From eb3e8b17bd91ab7cb1bcd42ac235325a399ccfa3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 17 Oct 2021 22:24:11 +0200 Subject: [PATCH 001/231] XCM v3: Expectations, BurnAsset --- xcm/src/lib.rs | 104 +++++++++++++++++++++++++----------- xcm/src/v1/mod.rs | 2 +- xcm/src/v2/mod.rs | 93 ++++++++++++++++++++++++++++++++ xcm/src/v2/traits.rs | 35 +++++++++++- xcm/xcm-executor/src/lib.rs | 16 ++++++ 5 files changed, 218 insertions(+), 32 deletions(-) diff --git a/xcm/src/lib.rs b/xcm/src/lib.rs index 87aad30c79f4..e7e1a98b3a61 100644 --- a/xcm/src/lib.rs +++ b/xcm/src/lib.rs @@ -35,9 +35,10 @@ use scale_info::TypeInfo; pub mod v0; pub mod v1; pub mod v2; +pub mod v3; pub mod latest { - pub use super::v2::*; + pub use super::v3::*; } mod double_encoded; @@ -83,7 +84,7 @@ impl IntoVersion for VersionedMultiLocation { fn into_version(self, n: Version) -> Result { Ok(match n { 0 => Self::V0(self.try_into()?), - 1 | 2 => Self::V1(self.try_into()?), + 1 | 2 | 3 => Self::V1(self.try_into()?), _ => return Err(()), }) } @@ -132,6 +133,7 @@ pub enum VersionedResponse { V0(v0::Response), V1(v1::Response), V2(v2::Response), + V3(v3::Response), } impl IntoVersion for VersionedResponse { @@ -140,6 +142,7 @@ impl IntoVersion for VersionedResponse { 0 => Self::V0(self.try_into()?), 1 => Self::V1(self.try_into()?), 2 => Self::V2(self.try_into()?), + 3 => Self::V3(self.try_into()?), _ => return Err(()), }) } @@ -157,9 +160,15 @@ impl From for VersionedResponse { } } -impl> From for VersionedResponse { +impl From for VersionedResponse { + fn from(x: v2::Response) -> Self { + VersionedResponse::V2(x) + } +} + +impl> From for VersionedResponse { fn from(x: T) -> Self { - VersionedResponse::V2(x.into()) + VersionedResponse::V3(x.into()) } } @@ -170,7 +179,8 @@ impl TryFrom for v0::Response { match x { V0(x) => Ok(x), V1(x) => x.try_into(), - V2(x) => VersionedResponse::V1(x.try_into()?).try_into(), + V2(x) => V1(x.try_into()?).try_into(), + V3(x) => V2(x.try_into()?).try_into(), } } } @@ -183,6 +193,7 @@ impl TryFrom for v1::Response { V0(x) => x.try_into(), V1(x) => Ok(x), V2(x) => x.try_into(), + V3(x) => V2(x.try_into()?).try_into(), } } } @@ -192,9 +203,23 @@ impl TryFrom for v2::Response { fn try_from(x: VersionedResponse) -> Result { use VersionedResponse::*; match x { - V0(x) => VersionedResponse::V1(x.try_into()?).try_into(), + V0(x) => V1(x.try_into()?).try_into(), V1(x) => x.try_into(), V2(x) => Ok(x), + V3(x) => x.try_into(), + } + } +} + +impl TryFrom for v3::Response { + type Error = (); + fn try_from(x: VersionedResponse) -> Result { + use VersionedResponse::*; + match x { + V0(x) => V1(x.try_into()?).try_into(), + V1(x) => V2(x.try_into()?).try_into(), + V2(x) => x.try_into(), + V3(x) => Ok(x), } } } @@ -213,7 +238,7 @@ impl IntoVersion for VersionedMultiAsset { fn into_version(self, n: Version) -> Result { Ok(match n { 0 => Self::V0(self.try_into()?), - 1 | 2 => Self::V1(self.try_into()?), + 1 | 2 | 3 => Self::V1(self.try_into()?), _ => return Err(()), }) } @@ -267,7 +292,7 @@ impl IntoVersion for VersionedMultiAssets { fn into_version(self, n: Version) -> Result { Ok(match n { 0 => Self::V0(self.try_into()?), - 1 | 2 => Self::V1(self.try_into()?), + 1 | 2 | 3 => Self::V1(self.try_into()?), _ => return Err(()), }) } @@ -317,6 +342,7 @@ pub enum VersionedXcm { V0(v0::Xcm), V1(v1::Xcm), V2(v2::Xcm), + V3(v3::Xcm), } impl IntoVersion for VersionedXcm { @@ -325,6 +351,7 @@ impl IntoVersion for VersionedXcm { 0 => Self::V0(self.try_into()?), 1 => Self::V1(self.try_into()?), 2 => Self::V2(self.try_into()?), + 3 => Self::V3(self.try_into()?), _ => return Err(()), }) } @@ -348,6 +375,12 @@ impl From> for VersionedXcm { } } +impl From> for VersionedXcm { + fn from(x: v3::Xcm) -> Self { + VersionedXcm::V3(x) + } +} + impl TryFrom> for v0::Xcm { type Error = (); fn try_from(x: VersionedXcm) -> Result { @@ -356,6 +389,7 @@ impl TryFrom> for v0::Xcm { V0(x) => Ok(x), V1(x) => x.try_into(), V2(x) => V1(x.try_into()?).try_into(), + V3(x) => V2(x.try_into()?).try_into(), } } } @@ -368,6 +402,7 @@ impl TryFrom> for v1::Xcm { V0(x) => x.try_into(), V1(x) => Ok(x), V2(x) => x.try_into(), + V3(x) => V2(x.try_into()?).try_into(), } } } @@ -380,6 +415,20 @@ impl TryFrom> for v2::Xcm { V0(x) => V1(x.try_into()?).try_into(), V1(x) => x.try_into(), V2(x) => Ok(x), + V3(x) => x.try_into(), + } + } +} + +impl TryFrom> for v3::Xcm { + type Error = (); + fn try_from(x: VersionedXcm) -> Result { + use VersionedXcm::*; + match x { + V0(x) => V1(x.try_into()?).try_into(), + V1(x) => V2(x.try_into()?).try_into(), + V2(x) => x.try_into(), + V3(x) => Ok(x), } } } @@ -402,48 +451,37 @@ impl WrapVersion for () { } } -/// `WrapVersion` implementation which attempts to always convert the XCM to version 0 before wrapping it. -pub struct AlwaysV0; -impl WrapVersion for AlwaysV0 { - fn wrap_version( - _: &latest::MultiLocation, - xcm: impl Into>, - ) -> Result, ()> { - Ok(VersionedXcm::::V0(xcm.into().try_into()?)) - } -} - -/// `WrapVersion` implementation which attempts to always convert the XCM to version 1 before wrapping it. -pub struct AlwaysV1; -impl WrapVersion for AlwaysV1 { +/// `WrapVersion` implementation which attempts to always convert the XCM to version 2 before wrapping it. +pub struct AlwaysV2; +impl WrapVersion for AlwaysV2 { fn wrap_version( _: &latest::MultiLocation, xcm: impl Into>, ) -> Result, ()> { - Ok(VersionedXcm::::V1(xcm.into().try_into()?)) + Ok(VersionedXcm::::V2(xcm.into().try_into()?)) } } /// `WrapVersion` implementation which attempts to always convert the XCM to version 2 before wrapping it. -pub struct AlwaysV2; -impl WrapVersion for AlwaysV2 { +pub struct AlwaysV3; +impl WrapVersion for AlwaysV3 { fn wrap_version( _: &latest::MultiLocation, xcm: impl Into>, ) -> Result, ()> { - Ok(VersionedXcm::::V2(xcm.into().try_into()?)) + Ok(VersionedXcm::::V3(xcm.into().try_into()?)) } } /// `WrapVersion` implementation which attempts to always convert the XCM to the latest version before wrapping it. -pub type AlwaysLatest = AlwaysV1; +pub type AlwaysLatest = AlwaysV2; /// `WrapVersion` implementation which attempts to always convert the XCM to the release version before wrapping it. -pub type AlwaysRelease = AlwaysV0; +pub type AlwaysRelease = AlwaysV2; pub mod prelude { pub use super::{ - latest::prelude::*, AlwaysLatest, AlwaysRelease, AlwaysV0, AlwaysV1, AlwaysV2, IntoVersion, + latest::prelude::*, AlwaysLatest, AlwaysRelease, AlwaysV2, AlwaysV3, IntoVersion, Unsupported, Version as XcmVersion, VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, VersionedXcm, WrapVersion, }; @@ -468,9 +506,15 @@ pub mod opaque { // Then override with the opaque types in v2 pub use crate::v2::opaque::{Instruction, Xcm}; } + pub mod v3 { + // Everything from v2 + pub use crate::v3::*; + // Then override with the opaque types in v3 + pub use crate::v3::opaque::{Instruction, Xcm}; + } pub mod latest { - pub use super::v2::*; + pub use super::v3::*; } /// The basic `VersionedXcm` type which just uses the `Vec` as an encoded call. diff --git a/xcm/src/v1/mod.rs b/xcm/src/v1/mod.rs index 87c016432018..43e7d504533c 100644 --- a/xcm/src/v1/mod.rs +++ b/xcm/src/v1/mod.rs @@ -505,7 +505,7 @@ impl TryFrom> for Xcm { } } -// Convert from a v1 response to a v2 response +// Convert from a v2 response to a v1 response impl TryFrom for Response { type Error = (); fn try_from(response: NewResponse) -> result::Result { diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index 60bec66ed963..6cbfec9d5e0d 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -17,6 +17,7 @@ //! Version 1 of the Cross-Consensus Message format data structures. use super::v1::{Order as OldOrder, Response as OldResponse, Xcm as OldXcm}; +use super::v3::{Instruction as NewInstruction, Response as NewResponse, Xcm as NewXcm}; use crate::{DoubleEncoded, GetWeight}; use alloc::{vec, vec::Vec}; use core::{ @@ -390,6 +391,12 @@ pub enum Instruction { /// /// A `QueryResponse` message of type `ExecutionOutcome` is sent to `dest` with the given /// `query_id` and the outcome of the XCM. + /// + /// - `query_id`: An identifier that will be replicated into the returned XCM message. + /// - `dest`: A valid destination for the returned XCM message. + /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which + /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the + /// response may not execute at all. /// /// Kind: *Instruction* /// @@ -601,8 +608,15 @@ pub enum Instruction { /// Ask the destination system to respond with the most recent version of XCM that they /// support in a `QueryResponse` instruction. Any changes to this should also elicit similar /// responses when they happen. + /// + /// - `query_id`: An identifier that will be replicated into the returned XCM message. + /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which + /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the + /// response may not execute at all. /// /// Kind: *Instruction* + /// + /// Errors: *Fallible* SubscribeVersion { #[codec(compact)] query_id: QueryId, @@ -613,6 +627,8 @@ pub enum Instruction { /// Cancel the effect of a previous `SubscribeVersion` instruction. /// /// Kind: *Instruction* + /// + /// Errors: *Fallible* UnsubscribeVersion, } @@ -744,6 +760,24 @@ impl TryFrom for Response { } } +// Convert from a v3 response to a v2 response +impl TryFrom for Response { + type Error = (); + fn try_from(response: NewResponse) -> result::Result { + match response { + NewResponse::Assets(assets) => Ok(Self::Assets(assets)), + NewResponse::Version(version) => Ok(Self::Version(version)), + NewResponse::ExecutionResult(error) => { + Ok(Self::ExecutionResult(match error { + Some((i, e)) => Some((i, e.try_into()?)), + None => None, + })) + }, + NewResponse::Null => Ok(Self::Null), + } + } +} + impl TryFrom> for Xcm { type Error = (); fn try_from(old: OldXcm) -> result::Result, ()> { @@ -796,6 +830,14 @@ impl TryFrom> for Xcm { } } +// Convert from a v3 XCM to a v2 XCM. +impl TryFrom> for Xcm { + type Error = (); + fn try_from(new_xcm: NewXcm) -> result::Result { + Ok(Xcm(new_xcm.0.into_iter().map(TryInto::try_into).collect::>()?)) + } +} + impl TryFrom> for Instruction { type Error = (); fn try_from(old: OldOrder) -> result::Result, ()> { @@ -845,6 +887,57 @@ impl TryFrom> for Instruction { } } +// Convert from a v3 instruction to a v2 instruction +impl TryFrom> for Instruction { + type Error = (); + fn try_from(instruction: NewInstruction) -> result::Result { + use NewInstruction::*; + Ok(match instruction { + WithdrawAsset(assets) => Self::WithdrawAsset(assets), + ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets), + ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets), + QueryResponse { query_id, response, max_weight } => + Self::QueryResponse { query_id, response: response.try_into()?, max_weight }, + TransferAsset { assets, beneficiary } => Self::TransferAsset { assets, beneficiary }, + TransferReserveAsset { assets, dest, xcm } => + Self::TransferReserveAsset { assets, dest, xcm: xcm.try_into()? }, + HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => + Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, + HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient }, + HrmpChannelClosing { initiator, sender, recipient } => + Self::HrmpChannelClosing { initiator, sender, recipient }, + Transact { origin_type, require_weight_at_most, call } => + Self::Transact { origin_type, require_weight_at_most, call: call.into() }, + ReportError { query_id, dest, max_response_weight } => + Self::ReportError { query_id, dest, max_response_weight }, + DepositAsset { assets, max_assets, beneficiary } => + Self::DepositAsset { assets, max_assets, beneficiary }, + DepositReserveAsset { assets, max_assets, dest, xcm } => + Self::DepositReserveAsset { assets, max_assets, dest, xcm: xcm.try_into()? }, + ExchangeAsset { give, receive } => Self::ExchangeAsset { give, receive }, + InitiateReserveWithdraw { assets, reserve, xcm } => + Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? }, + InitiateTeleport { assets, dest, xcm } => + Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? }, + QueryHolding { query_id, dest, assets, max_response_weight } => + Self::QueryHolding { query_id, dest, assets, max_response_weight }, + BuyExecution { fees, weight_limit } => Self::BuyExecution { fees, weight_limit }, + ClearOrigin => Self::ClearOrigin, + DescendOrigin(who) => Self::DescendOrigin(who), + RefundSurplus => Self::RefundSurplus, + SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), + SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), + ClearError => Self::ClearError, + ClaimAsset { assets, ticket } => Self::ClaimAsset { assets, ticket }, + Trap(code) => Self::Trap(code), + SubscribeVersion { query_id, max_response_weight } => + Self::SubscribeVersion { query_id, max_response_weight }, + UnsubscribeVersion => Self::UnsubscribeVersion, + _ => return Err(()), + }) + } +} + #[cfg(test)] mod tests { use super::{prelude::*, *}; diff --git a/xcm/src/v2/traits.rs b/xcm/src/v2/traits.rs index d1e1381f4de3..79410f06838f 100644 --- a/xcm/src/v2/traits.rs +++ b/xcm/src/v2/traits.rs @@ -19,6 +19,7 @@ use core::result; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; +use crate::v3::Error as NewError; use super::*; @@ -110,6 +111,38 @@ pub enum Error { WeightNotComputable, } +impl TryFrom for Error { + type Error = (); + fn try_from(new_error: NewError) -> result::Result { + use NewError::*; + Ok(match new_error { + Overflow => Self::Overflow, + Unimplemented => Self::Unimplemented, + UntrustedReserveLocation => Self::UntrustedReserveLocation, + UntrustedTeleportLocation => Self::UntrustedTeleportLocation, + MultiLocationFull => Self::MultiLocationFull, + MultiLocationNotInvertible => Self::MultiLocationNotInvertible, + BadOrigin => Self::BadOrigin, + InvalidLocation => Self::InvalidLocation, + AssetNotFound => Self::AssetNotFound, + FailedToTransactAsset(s) => Self::FailedToTransactAsset(s), + NotWithdrawable => Self::NotWithdrawable, + LocationCannotHold => Self::LocationCannotHold, + ExceedsMaxMessageSize => Self::ExceedsMaxMessageSize, + DestinationUnsupported => Self::DestinationUnsupported, + Transport(s) => Self::Transport(s), + Unroutable => Self::Unroutable, + UnknownClaim => Self::UnknownClaim, + FailedToDecode => Self::FailedToDecode, + TooMuchWeightRequired => Self::TooMuchWeightRequired, + NotHoldingFees => Self::NotHoldingFees, + TooExpensive => Self::TooExpensive, + Trap(i) => Self::Trap(i), + _ => return Err(()), + }) + } +} + impl From for Error { fn from(e: SendError) -> Self { match e { @@ -320,7 +353,7 @@ impl SendXcm for Tuple { } } -/// The info needed to weight an XCM. +/// The info needed to weigh an XCM. // TODO: Automate Generation pub trait XcmWeightInfo { fn withdraw_asset(assets: &MultiAssets) -> Weight; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index f252b2e7e3a3..fbeca92a2107 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -451,6 +451,22 @@ impl XcmExecutor { ensure!(&self.original_origin == origin, XcmError::BadOrigin); Config::SubscriptionService::stop(origin) }, + BurnAsset(assets) => { + self.holding.saturating_take(assets.into()); + Ok(()) + }, + ExpectAsset(assets) => { + self.holding.ensure_contains(&assets).map_err(|_| XcmError::ExpectationFalse) + }, + ExpectOrigin(origin) => { + let origin_ref = self.origin.as_ref().ok_or(XcmError::ExpectationFalse)?; + ensure!(origin_ref == &origin, XcmError::ExpectationFalse); + Ok(()) + }, + ExpectError(error) => { + ensure!(self.error == error, XcmError::ExpectationFalse); + Ok(()) + }, ExchangeAsset { .. } => Err(XcmError::Unimplemented), HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), From c448fdafe5ea3f83e47434c9bf3fdc9be7c26626 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 17 Oct 2021 22:24:26 +0200 Subject: [PATCH 002/231] Add files --- xcm/src/v3/mod.rs | 902 +++++++++++++++++++++++++++++++++++++++++++ xcm/src/v3/traits.rs | 421 ++++++++++++++++++++ 2 files changed, 1323 insertions(+) create mode 100644 xcm/src/v3/mod.rs create mode 100644 xcm/src/v3/traits.rs diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs new file mode 100644 index 000000000000..dc5de519d3a4 --- /dev/null +++ b/xcm/src/v3/mod.rs @@ -0,0 +1,902 @@ +// Copyright 2020 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Version 1 of the Cross-Consensus Message format data structures. + +use super::v2::{Instruction as OldInstruction, Response as OldResponse, Xcm as OldXcm}; +use crate::{DoubleEncoded, GetWeight}; +use alloc::{vec, vec::Vec}; +use core::{ + convert::{TryFrom, TryInto}, + fmt::Debug, + result, +}; +use derivative::Derivative; +use parity_scale_codec::{self, Decode, Encode}; +use scale_info::TypeInfo; + +mod traits; + +pub use traits::{ + Error, ExecuteXcm, Outcome, Result, SendError, SendResult, SendXcm, Weight, XcmWeightInfo, +}; +// These parts of XCM v1 have been unchanged in XCM v2, and are re-imported here. +pub use super::v2::{ + Ancestor, AncestorThen, AssetId, AssetInstance, BodyId, BodyPart, Fungibility, + InteriorMultiLocation, Junction, Junctions, MultiAsset, MultiAssetFilter, MultiAssets, + MultiLocation, NetworkId, OriginKind, Parent, ParentThen, WildFungibility, WildMultiAsset, + WeightLimit, +}; + +/// This module's XCM version. +pub const VERSION: super::Version = 3; + +/// An identifier for a query. +pub type QueryId = u64; + +#[derive(Derivative, Default, Encode, Decode, TypeInfo)] +#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] +#[codec(encode_bound())] +#[codec(decode_bound())] +#[scale_info(bounds(), skip_type_params(Call))] +pub struct Xcm(pub Vec>); + +impl Xcm { + /// Create an empty instance. + pub fn new() -> Self { + Self(vec![]) + } + + /// Return `true` if no instructions are held in `self`. + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } + + /// Return the number of instructions held in `self`. + pub fn len(&self) -> usize { + self.0.len() + } + + /// Consume and either return `self` if it contains some instructions, or if it's empty, then + /// instead return the result of `f`. + pub fn or_else(self, f: impl FnOnce() -> Self) -> Self { + if self.0.is_empty() { + f() + } else { + self + } + } + + /// Return the first instruction, if any. + pub fn first(&self) -> Option<&Instruction> { + self.0.first() + } + + /// Return the last instruction, if any. + pub fn last(&self) -> Option<&Instruction> { + self.0.last() + } + + /// Return the only instruction, contained in `Self`, iff only one exists (`None` otherwise). + pub fn only(&self) -> Option<&Instruction> { + if self.0.len() == 1 { + self.0.first() + } else { + None + } + } + + /// Return the only instruction, contained in `Self`, iff only one exists (returns `self` + /// otherwise). + pub fn into_only(mut self) -> core::result::Result, Self> { + if self.0.len() == 1 { + self.0.pop().ok_or(self) + } else { + Err(self) + } + } +} + +/// A prelude for importing all types typically used when interacting with XCM messages. +pub mod prelude { + mod contents { + pub use super::super::{ + Ancestor, AncestorThen, + AssetId::{self, *}, + AssetInstance::{self, *}, + BodyId, BodyPart, Error as XcmError, ExecuteXcm, + Fungibility::{self, *}, + Instruction::*, + InteriorMultiLocation, + Junction::{self, *}, + Junctions::{self, *}, + MultiAsset, + MultiAssetFilter::{self, *}, + MultiAssets, MultiLocation, + NetworkId::{self, *}, + OriginKind, Outcome, Parent, ParentThen, QueryId, Response, Result as XcmResult, + SendError, SendResult, SendXcm, + WeightLimit::{self, *}, + WildFungibility::{self, Fungible as WildFungible, NonFungible as WildNonFungible}, + WildMultiAsset::{self, *}, + XcmWeightInfo, VERSION as XCM_VERSION, + }; + } + pub use super::{Instruction, Xcm}; + pub use contents::*; + pub mod opaque { + pub use super::{ + super::opaque::{Instruction, Xcm}, + contents::*, + }; + } +} + +/// Response data to a query. +#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] +pub enum Response { + /// No response. Serves as a neutral default. + Null, + /// Some assets. + Assets(MultiAssets), + /// The outcome of an XCM instruction. + ExecutionResult(Option<(u32, Error)>), + /// An XCM version. + Version(super::Version), +} + +impl Default for Response { + fn default() -> Self { + Self::Null + } +} + +/// Cross-Consensus Message: A message from one consensus system to another. +/// +/// Consensus systems that may send and receive messages include blockchains and smart contracts. +/// +/// All messages are delivered from a known *origin*, expressed as a `MultiLocation`. +/// +/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the outer +/// XCM format, known as `VersionedXcm`. +#[derive(Derivative, Encode, Decode, TypeInfo)] +#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] +#[codec(encode_bound())] +#[codec(decode_bound())] +#[scale_info(bounds(), skip_type_params(Call))] +pub enum Instruction { + /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the Holding + /// Register. + /// + /// - `assets`: The asset(s) to be withdrawn into holding. + /// + /// Kind: *Instruction*. + /// + /// Errors: + WithdrawAsset(MultiAssets), + + /// Asset(s) (`assets`) have been received into the ownership of this system on the `origin` + /// system and equivalent derivatives should be placed into the Holding Register. + /// + /// - `assets`: The asset(s) that are minted into holding. + /// + /// Safety: `origin` must be trusted to have received and be storing `assets` such that they + /// may later be withdrawn should this system send a corresponding message. + /// + /// Kind: *Trusted Indication*. + /// + /// Errors: + ReserveAssetDeposited(MultiAssets), + + /// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets should + /// be created and placed into the Holding Register. + /// + /// - `assets`: The asset(s) that are minted into the Holding Register. + /// + /// Safety: `origin` must be trusted to have irrevocably destroyed the corresponding `assets` + /// prior as a consequence of sending this message. + /// + /// Kind: *Trusted Indication*. + /// + /// Errors: + ReceiveTeleportedAsset(MultiAssets), + + /// Respond with information that the local system is expecting. + /// + /// - `query_id`: The identifier of the query that resulted in this message being sent. + /// - `response`: The message content. + /// - `max_weight`: The maximum weight that handling this response should take. + /// + /// Safety: No concerns. + /// + /// Kind: *Information*. + /// + /// Errors: + QueryResponse { + #[codec(compact)] + query_id: QueryId, + response: Response, + #[codec(compact)] + max_weight: u64, + }, + + /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets + /// under the ownership of `beneficiary`. + /// + /// - `assets`: The asset(s) to be withdrawn. + /// - `beneficiary`: The new owner for the assets. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction*. + /// + /// Errors: + TransferAsset { assets: MultiAssets, beneficiary: MultiLocation }, + + /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets + /// under the ownership of `dest` within this consensus system (i.e. its sovereign account). + /// + /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the given + /// `xcm`. + /// + /// - `assets`: The asset(s) to be withdrawn. + /// - `dest`: The location whose sovereign account will own the assets and thus the effective + /// beneficiary for the assets and the notification target for the reserve asset deposit + /// message. + /// - `xcm`: The instructions that should follow the `ReserveAssetDeposited` + /// instruction, which is sent onwards to `dest`. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction*. + /// + /// Errors: + TransferReserveAsset { assets: MultiAssets, dest: MultiLocation, xcm: Xcm<()> }, + + /// Apply the encoded transaction `call`, whose dispatch-origin should be `origin` as expressed + /// by the kind of origin `origin_type`. + /// + /// - `origin_type`: The means of expressing the message origin as a dispatch origin. + /// - `max_weight`: The weight of `call`; this should be at least the chain's calculated weight + /// and will be used in the weight determination arithmetic. + /// - `call`: The encoded transaction to be applied. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction*. + /// + /// Errors: + Transact { + origin_type: OriginKind, + #[codec(compact)] + require_weight_at_most: u64, + call: DoubleEncoded, + }, + + /// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the + /// relay-chain to a para. + /// + /// - `sender`: The sender in the to-be opened channel. Also, the initiator of the channel opening. + /// - `max_message_size`: The maximum size of a message proposed by the sender. + /// - `max_capacity`: The maximum number of messages that can be queued in the channel. + /// + /// Safety: The message should originate directly from the relay-chain. + /// + /// Kind: *System Notification* + HrmpNewChannelOpenRequest { + #[codec(compact)] + sender: u32, + #[codec(compact)] + max_message_size: u32, + #[codec(compact)] + max_capacity: u32, + }, + + /// A message to notify about that a previously sent open channel request has been accepted by + /// the recipient. That means that the channel will be opened during the next relay-chain session + /// change. This message is meant to be sent by the relay-chain to a para. + /// + /// Safety: The message should originate directly from the relay-chain. + /// + /// Kind: *System Notification* + /// + /// Errors: + HrmpChannelAccepted { + // NOTE: We keep this as a structured item to a) keep it consistent with the other Hrmp + // items; and b) because the field's meaning is not obvious/mentioned from the item name. + #[codec(compact)] + recipient: u32, + }, + + /// A message to notify that the other party in an open channel decided to close it. In particular, + /// `initiator` is going to close the channel opened from `sender` to the `recipient`. The close + /// will be enacted at the next relay-chain session change. This message is meant to be sent by + /// the relay-chain to a para. + /// + /// Safety: The message should originate directly from the relay-chain. + /// + /// Kind: *System Notification* + /// + /// Errors: + HrmpChannelClosing { + #[codec(compact)] + initiator: u32, + #[codec(compact)] + sender: u32, + #[codec(compact)] + recipient: u32, + }, + + /// Clear the origin. + /// + /// This may be used by the XCM author to ensure that later instructions cannot command the + /// authority of the origin (e.g. if they are being relayed from an untrusted source, as often + /// the case with `ReserveAssetDeposited`). + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction*. + /// + /// Errors: + ClearOrigin, + + /// Mutate the origin to some interior location. + /// + /// Kind: *Instruction* + /// + /// Errors: + DescendOrigin(InteriorMultiLocation), + + /// Immediately report the contents of the Error Register to the given destination via XCM. + /// + /// A `QueryResponse` message of type `ExecutionOutcome` is sent to `dest` with the given + /// `query_id` and the outcome of the XCM. + /// + /// - `query_id`: An identifier that will be replicated into the returned XCM message. + /// - `dest`: A valid destination for the returned XCM message. + /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which + /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the + /// response may not execute at all. + /// + /// Kind: *Instruction* + /// + /// Errors: + ReportError { + #[codec(compact)] + query_id: QueryId, + dest: MultiLocation, + #[codec(compact)] + max_response_weight: u64, + }, + + /// Remove the asset(s) (`assets`) from the Holding Register and place equivalent assets under + /// the ownership of `beneficiary` within this consensus system. + /// + /// - `assets`: The asset(s) to remove from holding. + /// - `max_assets`: The maximum number of unique assets/asset instances to remove from holding. + /// Only the first `max_assets` assets/instances of those matched by `assets` will be removed, + /// prioritized under standard asset ordering. Any others will remain in holding. + /// - `beneficiary`: The new owner for the assets. + /// + /// Kind: *Instruction* + /// + /// Errors: + DepositAsset { + assets: MultiAssetFilter, + #[codec(compact)] + max_assets: u32, + beneficiary: MultiLocation, + }, + + /// Remove the asset(s) (`assets`) from the Holding Register and place equivalent assets under + /// the ownership of `dest` within this consensus system (i.e. deposit them into its sovereign + /// account). + /// + /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the given `effects`. + /// + /// - `assets`: The asset(s) to remove from holding. + /// - `max_assets`: The maximum number of unique assets/asset instances to remove from holding. + /// Only the first `max_assets` assets/instances of those matched by `assets` will be removed, + /// prioritized under standard asset ordering. Any others will remain in holding. + /// - `dest`: The location whose sovereign account will own the assets and thus the effective + /// beneficiary for the assets and the notification target for the reserve asset deposit + /// message. + /// - `xcm`: The orders that should follow the `ReserveAssetDeposited` instruction + /// which is sent onwards to `dest`. + /// + /// Kind: *Instruction* + /// + /// Errors: + DepositReserveAsset { + assets: MultiAssetFilter, + #[codec(compact)] + max_assets: u32, + dest: MultiLocation, + xcm: Xcm<()>, + }, + + /// Remove the asset(s) (`give`) from the Holding Register and replace them with alternative + /// assets. + /// + /// The minimum amount of assets to be received into the Holding Register for the order not to + /// fail may be stated. + /// + /// - `give`: The asset(s) to remove from holding. + /// - `receive`: The minimum amount of assets(s) which `give` should be exchanged for. + /// + /// Kind: *Instruction* + /// + /// Errors: + ExchangeAsset { give: MultiAssetFilter, receive: MultiAssets }, + + /// Remove the asset(s) (`assets`) from holding and send a `WithdrawAsset` XCM message to a + /// reserve location. + /// + /// - `assets`: The asset(s) to remove from holding. + /// - `reserve`: A valid location that acts as a reserve for all asset(s) in `assets`. The + /// sovereign account of this consensus system *on the reserve location* will have appropriate + /// assets withdrawn and `effects` will be executed on them. There will typically be only one + /// valid location on any given asset/chain combination. + /// - `xcm`: The instructions to execute on the assets once withdrawn *on the reserve + /// location*. + /// + /// Kind: *Instruction* + /// + /// Errors: + InitiateReserveWithdraw { assets: MultiAssetFilter, reserve: MultiLocation, xcm: Xcm<()> }, + + /// Remove the asset(s) (`assets`) from holding and send a `ReceiveTeleportedAsset` XCM message + /// to a `dest` location. + /// + /// - `assets`: The asset(s) to remove from holding. + /// - `dest`: A valid location that respects teleports coming from this location. + /// - `xcm`: The instructions to execute on the assets once arrived *on the destination + /// location*. + /// + /// NOTE: The `dest` location *MUST* respect this origin as a valid teleportation origin for all + /// `assets`. If it does not, then the assets may be lost. + /// + /// Kind: *Instruction* + /// + /// Errors: + InitiateTeleport { assets: MultiAssetFilter, dest: MultiLocation, xcm: Xcm<()> }, + + /// Send a `Balances` XCM message with the `assets` value equal to the holding contents, or a + /// portion thereof. + /// + /// - `query_id`: An identifier that will be replicated into the returned XCM message. + /// - `dest`: A valid destination for the returned XCM message. This may be limited to the + /// current origin. + /// - `assets`: A filter for the assets that should be reported back. The assets reported back + /// will be, asset-wise, *the lesser of this value and the holding register*. No wildcards + /// will be used when reporting assets back. + /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which + /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the + /// response may not execute at all. + /// + /// Kind: *Instruction* + /// + /// Errors: + QueryHolding { + #[codec(compact)] + query_id: QueryId, + dest: MultiLocation, + assets: MultiAssetFilter, + #[codec(compact)] + max_response_weight: u64, + }, + + /// Pay for the execution of some XCM `xcm` and `orders` with up to `weight` + /// picoseconds of execution time, paying for this with up to `fees` from the Holding Register. + /// + /// - `fees`: The asset(s) to remove from the Holding Register to pay for fees. + /// - `weight_limit`: The maximum amount of weight to purchase; this must be at least the + /// expected maximum weight of the total XCM to be executed for the + /// `AllowTopLevelPaidExecutionFrom` barrier to allow the XCM be executed. + /// + /// Kind: *Instruction* + /// + /// Errors: + BuyExecution { fees: MultiAsset, weight_limit: WeightLimit }, + + /// Refund any surplus weight previously bought with `BuyExecution`. + /// + /// Kind: *Instruction* + /// + /// Errors: None. + RefundSurplus, + + /// Set the Error Handler Register. This is code that should be called in the case of an error + /// happening. + /// + /// An error occurring within execution of this code will _NOT_ result in the error register + /// being set, nor will an error handler be called due to it. The error handler and appendix + /// may each still be set. + /// + /// The apparent weight of this instruction is inclusive of the inner `Xcm`; the executing + /// weight however includes only the difference between the previous handler and the new + /// handler, which can reasonably be negative, which would result in a surplus. + /// + /// Kind: *Instruction* + /// + /// Errors: None. + SetErrorHandler(Xcm), + + /// Set the Appendix Register. This is code that should be called after code execution + /// (including the error handler if any) is finished. This will be called regardless of whether + /// an error occurred. + /// + /// Any error occurring due to execution of this code will result in the error register being + /// set, and the error handler (if set) firing. + /// + /// The apparent weight of this instruction is inclusive of the inner `Xcm`; the executing + /// weight however includes only the difference between the previous appendix and the new + /// appendix, which can reasonably be negative, which would result in a surplus. + /// + /// Kind: *Instruction* + /// + /// Errors: None. + SetAppendix(Xcm), + + /// Clear the Error Register. + /// + /// Kind: *Instruction* + /// + /// Errors: None. + ClearError, + + /// Create some assets which are being held on behalf of the origin. + /// + /// - `assets`: The assets which are to be claimed. This must match exactly with the assets + /// claimable by the origin of the ticket. + /// - `ticket`: The ticket of the asset; this is an abstract identifier to help locate the + /// asset. + /// + /// Kind: *Instruction* + /// + /// Errors: + ClaimAsset { assets: MultiAssets, ticket: MultiLocation }, + + /// Always throws an error of type `Trap`. + /// + /// Kind: *Instruction* + /// + /// Errors: + /// - `Trap`: All circumstances, whose inner value is the same as this item's inner value. + Trap(#[codec(compact)] u64), + + /// Ask the destination system to respond with the most recent version of XCM that they + /// support in a `QueryResponse` instruction. Any changes to this should also elicit similar + /// responses when they happen. + /// + /// - `query_id`: An identifier that will be replicated into the returned XCM message. + /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which + /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the + /// response may not execute at all. + /// + /// Kind: *Instruction* + /// + /// Errors: *Fallible* + SubscribeVersion { + #[codec(compact)] + query_id: QueryId, + #[codec(compact)] + max_response_weight: u64, + }, + + /// Cancel the effect of a previous `SubscribeVersion` instruction. + /// + /// Kind: *Instruction* + /// + /// Errors: *Fallible* + UnsubscribeVersion, + + /// Reduce Holding by up to the given assets. + /// + /// Holding is reduced by up to the assets in the parameter. If this is less than the + /// + /// Kind: *Instruction* + /// + /// Errors: *Fallible* + BurnAsset(MultiAssets), + + /// Throw an error if Holding does not contain at least the given assets. + /// + /// Kind: *Instruction* + /// + /// Errors: + /// - `ExpectationFalse`: If Holding Register does not contain the assets in the parameter. + ExpectAsset(MultiAssets), + + /// Ensure that the Origin Register equals some given value and throw an error if not. + /// + /// Kind: *Instruction* + /// + /// Errors: + /// - `ExpectationFalse`: If Origin Register is not some value, or if that value is not equal to + /// the parameter. + ExpectOrigin(MultiLocation), + + /// Ensure that the Error Register equals some given value and throw an error if not. + /// + /// Kind: *Instruction* + /// + /// Errors: + /// - `ExpectationFalse`: If the value of the Error Register is not equal to the parameter. + ExpectError(Option<(u32, Error)>), +} + +impl Xcm { + pub fn into(self) -> Xcm { + Xcm::from(self) + } + pub fn from(xcm: Xcm) -> Self { + Self(xcm.0.into_iter().map(Instruction::::from).collect()) + } +} + +impl Instruction { + pub fn into(self) -> Instruction { + Instruction::from(self) + } + pub fn from(xcm: Instruction) -> Self { + use Instruction::*; + match xcm { + WithdrawAsset(assets) => WithdrawAsset(assets), + ReserveAssetDeposited(assets) => ReserveAssetDeposited(assets), + ReceiveTeleportedAsset(assets) => ReceiveTeleportedAsset(assets), + QueryResponse { query_id, response, max_weight } => + QueryResponse { query_id, response, max_weight }, + TransferAsset { assets, beneficiary } => TransferAsset { assets, beneficiary }, + TransferReserveAsset { assets, dest, xcm } => + TransferReserveAsset { assets, dest, xcm }, + HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => + HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, + HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient }, + HrmpChannelClosing { initiator, sender, recipient } => + HrmpChannelClosing { initiator, sender, recipient }, + Transact { origin_type, require_weight_at_most, call } => + Transact { origin_type, require_weight_at_most, call: call.into() }, + ReportError { query_id, dest, max_response_weight } => + ReportError { query_id, dest, max_response_weight }, + DepositAsset { assets, max_assets, beneficiary } => + DepositAsset { assets, max_assets, beneficiary }, + DepositReserveAsset { assets, max_assets, dest, xcm } => + DepositReserveAsset { assets, max_assets, dest, xcm }, + ExchangeAsset { give, receive } => ExchangeAsset { give, receive }, + InitiateReserveWithdraw { assets, reserve, xcm } => + InitiateReserveWithdraw { assets, reserve, xcm }, + InitiateTeleport { assets, dest, xcm } => InitiateTeleport { assets, dest, xcm }, + QueryHolding { query_id, dest, assets, max_response_weight } => + QueryHolding { query_id, dest, assets, max_response_weight }, + BuyExecution { fees, weight_limit } => BuyExecution { fees, weight_limit }, + ClearOrigin => ClearOrigin, + DescendOrigin(who) => DescendOrigin(who), + RefundSurplus => RefundSurplus, + SetErrorHandler(xcm) => SetErrorHandler(xcm.into()), + SetAppendix(xcm) => SetAppendix(xcm.into()), + ClearError => ClearError, + ClaimAsset { assets, ticket } => ClaimAsset { assets, ticket }, + Trap(code) => Trap(code), + SubscribeVersion { query_id, max_response_weight } => + SubscribeVersion { query_id, max_response_weight }, + UnsubscribeVersion => UnsubscribeVersion, + BurnAsset(assets) => BurnAsset(assets), + ExpectAsset(assets) => ExpectAsset(assets), + ExpectOrigin(origin) => ExpectOrigin(origin), + ExpectError(error) => ExpectError(error), + } + } +} + +// TODO: Automate Generation +impl> GetWeight for Instruction { + fn weight(&self) -> Weight { + use Instruction::*; + match self { + WithdrawAsset(assets) => W::withdraw_asset(assets), + ReserveAssetDeposited(assets) => W::reserve_asset_deposited(assets), + ReceiveTeleportedAsset(assets) => W::receive_teleported_asset(assets), + QueryResponse { query_id, response, max_weight } => + W::query_response(query_id, response, max_weight), + TransferAsset { assets, beneficiary } => W::transfer_asset(assets, beneficiary), + TransferReserveAsset { assets, dest, xcm } => + W::transfer_reserve_asset(&assets, dest, xcm), + Transact { origin_type, require_weight_at_most, call } => + W::transact(origin_type, require_weight_at_most, call), + HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => + W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity), + HrmpChannelAccepted { recipient } => W::hrmp_channel_accepted(recipient), + HrmpChannelClosing { initiator, sender, recipient } => + W::hrmp_channel_closing(initiator, sender, recipient), + ClearOrigin => W::clear_origin(), + DescendOrigin(who) => W::descend_origin(who), + ReportError { query_id, dest, max_response_weight } => + W::report_error(query_id, dest, max_response_weight), + DepositAsset { assets, max_assets, beneficiary } => + W::deposit_asset(assets, max_assets, beneficiary), + DepositReserveAsset { assets, max_assets, dest, xcm } => + W::deposit_reserve_asset(assets, max_assets, dest, xcm), + ExchangeAsset { give, receive } => W::exchange_asset(give, receive), + InitiateReserveWithdraw { assets, reserve, xcm } => + W::initiate_reserve_withdraw(assets, reserve, xcm), + InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm), + QueryHolding { query_id, dest, assets, max_response_weight } => + W::query_holding(query_id, dest, assets, max_response_weight), + BuyExecution { fees, weight_limit } => W::buy_execution(fees, weight_limit), + RefundSurplus => W::refund_surplus(), + SetErrorHandler(xcm) => W::set_error_handler(xcm), + SetAppendix(xcm) => W::set_appendix(xcm), + ClearError => W::clear_error(), + ClaimAsset { assets, ticket } => W::claim_asset(assets, ticket), + Trap(code) => W::trap(code), + SubscribeVersion { query_id, max_response_weight } => + W::subscribe_version(query_id, max_response_weight), + UnsubscribeVersion => W::unsubscribe_version(), + BurnAsset(assets) => W::burn_asset(assets), + ExpectAsset(assets) => W::expect_asset(assets), + ExpectOrigin(origin) => W::expect_origin(origin), + ExpectError(error) => W::expect_error(error), + } + } +} + +pub mod opaque { + /// The basic concrete type of `Xcm`, which doesn't make any assumptions about the + /// format of a call other than it is pre-encoded. + pub type Xcm = super::Xcm<()>; + + /// The basic concrete type of `Instruction`, which doesn't make any assumptions about the + /// format of a call other than it is pre-encoded. + pub type Instruction = super::Instruction<()>; +} + +// Convert from a v2 response to a v3 response. +impl TryFrom for Response { + type Error = (); + fn try_from(old_response: OldResponse) -> result::Result { + match old_response { + OldResponse::Assets(assets) => Ok(Self::Assets(assets)), + OldResponse::Version(version) => Ok(Self::Version(version)), + OldResponse::ExecutionResult(error) => { + Ok(Self::ExecutionResult(match error { + Some((i, e)) => Some((i, e.try_into()?)), + None => None, + })) + }, + OldResponse::Null => Ok(Self::Null), + } + } +} + +// Convert from a v2 XCM to a v3 XCM. +impl TryFrom> for Xcm { + type Error = (); + fn try_from(old_xcm: OldXcm) -> result::Result { + Ok(Xcm(old_xcm.0.into_iter().map(TryInto::try_into).collect::>()?)) + } +} + +// Convert from a v2 instruction to a v3 instruction. +impl TryFrom> for Instruction { + type Error = (); + fn try_from(old_instruction: OldInstruction) -> result::Result { + use OldInstruction::*; + Ok(match old_instruction { + WithdrawAsset(assets) => Self::WithdrawAsset(assets), + ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets), + ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets), + QueryResponse { query_id, response, max_weight } => + Self::QueryResponse { query_id, response: response.try_into()?, max_weight }, + TransferAsset { assets, beneficiary } => Self::TransferAsset { assets, beneficiary }, + TransferReserveAsset { assets, dest, xcm } => + Self::TransferReserveAsset { assets, dest, xcm: xcm.try_into()? }, + HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => + Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, + HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient }, + HrmpChannelClosing { initiator, sender, recipient } => + Self::HrmpChannelClosing { initiator, sender, recipient }, + Transact { origin_type, require_weight_at_most, call } => + Self::Transact { origin_type, require_weight_at_most, call: call.into() }, + ReportError { query_id, dest, max_response_weight } => + Self::ReportError { query_id, dest, max_response_weight }, + DepositAsset { assets, max_assets, beneficiary } => + Self::DepositAsset { assets, max_assets, beneficiary }, + DepositReserveAsset { assets, max_assets, dest, xcm } => + Self::DepositReserveAsset { assets, max_assets, dest, xcm: xcm.try_into()? }, + ExchangeAsset { give, receive } => Self::ExchangeAsset { give, receive }, + InitiateReserveWithdraw { assets, reserve, xcm } => + Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? }, + InitiateTeleport { assets, dest, xcm } => + Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? }, + QueryHolding { query_id, dest, assets, max_response_weight } => + Self::QueryHolding { query_id, dest, assets, max_response_weight }, + BuyExecution { fees, weight_limit } => Self::BuyExecution { fees, weight_limit }, + ClearOrigin => Self::ClearOrigin, + DescendOrigin(who) => Self::DescendOrigin(who), + RefundSurplus => Self::RefundSurplus, + SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), + SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), + ClearError => Self::ClearError, + ClaimAsset { assets, ticket } => Self::ClaimAsset { assets, ticket }, + Trap(code) => Self::Trap(code), + SubscribeVersion { query_id, max_response_weight } => + Self::SubscribeVersion { query_id, max_response_weight }, + UnsubscribeVersion => Self::UnsubscribeVersion, + }) + } +} + +#[cfg(test)] +mod tests { + use super::{prelude::*, *}; + + #[test] + fn basic_roundtrip_works() { + let xcm = + Xcm::<()>(vec![TransferAsset { assets: (Here, 1).into(), beneficiary: Here.into() }]); + let old_xcm = OldXcm::<()>(vec![ + OldInstruction::TransferAsset { assets: (Here, 1).into(), beneficiary: Here.into() } + ]); + assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); + let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); + assert_eq!(new_xcm, xcm); + } + + #[test] + fn teleport_roundtrip_works() { + let xcm = Xcm::<()>(vec![ + ReceiveTeleportedAsset((Here, 1).into()), + ClearOrigin, + DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Here.into() }, + ]); + let old_xcm: OldXcm<()> = OldXcm::<()>(vec![ + OldInstruction::ReceiveTeleportedAsset((Here, 1).into()), + OldInstruction::ClearOrigin, + OldInstruction::DepositAsset { + assets: Wild(All), + max_assets: 1, + beneficiary: Here.into(), + }, + ]); + assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); + let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); + assert_eq!(new_xcm, xcm); + } + + #[test] + fn reserve_deposit_roundtrip_works() { + let xcm = Xcm::<()>(vec![ + ReserveAssetDeposited((Here, 1).into()), + ClearOrigin, + BuyExecution { fees: (Here, 1).into(), weight_limit: Some(1).into() }, + DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Here.into() }, + ]); + let old_xcm = OldXcm::<()>(vec![ + OldInstruction::ReserveAssetDeposited((Here, 1).into()), + OldInstruction::ClearOrigin, + OldInstruction::BuyExecution { fees: (Here, 1).into(), weight_limit: Some(1).into() }, + OldInstruction::DepositAsset { + assets: Wild(All), + max_assets: 1, + beneficiary: Here.into(), + }, + ]); + assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); + let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); + assert_eq!(new_xcm, xcm); + } +} diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs new file mode 100644 index 000000000000..230cfa2085bf --- /dev/null +++ b/xcm/src/v3/traits.rs @@ -0,0 +1,421 @@ +// Copyright 2020 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Cross-Consensus Message format data structures. + +use core::result; +use parity_scale_codec::{Decode, Encode}; +use scale_info::TypeInfo; +use crate::v2::Error as OldError; + +use super::*; + +#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] +pub enum Error { + // Errors that happen due to instructions being executed. These alone are defined in the + // XCM specification. + /// An arithmetic overflow happened. + #[codec(index = 0)] + Overflow, + /// The instruction is intentionally unsupported. + #[codec(index = 1)] + Unimplemented, + /// Origin Register does not contain a value value for a reserve transfer notification. + #[codec(index = 2)] + UntrustedReserveLocation, + /// Origin Register does not contain a value value for a teleport notification. + #[codec(index = 3)] + UntrustedTeleportLocation, + /// `MultiLocation` value too large to descend further. + #[codec(index = 4)] + MultiLocationFull, + /// `MultiLocation` value ascend more parents than known ancestors of local location. + #[codec(index = 5)] + MultiLocationNotInvertible, + /// The Origin Register does not contain a valid value for instruction. + #[codec(index = 6)] + BadOrigin, + /// The location parameter is not a valid value for the instruction. + #[codec(index = 7)] + InvalidLocation, + /// The given asset is not handled. + #[codec(index = 8)] + AssetNotFound, + /// An asset transaction (like withdraw or deposit) failed (typically due to type conversions). + #[codec(index = 9)] + FailedToTransactAsset(#[codec(skip)] &'static str), + /// An asset cannot be withdrawn, potentially due to lack of ownership, availability or rights. + #[codec(index = 10)] + NotWithdrawable, + /// An asset cannot be deposited under the ownership of a particular location. + #[codec(index = 11)] + LocationCannotHold, + /// Attempt to send a message greater than the maximum supported by the transport protocol. + #[codec(index = 12)] + ExceedsMaxMessageSize, + /// The given message cannot be translated into a format supported by the destination. + #[codec(index = 13)] + DestinationUnsupported, + /// Destination is routable, but there is some issue with the transport mechanism. + #[codec(index = 14)] + Transport(#[codec(skip)] &'static str), + /// Destination is known to be unroutable. + #[codec(index = 15)] + Unroutable, + /// Used by `ClaimAsset` when the given claim could not be recognized/found. + #[codec(index = 16)] + UnknownClaim, + /// Used by `Transact` when the functor cannot be decoded. + #[codec(index = 17)] + FailedToDecode, + /// Used by `Transact` to indicate that the given weight limit could be breached by the functor. + #[codec(index = 18)] + TooMuchWeightRequired, + /// Used by `BuyExecution` when the Holding Register does not contain payable fees. + #[codec(index = 19)] + NotHoldingFees, + /// Used by `BuyExecution` when the fees declared to purchase weight are insufficient. + #[codec(index = 20)] + TooExpensive, + /// Used by the `Trap` instruction to force an error intentionally. Its code is included. + #[codec(index = 21)] + Trap(u64), + /// Used by `ExpectAsset`, `ExpectError` and `ExpectOrigin` when the expectation was not true. + #[codec(index = 22)] + ExpectationFalse, + + // Errors that happen prior to instructions being executed. These fall outside of the XCM spec. + /// XCM version not able to be handled. + UnhandledXcmVersion, + /// Execution of the XCM would potentially result in a greater weight used than weight limit. + WeightLimitReached(Weight), + /// The XCM did not pass the barrier condition for execution. + /// + /// The barrier condition differs on different chains and in different circumstances, but + /// generally it means that the conditions surrounding the message were not such that the chain + /// considers the message worth spending time executing. Since most chains lift the barrier to + /// execution on appropriate payment, presentation of an NFT voucher, or based on the message + /// origin, it means that none of those were the case. + Barrier, + /// The weight of an XCM message is not computable ahead of execution. + WeightNotComputable, +} + +impl TryFrom for Error { + type Error = (); + fn try_from(old_error: OldError) -> result::Result { + use OldError::*; + Ok(match old_error { + Overflow => Self::Overflow, + Unimplemented => Self::Unimplemented, + UntrustedReserveLocation => Self::UntrustedReserveLocation, + UntrustedTeleportLocation => Self::UntrustedTeleportLocation, + MultiLocationFull => Self::MultiLocationFull, + MultiLocationNotInvertible => Self::MultiLocationNotInvertible, + BadOrigin => Self::BadOrigin, + InvalidLocation => Self::InvalidLocation, + AssetNotFound => Self::AssetNotFound, + FailedToTransactAsset(s) => Self::FailedToTransactAsset(s), + NotWithdrawable => Self::NotWithdrawable, + LocationCannotHold => Self::LocationCannotHold, + ExceedsMaxMessageSize => Self::ExceedsMaxMessageSize, + DestinationUnsupported => Self::DestinationUnsupported, + Transport(s) => Self::Transport(s), + Unroutable => Self::Unroutable, + UnknownClaim => Self::UnknownClaim, + FailedToDecode => Self::FailedToDecode, + TooMuchWeightRequired => Self::TooMuchWeightRequired, + NotHoldingFees => Self::NotHoldingFees, + TooExpensive => Self::TooExpensive, + Trap(i) => Self::Trap(i), + _ => return Err(()), + }) + } +} + +impl From for Error { + fn from(e: SendError) -> Self { + match e { + SendError::CannotReachDestination(..) | SendError::Unroutable => Error::Unroutable, + SendError::Transport(s) => Error::Transport(s), + SendError::DestinationUnsupported => Error::DestinationUnsupported, + SendError::ExceedsMaxMessageSize => Error::ExceedsMaxMessageSize, + } + } +} + +pub type Result = result::Result<(), Error>; + +/// Local weight type; execution time in picoseconds. +pub type Weight = u64; + +/// Outcome of an XCM execution. +#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] +pub enum Outcome { + /// Execution completed successfully; given weight was used. + Complete(Weight), + /// Execution started, but did not complete successfully due to the given error; given weight was used. + Incomplete(Weight, Error), + /// Execution did not start due to the given error. + Error(Error), +} + +impl Outcome { + pub fn ensure_complete(self) -> Result { + match self { + Outcome::Complete(_) => Ok(()), + Outcome::Incomplete(_, e) => Err(e), + Outcome::Error(e) => Err(e), + } + } + pub fn ensure_execution(self) -> result::Result { + match self { + Outcome::Complete(w) => Ok(w), + Outcome::Incomplete(w, _) => Ok(w), + Outcome::Error(e) => Err(e), + } + } + /// How much weight was used by the XCM execution attempt. + pub fn weight_used(&self) -> Weight { + match self { + Outcome::Complete(w) => *w, + Outcome::Incomplete(w, _) => *w, + Outcome::Error(_) => 0, + } + } +} + +/// Type of XCM message executor. +pub trait ExecuteXcm { + /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is + /// a basic hard-limit and the implementation may place further restrictions or requirements on weight and + /// other aspects. + fn execute_xcm( + origin: impl Into, + message: Xcm, + weight_limit: Weight, + ) -> Outcome { + let origin = origin.into(); + log::debug!( + target: "xcm::execute_xcm", + "origin: {:?}, message: {:?}, weight_limit: {:?}", + origin, + message, + weight_limit, + ); + Self::execute_xcm_in_credit(origin, message, weight_limit, 0) + } + + /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. + /// + /// Some amount of `weight_credit` may be provided which, depending on the implementation, may allow + /// execution without associated payment. + fn execute_xcm_in_credit( + origin: impl Into, + message: Xcm, + weight_limit: Weight, + weight_credit: Weight, + ) -> Outcome; +} + +impl ExecuteXcm for () { + fn execute_xcm_in_credit( + _origin: impl Into, + _message: Xcm, + _weight_limit: Weight, + _weight_credit: Weight, + ) -> Outcome { + Outcome::Error(Error::Unimplemented) + } +} + +/// Error result value when attempting to send an XCM message. +#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, scale_info::TypeInfo)] +pub enum SendError { + /// The message and destination combination was not recognized as being reachable. + /// + /// This is not considered fatal: if there are alternative transport routes available, then + /// they may be attempted. For this reason, the destination and message are contained. + CannotReachDestination(MultiLocation, Xcm<()>), + /// Destination is routable, but there is some issue with the transport mechanism. This is + /// considered fatal. + /// A human-readable explanation of the specific issue is provided. + Transport(#[codec(skip)] &'static str), + /// Destination is known to be unroutable. This is considered fatal. + Unroutable, + /// The given message cannot be translated into a format that the destination can be expected + /// to interpret. + DestinationUnsupported, + /// Message could not be sent due to its size exceeding the maximum allowed by the transport + /// layer. + ExceedsMaxMessageSize, +} + +/// Result value when attempting to send an XCM message. +pub type SendResult = result::Result<(), SendError>; + +/// Utility for sending an XCM message. +/// +/// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each router might return +/// `CannotReachDestination` to pass the execution to the next sender item. Note that each `CannotReachDestination` +/// might alter the destination and the XCM message for to the next router. +/// +/// +/// # Example +/// ```rust +/// # use xcm::v2::prelude::*; +/// # use parity_scale_codec::Encode; +/// +/// /// A sender that only passes the message through and does nothing. +/// struct Sender1; +/// impl SendXcm for Sender1 { +/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { +/// return Err(SendError::CannotReachDestination(destination.into(), message)) +/// } +/// } +/// +/// /// A sender that accepts a message that has an X2 junction, otherwise stops the routing. +/// struct Sender2; +/// impl SendXcm for Sender2 { +/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { +/// if let MultiLocation { parents: 0, interior: X2(j1, j2) } = destination.into() { +/// Ok(()) +/// } else { +/// Err(SendError::Unroutable) +/// } +/// } +/// } +/// +/// /// A sender that accepts a message from a parent, passing through otherwise. +/// struct Sender3; +/// impl SendXcm for Sender3 { +/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { +/// let destination = destination.into(); +/// match destination { +/// MultiLocation { parents: 1, interior: Here } => Ok(()), +/// _ => Err(SendError::CannotReachDestination(destination, message)), +/// } +/// } +/// } +/// +/// // A call to send via XCM. We don't really care about this. +/// # fn main() { +/// let call: Vec = ().encode(); +/// let message = Xcm(vec![Instruction::Transact { +/// origin_type: OriginKind::Superuser, +/// require_weight_at_most: 0, +/// call: call.into(), +/// }]); +/// +/// assert!( +/// // Sender2 will block this. +/// <(Sender1, Sender2, Sender3) as SendXcm>::send_xcm(Parent, message.clone()) +/// .is_err() +/// ); +/// +/// assert!( +/// // Sender3 will catch this. +/// <(Sender1, Sender3) as SendXcm>::send_xcm(Parent, message.clone()) +/// .is_ok() +/// ); +/// # } +/// ``` +pub trait SendXcm { + /// Send an XCM `message` to a given `destination`. + /// + /// If it is not a destination which can be reached with this type but possibly could by others, then it *MUST* + /// return `CannotReachDestination`. Any other error will cause the tuple implementation to exit early without + /// trying other type fields. + fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult; +} + +#[impl_trait_for_tuples::impl_for_tuples(30)] +impl SendXcm for Tuple { + fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { + for_tuples!( #( + // we shadow `destination` and `message` in each expansion for the next one. + let (destination, message) = match Tuple::send_xcm(destination, message) { + Err(SendError::CannotReachDestination(d, m)) => (d, m), + o @ _ => return o, + }; + )* ); + Err(SendError::CannotReachDestination(destination.into(), message)) + } +} + +/// The info needed to weigh an XCM. +// TODO: Automate Generation +pub trait XcmWeightInfo { + fn withdraw_asset(assets: &MultiAssets) -> Weight; + fn reserve_asset_deposited(assets: &MultiAssets) -> Weight; + fn receive_teleported_asset(assets: &MultiAssets) -> Weight; + fn query_response(query_id: &u64, response: &Response, max_weight: &u64) -> Weight; + fn transfer_asset(assets: &MultiAssets, beneficiary: &MultiLocation) -> Weight; + fn transfer_reserve_asset(assets: &MultiAssets, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight; + fn transact( + origin_type: &OriginKind, + require_weight_at_most: &u64, + call: &DoubleEncoded, + ) -> Weight; + fn hrmp_new_channel_open_request( + sender: &u32, + max_message_size: &u32, + max_capacity: &u32, + ) -> Weight; + fn hrmp_channel_accepted(recipient: &u32) -> Weight; + fn hrmp_channel_closing(initiator: &u32, sender: &u32, recipient: &u32) -> Weight; + fn clear_origin() -> Weight; + fn descend_origin(who: &InteriorMultiLocation) -> Weight; + fn report_error(query_id: &QueryId, dest: &MultiLocation, max_response_weight: &u64) -> Weight; + fn relayed_from(who: &Junctions, message: &alloc::boxed::Box>) -> Weight; + fn deposit_asset( + assets: &MultiAssetFilter, + max_assets: &u32, + beneficiary: &MultiLocation, + ) -> Weight; + fn deposit_reserve_asset( + assets: &MultiAssetFilter, + max_assets: &u32, + dest: &MultiLocation, + xcm: &Xcm<()>, + ) -> Weight; + fn exchange_asset(give: &MultiAssetFilter, receive: &MultiAssets) -> Weight; + fn initiate_reserve_withdraw( + assets: &MultiAssetFilter, + reserve: &MultiLocation, + xcm: &Xcm<()>, + ) -> Weight; + fn initiate_teleport(assets: &MultiAssetFilter, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight; + fn query_holding( + query_id: &u64, + dest: &MultiLocation, + assets: &MultiAssetFilter, + max_response_weight: &u64, + ) -> Weight; + fn buy_execution(fees: &MultiAsset, weight_limit: &WeightLimit) -> Weight; + fn refund_surplus() -> Weight; + fn set_error_handler(xcm: &Xcm) -> Weight; + fn set_appendix(xcm: &Xcm) -> Weight; + fn clear_error() -> Weight; + fn claim_asset(assets: &MultiAssets, ticket: &MultiLocation) -> Weight; + fn trap(code: &u64) -> Weight; + fn subscribe_version(query_id: &QueryId, max_response_weight: &u64) -> Weight; + fn unsubscribe_version() -> Weight; + fn burn_asset(_assets: &MultiAssets) -> Weight { 0 } + fn expect_asset(_assets: &MultiAssets) -> Weight { 0 } + fn expect_origin(_origin: &MultiLocation) -> Weight { 0 } + fn expect_error(_error: &Option<(u32, Error)>) -> Weight { 0 } +} From 3caf55a1fc1d8e4444f2c1001c5cf2fc21c82945 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 17 Oct 2021 22:48:35 +0200 Subject: [PATCH 003/231] Formatting --- xcm/src/v2/mod.rs | 20 ++++++++++---------- xcm/src/v2/traits.rs | 2 +- xcm/src/v3/mod.rs | 29 ++++++++++++++--------------- xcm/src/v3/traits.rs | 18 +++++++++++++----- xcm/xcm-executor/src/lib.rs | 5 ++--- 5 files changed, 40 insertions(+), 34 deletions(-) diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index 6cbfec9d5e0d..b8c88a9f7608 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -16,8 +16,10 @@ //! Version 1 of the Cross-Consensus Message format data structures. -use super::v1::{Order as OldOrder, Response as OldResponse, Xcm as OldXcm}; -use super::v3::{Instruction as NewInstruction, Response as NewResponse, Xcm as NewXcm}; +use super::{ + v1::{Order as OldOrder, Response as OldResponse, Xcm as OldXcm}, + v3::{Instruction as NewInstruction, Response as NewResponse, Xcm as NewXcm}, +}; use crate::{DoubleEncoded, GetWeight}; use alloc::{vec, vec::Vec}; use core::{ @@ -391,7 +393,7 @@ pub enum Instruction { /// /// A `QueryResponse` message of type `ExecutionOutcome` is sent to `dest` with the given /// `query_id` and the outcome of the XCM. - /// + /// /// - `query_id`: An identifier that will be replicated into the returned XCM message. /// - `dest`: A valid destination for the returned XCM message. /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which @@ -608,7 +610,7 @@ pub enum Instruction { /// Ask the destination system to respond with the most recent version of XCM that they /// support in a `QueryResponse` instruction. Any changes to this should also elicit similar /// responses when they happen. - /// + /// /// - `query_id`: An identifier that will be replicated into the returned XCM message. /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the @@ -767,12 +769,10 @@ impl TryFrom for Response { match response { NewResponse::Assets(assets) => Ok(Self::Assets(assets)), NewResponse::Version(version) => Ok(Self::Version(version)), - NewResponse::ExecutionResult(error) => { - Ok(Self::ExecutionResult(match error { - Some((i, e)) => Some((i, e.try_into()?)), - None => None, - })) - }, + NewResponse::ExecutionResult(error) => Ok(Self::ExecutionResult(match error { + Some((i, e)) => Some((i, e.try_into()?)), + None => None, + })), NewResponse::Null => Ok(Self::Null), } } diff --git a/xcm/src/v2/traits.rs b/xcm/src/v2/traits.rs index 79410f06838f..a56667310681 100644 --- a/xcm/src/v2/traits.rs +++ b/xcm/src/v2/traits.rs @@ -16,10 +16,10 @@ //! Cross-Consensus Message format data structures. +use crate::v3::Error as NewError; use core::result; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -use crate::v3::Error as NewError; use super::*; diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index dc5de519d3a4..decd9e3066e5 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -37,8 +37,8 @@ pub use traits::{ pub use super::v2::{ Ancestor, AncestorThen, AssetId, AssetInstance, BodyId, BodyPart, Fungibility, InteriorMultiLocation, Junction, Junctions, MultiAsset, MultiAssetFilter, MultiAssets, - MultiLocation, NetworkId, OriginKind, Parent, ParentThen, WildFungibility, WildMultiAsset, - WeightLimit, + MultiLocation, NetworkId, OriginKind, Parent, ParentThen, WeightLimit, WildFungibility, + WildMultiAsset, }; /// This module's XCM version. @@ -364,7 +364,7 @@ pub enum Instruction { /// /// A `QueryResponse` message of type `ExecutionOutcome` is sent to `dest` with the given /// `query_id` and the outcome of the XCM. - /// + /// /// - `query_id`: An identifier that will be replicated into the returned XCM message. /// - `dest`: A valid destination for the returned XCM message. /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which @@ -581,7 +581,7 @@ pub enum Instruction { /// Ask the destination system to respond with the most recent version of XCM that they /// support in a `QueryResponse` instruction. Any changes to this should also elicit similar /// responses when they happen. - /// + /// /// - `query_id`: An identifier that will be replicated into the returned XCM message. /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the @@ -606,8 +606,8 @@ pub enum Instruction { /// Reduce Holding by up to the given assets. /// - /// Holding is reduced by up to the assets in the parameter. If this is less than the - /// + /// Holding is reduced by up to the assets in the parameter. If this is less than the + /// /// Kind: *Instruction* /// /// Errors: *Fallible* @@ -771,12 +771,10 @@ impl TryFrom for Response { match old_response { OldResponse::Assets(assets) => Ok(Self::Assets(assets)), OldResponse::Version(version) => Ok(Self::Version(version)), - OldResponse::ExecutionResult(error) => { - Ok(Self::ExecutionResult(match error { - Some((i, e)) => Some((i, e.try_into()?)), - None => None, - })) - }, + OldResponse::ExecutionResult(error) => Ok(Self::ExecutionResult(match error { + Some((i, e)) => Some((i, e.try_into()?)), + None => None, + })), OldResponse::Null => Ok(Self::Null), } } @@ -848,9 +846,10 @@ mod tests { fn basic_roundtrip_works() { let xcm = Xcm::<()>(vec![TransferAsset { assets: (Here, 1).into(), beneficiary: Here.into() }]); - let old_xcm = OldXcm::<()>(vec![ - OldInstruction::TransferAsset { assets: (Here, 1).into(), beneficiary: Here.into() } - ]); + let old_xcm = OldXcm::<()>(vec![OldInstruction::TransferAsset { + assets: (Here, 1).into(), + beneficiary: Here.into(), + }]); assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); assert_eq!(new_xcm, xcm); diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 230cfa2085bf..8fb19e718c49 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -16,10 +16,10 @@ //! Cross-Consensus Message format data structures. +use crate::v2::Error as OldError; use core::result; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -use crate::v2::Error as OldError; use super::*; @@ -414,8 +414,16 @@ pub trait XcmWeightInfo { fn trap(code: &u64) -> Weight; fn subscribe_version(query_id: &QueryId, max_response_weight: &u64) -> Weight; fn unsubscribe_version() -> Weight; - fn burn_asset(_assets: &MultiAssets) -> Weight { 0 } - fn expect_asset(_assets: &MultiAssets) -> Weight { 0 } - fn expect_origin(_origin: &MultiLocation) -> Weight { 0 } - fn expect_error(_error: &Option<(u32, Error)>) -> Weight { 0 } + fn burn_asset(_assets: &MultiAssets) -> Weight { + 0 + } + fn expect_asset(_assets: &MultiAssets) -> Weight { + 0 + } + fn expect_origin(_origin: &MultiLocation) -> Weight { + 0 + } + fn expect_error(_error: &Option<(u32, Error)>) -> Weight { + 0 + } } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index fbeca92a2107..ed4e5c4dcc94 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -455,9 +455,8 @@ impl XcmExecutor { self.holding.saturating_take(assets.into()); Ok(()) }, - ExpectAsset(assets) => { - self.holding.ensure_contains(&assets).map_err(|_| XcmError::ExpectationFalse) - }, + ExpectAsset(assets) => + self.holding.ensure_contains(&assets).map_err(|_| XcmError::ExpectationFalse), ExpectOrigin(origin) => { let origin_ref = self.origin.as_ref().ok_or(XcmError::ExpectationFalse)?; ensure!(origin_ref == &origin, XcmError::ExpectationFalse); From 0a536b1707f0448363ba58df5e93093274b4902d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 18 Oct 2021 19:25:22 +0200 Subject: [PATCH 004/231] Safe dispatches --- Cargo.lock | 381 +++++++++++++++++------------- Cargo.toml | 217 +++++++++++++++++ xcm/src/v2/mod.rs | 1 + xcm/src/v3/mod.rs | 132 ++++++++++- xcm/src/v3/traits.rs | 22 ++ xcm/xcm-builder/tests/mock/mod.rs | 1 + xcm/xcm-executor/src/config.rs | 10 +- xcm/xcm-executor/src/lib.rs | 85 ++++++- 8 files changed, 675 insertions(+), 174 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d5f70c9a736..767f8662cba5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -467,7 +467,6 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "beefy-primitives", "fnv", @@ -495,7 +494,6 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -515,12 +513,10 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "scale-info", @@ -1910,7 +1906,6 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", ] @@ -1928,7 +1923,6 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -1948,7 +1942,6 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "Inflector", "chrono", @@ -1974,7 +1967,6 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -1988,7 +1980,6 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -2016,7 +2007,6 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "bitflags", "frame-metadata", @@ -2043,7 +2033,6 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2055,7 +2044,6 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.0", @@ -2067,7 +2055,6 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "proc-macro2", "quote", @@ -2077,7 +2064,6 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2100,7 +2086,6 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -2111,7 +2096,6 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "log", @@ -2128,7 +2112,6 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -2143,7 +2126,6 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "sp-api", @@ -2152,7 +2134,6 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "sp-api", @@ -2365,7 +2346,6 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generate-bags" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "chrono", "frame-election-provider-support", @@ -4606,7 +4586,6 @@ checksum = "13370dae44474229701bb69b90b4f4dca6404cb0357a2d50d635f1171dc3aa7b" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4620,7 +4599,6 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -4636,7 +4614,6 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -4651,7 +4628,6 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4675,7 +4651,6 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4695,7 +4670,6 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4710,7 +4684,6 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "beefy-primitives", "frame-support", @@ -4726,7 +4699,6 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -4751,7 +4723,6 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4836,7 +4807,6 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4853,7 +4823,6 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4869,7 +4838,6 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4893,7 +4861,6 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4911,7 +4878,6 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4926,7 +4892,6 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4949,7 +4914,6 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "enumflags2", "frame-benchmarking", @@ -4965,7 +4929,6 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -4985,7 +4948,6 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5002,7 +4964,6 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5019,7 +4980,6 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5037,7 +4997,6 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -5053,7 +5012,6 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5070,7 +5028,6 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5085,7 +5042,6 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -5099,7 +5055,6 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -5116,7 +5071,6 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5139,7 +5093,6 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5154,7 +5107,6 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -5168,7 +5120,6 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5184,7 +5135,6 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -5205,7 +5155,6 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5221,7 +5170,6 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -5235,7 +5183,6 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5258,7 +5205,6 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -5269,7 +5215,6 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "log", "sp-arithmetic", @@ -5278,7 +5223,6 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -5292,7 +5236,6 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5310,7 +5253,6 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5329,7 +5271,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-support", "frame-system", @@ -5346,7 +5287,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5363,7 +5303,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5374,7 +5313,6 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5391,7 +5329,6 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -5407,7 +5344,6 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-benchmarking", "frame-support", @@ -7778,7 +7714,6 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "env_logger 0.9.0", "jsonrpsee-proc-macros", @@ -8041,7 +7976,6 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "log", "sp-core", @@ -8052,7 +7986,6 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "derive_more", @@ -8079,7 +8012,6 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -8102,7 +8034,6 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8118,7 +8049,6 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -8134,7 +8064,6 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -8145,7 +8074,6 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "chrono", "fdlimit", @@ -8183,7 +8111,6 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "fnv", "futures 0.3.17", @@ -8211,7 +8138,6 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "hash-db", "kvdb", @@ -8236,7 +8162,6 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "futures 0.3.17", @@ -8260,7 +8185,6 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "derive_more", @@ -8303,7 +8227,6 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "derive_more", "futures 0.3.17", @@ -8327,7 +8250,6 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8340,7 +8262,6 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "assert_matches", "async-trait", @@ -8374,7 +8295,6 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "futures 0.3.17", @@ -8400,7 +8320,6 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "sc-client-api", "sp-authorship", @@ -8411,7 +8330,6 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "lazy_static", "libsecp256k1 0.6.0", @@ -8437,7 +8355,6 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "derive_more", "environmental", @@ -8455,7 +8372,6 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "log", "parity-scale-codec", @@ -8471,7 +8387,6 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "cfg-if 1.0.0", "libc", @@ -8489,7 +8404,6 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "derive_more", @@ -8526,7 +8440,6 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "derive_more", "finality-grandpa", @@ -8550,7 +8463,6 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "ansi_term 0.12.1", "futures 0.3.17", @@ -8567,7 +8479,6 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "derive_more", @@ -8582,7 +8493,6 @@ dependencies = [ [[package]] name = "sc-light" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "hash-db", "parity-scale-codec", @@ -8600,7 +8510,6 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-std", "async-trait", @@ -8651,7 +8560,6 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -8667,7 +8575,6 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "bytes 1.0.1", "fnv", @@ -8694,7 +8601,6 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "libp2p", @@ -8707,7 +8613,6 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8716,7 +8621,6 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "hash-db", @@ -8747,7 +8651,6 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "jsonrpc-core", @@ -8772,7 +8675,6 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "jsonrpc-core", @@ -8789,7 +8691,6 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "directories", @@ -8854,7 +8755,6 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "log", "parity-scale-codec", @@ -8868,7 +8768,6 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -8890,7 +8789,6 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "chrono", "futures 0.3.17", @@ -8908,7 +8806,6 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "ansi_term 0.12.1", "atty", @@ -8938,7 +8835,6 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -8949,7 +8845,6 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "intervalier", @@ -8976,7 +8871,6 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "derive_more", "futures 0.3.17", @@ -8990,7 +8884,6 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -9413,7 +9306,6 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "hash-db", "log", @@ -9430,7 +9322,6 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "blake2-rfc", "proc-macro-crate 1.1.0", @@ -9442,7 +9333,6 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "scale-info", @@ -9455,7 +9345,6 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "integer-sqrt", "num-traits", @@ -9470,7 +9359,6 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "scale-info", @@ -9483,7 +9371,6 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "parity-scale-codec", @@ -9495,7 +9382,6 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "sp-api", @@ -9507,7 +9393,6 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "log", @@ -9525,7 +9410,6 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "futures 0.3.17", @@ -9544,7 +9428,6 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "merlin", @@ -9567,7 +9450,6 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "scale-info", @@ -9578,7 +9460,6 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -9590,7 +9471,6 @@ dependencies = [ [[package]] name = "sp-core" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "base58", "blake2-rfc", @@ -9636,7 +9516,6 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "kvdb", "parking_lot", @@ -9645,7 +9524,6 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "proc-macro2", "quote", @@ -9655,7 +9533,6 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "environmental", "parity-scale-codec", @@ -9666,7 +9543,6 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "finality-grandpa", "log", @@ -9684,7 +9560,6 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -9698,7 +9573,6 @@ dependencies = [ [[package]] name = "sp-io" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "hash-db", @@ -9722,7 +9596,6 @@ dependencies = [ [[package]] name = "sp-keyring" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "lazy_static", "sp-core", @@ -9733,7 +9606,6 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "derive_more", @@ -9750,7 +9622,6 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "zstd", ] @@ -9758,7 +9629,6 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "scale-info", @@ -9773,7 +9643,6 @@ dependencies = [ [[package]] name = "sp-npos-elections-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -9784,7 +9653,6 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "sp-api", "sp-core", @@ -9794,7 +9662,6 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "backtrace", ] @@ -9802,7 +9669,6 @@ dependencies = [ [[package]] name = "sp-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "rustc-hash", "serde", @@ -9812,7 +9678,6 @@ dependencies = [ [[package]] name = "sp-runtime" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "either", "hash256-std-hasher", @@ -9834,7 +9699,6 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -9851,7 +9715,6 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "Inflector", "proc-macro-crate 1.1.0", @@ -9863,7 +9726,6 @@ dependencies = [ [[package]] name = "sp-serializer" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "serde", "serde_json", @@ -9872,7 +9734,6 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "scale-info", @@ -9886,7 +9747,6 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "scale-info", @@ -9897,7 +9757,6 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "hash-db", "log", @@ -9920,12 +9779,10 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" [[package]] name = "sp-storage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9938,7 +9795,6 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "log", "sp-core", @@ -9951,7 +9807,6 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "futures-timer 3.0.2", @@ -9967,7 +9822,6 @@ dependencies = [ [[package]] name = "sp-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "sp-std", @@ -9979,7 +9833,6 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "sp-api", "sp-runtime", @@ -9988,7 +9841,6 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "log", @@ -10004,7 +9856,6 @@ dependencies = [ [[package]] name = "sp-trie" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "hash-db", "memory-db", @@ -10019,7 +9870,6 @@ dependencies = [ [[package]] name = "sp-version" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10035,7 +9885,6 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10046,7 +9895,6 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10274,7 +10122,6 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "platforms", ] @@ -10282,7 +10129,6 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.17", @@ -10304,7 +10150,6 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-std", "derive_more", @@ -10318,7 +10163,6 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "async-trait", "futures 0.3.17", @@ -10345,7 +10189,6 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "futures 0.3.17", "substrate-test-utils-derive", @@ -10355,7 +10198,6 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -10366,7 +10208,6 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "ansi_term 0.12.1", "build-helper", @@ -10519,7 +10360,6 @@ dependencies = [ [[package]] name = "test-runner" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "frame-system", "futures 0.3.17", @@ -10960,7 +10800,6 @@ checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#afd572f208b25312f984987b7bb752e71fbf86d7" dependencies = [ "jsonrpsee-ws-client", "log", @@ -11938,3 +11777,223 @@ dependencies = [ "cc", "libc", ] + +[[patch.unused]] +name = "chain-spec-builder" +version = "2.0.0" + +[[patch.unused]] +name = "node-bench" +version = "0.9.0-dev" + +[[patch.unused]] +name = "node-cli" +version = "3.0.0-dev" + +[[patch.unused]] +name = "node-executor" +version = "3.0.0-dev" + +[[patch.unused]] +name = "node-inspect" +version = "0.9.0-dev" + +[[patch.unused]] +name = "node-primitives" +version = "2.0.0" + +[[patch.unused]] +name = "node-rpc" +version = "3.0.0-dev" + +[[patch.unused]] +name = "node-rpc-client" +version = "2.0.0" + +[[patch.unused]] +name = "node-runtime" +version = "3.0.0-dev" + +[[patch.unused]] +name = "node-runtime-generate-bags" +version = "3.0.0" + +[[patch.unused]] +name = "node-template" +version = "3.0.0" + +[[patch.unused]] +name = "node-template-runtime" +version = "3.0.0" + +[[patch.unused]] +name = "node-testing" +version = "3.0.0-dev" + +[[patch.unused]] +name = "pallet-atomic-swap" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-aura" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-contracts" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-contracts-primitives" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-contracts-proc-macro" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-contracts-rpc" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-contracts-rpc-runtime-api" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-elections" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-example" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-example-offchain-worker" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-example-parallel" +version = "3.0.0-dev" + +[[patch.unused]] +name = "pallet-lottery" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-node-authorization" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-randomness-collective-flip" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-scored-pool" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-template" +version = "3.0.0" + +[[patch.unused]] +name = "pallet-transaction-storage" +version = "4.0.0-dev" + +[[patch.unused]] +name = "pallet-uniques" +version = "4.0.0-dev" + +[[patch.unused]] +name = "sc-consensus-aura" +version = "0.10.0-dev" + +[[patch.unused]] +name = "sc-consensus-pow" +version = "0.10.0-dev" + +[[patch.unused]] +name = "sc-network-test" +version = "0.8.0" + +[[patch.unused]] +name = "sc-runtime-test" +version = "2.0.0" + +[[patch.unused]] +name = "sc-service-test" +version = "2.0.0" + +[[patch.unused]] +name = "sp-api-test" +version = "2.0.1" + +[[patch.unused]] +name = "sp-application-crypto-test" +version = "2.0.0" + +[[patch.unused]] +name = "sp-arithmetic-fuzzer" +version = "2.0.0" + +[[patch.unused]] +name = "sp-consensus-aura" +version = "0.10.0-dev" + +[[patch.unused]] +name = "sp-consensus-pow" +version = "0.10.0-dev" + +[[patch.unused]] +name = "sp-npos-elections-fuzzer" +version = "2.0.0-alpha.5" + +[[patch.unused]] +name = "sp-runtime-interface-test" +version = "2.0.0" + +[[patch.unused]] +name = "sp-runtime-interface-test-wasm" +version = "2.0.0" + +[[patch.unused]] +name = "sp-runtime-interface-test-wasm-deprecated" +version = "2.0.0" + +[[patch.unused]] +name = "sp-sandbox" +version = "0.10.0-dev" + +[[patch.unused]] +name = "sp-test-primitives" +version = "2.0.0" + +[[patch.unused]] +name = "subkey" +version = "2.0.1" + +[[patch.unused]] +name = "substrate-frame-cli" +version = "4.0.0-dev" + +[[patch.unused]] +name = "substrate-frame-rpc-support" +version = "3.0.0" + +[[patch.unused]] +name = "substrate-test-runtime" +version = "2.0.0" + +[[patch.unused]] +name = "substrate-test-runtime-client" +version = "2.0.0" + +[[patch.unused]] +name = "substrate-test-runtime-transaction-pool" +version = "2.0.0" + +[[patch.unused]] +name = "substrate-test-utils-test-crate" +version = "0.1.0" + +[[patch.unused]] +name = "test-runner-example" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 8ab176c69b13..4930ad1791ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -117,6 +117,223 @@ panic = "unwind" runtime-benchmarks= [ "polkadot-cli/runtime-benchmarks" ] try-runtime = [ "polkadot-cli/try-runtime" ] disputes = [ "polkadot-cli/disputes" ] +[patch."https://github.com/paritytech/substrate"] +node-template ={path = "/Users/gav/Core/substrate/bin/node-template/node" } +frame-benchmarking ={path = "/Users/gav/Core/substrate/frame/benchmarking" } +frame-support ={path = "/Users/gav/Core/substrate/frame/support" } +frame-support-procedural ={path = "/Users/gav/Core/substrate/frame/support/procedural" } +frame-support-procedural-tools ={path = "/Users/gav/Core/substrate/frame/support/procedural/tools" } +frame-support-procedural-tools-derive ={path = "/Users/gav/Core/substrate/frame/support/procedural/tools/derive" } +sp-arithmetic ={path = "/Users/gav/Core/substrate/primitives/arithmetic" } +sp-debug-derive ={path = "/Users/gav/Core/substrate/primitives/debug-derive" } +sp-std ={path = "/Users/gav/Core/substrate/primitives/std" } +sp-core ={path = "/Users/gav/Core/substrate/primitives/core" } +sp-externalities ={path = "/Users/gav/Core/substrate/primitives/externalities" } +sp-storage ={path = "/Users/gav/Core/substrate/primitives/storage" } +sp-runtime-interface ={path = "/Users/gav/Core/substrate/primitives/runtime-interface" } +sp-runtime-interface-proc-macro ={path = "/Users/gav/Core/substrate/primitives/runtime-interface/proc-macro" } +sp-tracing ={path = "/Users/gav/Core/substrate/primitives/tracing" } +sp-wasm-interface ={path = "/Users/gav/Core/substrate/primitives/wasm-interface" } +sp-io ={path = "/Users/gav/Core/substrate/primitives/io" } +sp-keystore ={path = "/Users/gav/Core/substrate/primitives/keystore" } +sp-state-machine ={path = "/Users/gav/Core/substrate/primitives/state-machine" } +sp-panic-handler ={path = "/Users/gav/Core/substrate/primitives/panic-handler" } +sp-trie ={path = "/Users/gav/Core/substrate/primitives/trie" } +sp-runtime ={path = "/Users/gav/Core/substrate/primitives/runtime" } +sp-application-crypto ={path = "/Users/gav/Core/substrate/primitives/application-crypto" } +sp-api ={path = "/Users/gav/Core/substrate/primitives/api" } +sp-api-proc-macro ={path = "/Users/gav/Core/substrate/primitives/api/proc-macro" } +sp-version ={path = "/Users/gav/Core/substrate/primitives/version" } +sp-version-proc-macro ={path = "/Users/gav/Core/substrate/primitives/version/proc-macro" } +sp-test-primitives ={path = "/Users/gav/Core/substrate/primitives/test-primitives" } +substrate-test-runtime-client ={path = "/Users/gav/Core/substrate/test-utils/runtime/client" } +sc-block-builder ={path = "/Users/gav/Core/substrate/client/block-builder" } +sc-client-api ={path = "/Users/gav/Core/substrate/client/api" } +substrate-prometheus-endpoint ={path = "/Users/gav/Core/substrate/utils/prometheus" } +sc-executor ={path = "/Users/gav/Core/substrate/client/executor" } +sc-executor-common ={path = "/Users/gav/Core/substrate/client/executor/common" } +sc-allocator ={path = "/Users/gav/Core/substrate/client/allocator" } +sp-maybe-compressed-blob ={path = "/Users/gav/Core/substrate/primitives/maybe-compressed-blob" } +sp-serializer ={path = "/Users/gav/Core/substrate/primitives/serializer" } +sc-executor-wasmi ={path = "/Users/gav/Core/substrate/client/executor/wasmi" } +sc-executor-wasmtime ={path = "/Users/gav/Core/substrate/client/executor/wasmtime" } +sc-runtime-test ={path = "/Users/gav/Core/substrate/client/executor/runtime-test" } +sp-sandbox ={path = "/Users/gav/Core/substrate/primitives/sandbox" } +sp-tasks ={path = "/Users/gav/Core/substrate/primitives/tasks" } +substrate-wasm-builder ={path = "/Users/gav/Core/substrate/utils/wasm-builder" } +sc-tracing ={path = "/Users/gav/Core/substrate/client/tracing" } +sc-rpc-server ={path = "/Users/gav/Core/substrate/client/rpc-servers" } +sc-tracing-proc-macro ={path = "/Users/gav/Core/substrate/client/tracing/proc-macro" } +sp-blockchain ={path = "/Users/gav/Core/substrate/primitives/blockchain" } +sp-consensus ={path = "/Users/gav/Core/substrate/primitives/consensus/common" } +sp-inherents ={path = "/Users/gav/Core/substrate/primitives/inherents" } +sp-database ={path = "/Users/gav/Core/substrate/primitives/database" } +sp-rpc ={path = "/Users/gav/Core/substrate/primitives/rpc" } +substrate-test-runtime ={path = "/Users/gav/Core/substrate/test-utils/runtime" } +frame-system ={path = "/Users/gav/Core/substrate/frame/system" } +frame-system-rpc-runtime-api ={path = "/Users/gav/Core/substrate/frame/system/rpc/runtime-api" } +pallet-babe ={path = "/Users/gav/Core/substrate/frame/babe" } +pallet-authorship ={path = "/Users/gav/Core/substrate/frame/authorship" } +sp-authorship ={path = "/Users/gav/Core/substrate/primitives/authorship" } +pallet-session ={path = "/Users/gav/Core/substrate/frame/session" } +pallet-timestamp ={path = "/Users/gav/Core/substrate/frame/timestamp" } +sp-timestamp ={path = "/Users/gav/Core/substrate/primitives/timestamp" } +sp-session ={path = "/Users/gav/Core/substrate/primitives/session" } +sp-staking ={path = "/Users/gav/Core/substrate/primitives/staking" } +sp-consensus-babe ={path = "/Users/gav/Core/substrate/primitives/consensus/babe" } +sp-consensus-slots ={path = "/Users/gav/Core/substrate/primitives/consensus/slots" } +sp-consensus-vrf ={path = "/Users/gav/Core/substrate/primitives/consensus/vrf" } +frame-election-provider-support ={path = "/Users/gav/Core/substrate/frame/election-provider-support" } +sp-npos-elections ={path = "/Users/gav/Core/substrate/primitives/npos-elections" } +sp-npos-elections-solution-type ={path = "/Users/gav/Core/substrate/primitives/npos-elections/solution-type" } +substrate-test-utils ={path = "/Users/gav/Core/substrate/test-utils" } +substrate-test-utils-derive ={path = "/Users/gav/Core/substrate/test-utils/derive" } +sc-service ={path = "/Users/gav/Core/substrate/client/service" } +sc-chain-spec ={path = "/Users/gav/Core/substrate/client/chain-spec" } +sc-chain-spec-derive ={path = "/Users/gav/Core/substrate/client/chain-spec/derive" } +sc-network ={path = "/Users/gav/Core/substrate/client/network" } +fork-tree ={path = "/Users/gav/Core/substrate/utils/fork-tree" } +sc-consensus ={path = "/Users/gav/Core/substrate/client/consensus/common" } +sc-utils ={path = "/Users/gav/Core/substrate/client/utils" } +sc-peerset ={path = "/Users/gav/Core/substrate/client/peerset" } +sp-finality-grandpa ={path = "/Users/gav/Core/substrate/primitives/finality-grandpa" } +sc-telemetry ={path = "/Users/gav/Core/substrate/client/telemetry" } +sc-client-db ={path = "/Users/gav/Core/substrate/client/db" } +sc-state-db ={path = "/Users/gav/Core/substrate/client/state-db" } +sc-informant ={path = "/Users/gav/Core/substrate/client/informant" } +sc-transaction-pool-api ={path = "/Users/gav/Core/substrate/client/transaction-pool/api" } +sc-keystore ={path = "/Users/gav/Core/substrate/client/keystore" } +sc-light ={path = "/Users/gav/Core/substrate/client/light" } +sc-offchain ={path = "/Users/gav/Core/substrate/client/offchain" } +sp-offchain ={path = "/Users/gav/Core/substrate/primitives/offchain" } +sc-transaction-pool ={path = "/Users/gav/Core/substrate/client/transaction-pool" } +sp-transaction-pool ={path = "/Users/gav/Core/substrate/primitives/transaction-pool" } +substrate-test-runtime-transaction-pool ={path = "/Users/gav/Core/substrate/test-utils/runtime/transaction-pool" } +sc-rpc ={path = "/Users/gav/Core/substrate/client/rpc" } +sc-rpc-api ={path = "/Users/gav/Core/substrate/client/rpc-api" } +sp-block-builder ={path = "/Users/gav/Core/substrate/primitives/block-builder" } +sp-transaction-storage-proof ={path = "/Users/gav/Core/substrate/primitives/transaction-storage-proof" } +pallet-balances ={path = "/Users/gav/Core/substrate/frame/balances" } +pallet-transaction-payment ={path = "/Users/gav/Core/substrate/frame/transaction-payment" } +pallet-offences ={path = "/Users/gav/Core/substrate/frame/offences" } +pallet-staking ={path = "/Users/gav/Core/substrate/frame/staking" } +pallet-bags-list ={path = "/Users/gav/Core/substrate/frame/bags-list" } +pallet-staking-reward-curve ={path = "/Users/gav/Core/substrate/frame/staking/reward-curve" } +sp-consensus-aura ={path = "/Users/gav/Core/substrate/primitives/consensus/aura" } +sp-keyring ={path = "/Users/gav/Core/substrate/primitives/keyring" } +substrate-test-client ={path = "/Users/gav/Core/substrate/test-utils/client" } +sp-runtime-interface-test-wasm ={path = "/Users/gav/Core/substrate/primitives/runtime-interface/test-wasm" } +frame-benchmarking-cli ={path = "/Users/gav/Core/substrate/utils/frame/benchmarking-cli" } +sc-cli ={path = "/Users/gav/Core/substrate/client/cli" } +node-template-runtime ={path = "/Users/gav/Core/substrate/bin/node-template/runtime" } +frame-executive ={path = "/Users/gav/Core/substrate/frame/executive" } +frame-system-benchmarking ={path = "/Users/gav/Core/substrate/frame/system/benchmarking" } +pallet-aura ={path = "/Users/gav/Core/substrate/frame/aura" } +pallet-grandpa ={path = "/Users/gav/Core/substrate/frame/grandpa" } +pallet-randomness-collective-flip ={path = "/Users/gav/Core/substrate/frame/randomness-collective-flip" } +pallet-sudo ={path = "/Users/gav/Core/substrate/frame/sudo" } +pallet-template ={path = "/Users/gav/Core/substrate/bin/node-template/pallets/template" } +pallet-transaction-payment-rpc-runtime-api ={path = "/Users/gav/Core/substrate/frame/transaction-payment/rpc/runtime-api" } +pallet-transaction-payment-rpc ={path = "/Users/gav/Core/substrate/frame/transaction-payment/rpc" } +sc-basic-authorship ={path = "/Users/gav/Core/substrate/client/basic-authorship" } +sc-proposer-metrics ={path = "/Users/gav/Core/substrate/client/proposer-metrics" } +sc-consensus-aura ={path = "/Users/gav/Core/substrate/client/consensus/aura" } +sc-consensus-slots ={path = "/Users/gav/Core/substrate/client/consensus/slots" } +sc-network-test ={path = "/Users/gav/Core/substrate/client/network/test" } +sc-finality-grandpa ={path = "/Users/gav/Core/substrate/client/finality-grandpa" } +sc-network-gossip ={path = "/Users/gav/Core/substrate/client/network-gossip" } +substrate-frame-rpc-system ={path = "/Users/gav/Core/substrate/utils/frame/rpc/system" } +substrate-build-script-utils ={path = "/Users/gav/Core/substrate/utils/build-script-utils" } +node-bench ={path = "/Users/gav/Core/substrate/bin/node/bench" } +node-primitives ={path = "/Users/gav/Core/substrate/bin/node/primitives" } +node-runtime ={path = "/Users/gav/Core/substrate/bin/node/runtime" } +frame-try-runtime ={path = "/Users/gav/Core/substrate/frame/try-runtime" } +pallet-assets ={path = "/Users/gav/Core/substrate/frame/assets" } +pallet-authority-discovery ={path = "/Users/gav/Core/substrate/frame/authority-discovery" } +sp-authority-discovery ={path = "/Users/gav/Core/substrate/primitives/authority-discovery" } +pallet-bounties ={path = "/Users/gav/Core/substrate/frame/bounties" } +pallet-treasury ={path = "/Users/gav/Core/substrate/frame/treasury" } +pallet-collective ={path = "/Users/gav/Core/substrate/frame/collective" } +pallet-contracts ={path = "/Users/gav/Core/substrate/frame/contracts" } +pallet-contracts-primitives ={path = "/Users/gav/Core/substrate/frame/contracts/common" } +pallet-contracts-proc-macro ={path = "/Users/gav/Core/substrate/frame/contracts/proc-macro" } +pallet-utility ={path = "/Users/gav/Core/substrate/frame/utility" } +pallet-contracts-rpc-runtime-api ={path = "/Users/gav/Core/substrate/frame/contracts/rpc/runtime-api" } +pallet-democracy ={path = "/Users/gav/Core/substrate/frame/democracy" } +pallet-scheduler ={path = "/Users/gav/Core/substrate/frame/scheduler" } +pallet-election-provider-multi-phase ={path = "/Users/gav/Core/substrate/frame/election-provider-multi-phase" } +pallet-elections-phragmen ={path = "/Users/gav/Core/substrate/frame/elections-phragmen" } +pallet-gilt ={path = "/Users/gav/Core/substrate/frame/gilt" } +pallet-identity ={path = "/Users/gav/Core/substrate/frame/identity" } +pallet-im-online ={path = "/Users/gav/Core/substrate/frame/im-online" } +pallet-indices ={path = "/Users/gav/Core/substrate/frame/indices" } +pallet-lottery ={path = "/Users/gav/Core/substrate/frame/lottery" } +frame-support-test ={path = "/Users/gav/Core/substrate/frame/support/test" } +frame-support-test-pallet ={path = "/Users/gav/Core/substrate/frame/support/test/pallet" } +pallet-membership ={path = "/Users/gav/Core/substrate/frame/membership" } +pallet-mmr ={path = "/Users/gav/Core/substrate/frame/merkle-mountain-range" } +pallet-mmr-primitives ={path = "/Users/gav/Core/substrate/frame/merkle-mountain-range/primitives" } +pallet-multisig ={path = "/Users/gav/Core/substrate/frame/multisig" } +pallet-offences-benchmarking ={path = "/Users/gav/Core/substrate/frame/offences/benchmarking" } +pallet-proxy ={path = "/Users/gav/Core/substrate/frame/proxy" } +pallet-recovery ={path = "/Users/gav/Core/substrate/frame/recovery" } +pallet-session-benchmarking ={path = "/Users/gav/Core/substrate/frame/session/benchmarking" } +pallet-society ={path = "/Users/gav/Core/substrate/frame/society" } +pallet-tips ={path = "/Users/gav/Core/substrate/frame/tips" } +pallet-transaction-storage ={path = "/Users/gav/Core/substrate/frame/transaction-storage" } +pallet-uniques ={path = "/Users/gav/Core/substrate/frame/uniques" } +pallet-vesting ={path = "/Users/gav/Core/substrate/frame/vesting" } +node-testing ={path = "/Users/gav/Core/substrate/bin/node/testing" } +node-executor ={path = "/Users/gav/Core/substrate/bin/node/executor" } +node-cli ={path = "/Users/gav/Core/substrate/bin/node/cli" } +node-inspect ={path = "/Users/gav/Core/substrate/bin/node/inspect" } +node-rpc ={path = "/Users/gav/Core/substrate/bin/node/rpc" } +pallet-contracts-rpc ={path = "/Users/gav/Core/substrate/frame/contracts/rpc" } +pallet-mmr-rpc ={path = "/Users/gav/Core/substrate/frame/merkle-mountain-range/rpc" } +sc-consensus-babe ={path = "/Users/gav/Core/substrate/client/consensus/babe" } +sc-consensus-epochs ={path = "/Users/gav/Core/substrate/client/consensus/epochs" } +sc-consensus-babe-rpc ={path = "/Users/gav/Core/substrate/client/consensus/babe/rpc" } +sc-finality-grandpa-rpc ={path = "/Users/gav/Core/substrate/client/finality-grandpa/rpc" } +sc-sync-state-rpc ={path = "/Users/gav/Core/substrate/client/sync-state-rpc" } +sc-authority-discovery ={path = "/Users/gav/Core/substrate/client/authority-discovery" } +sc-consensus-uncles ={path = "/Users/gav/Core/substrate/client/consensus/uncles" } +try-runtime-cli ={path = "/Users/gav/Core/substrate/utils/frame/try-runtime/cli" } +remote-externalities ={path = "/Users/gav/Core/substrate/utils/frame/remote-externalities" } +sc-service-test ={path = "/Users/gav/Core/substrate/client/service/test" } +substrate-frame-cli ={path = "/Users/gav/Core/substrate/utils/frame/frame-utilities-cli" } +test-runner-example ={path = "/Users/gav/Core/substrate/bin/node/test-runner-example" } +sc-consensus-manual-seal ={path = "/Users/gav/Core/substrate/client/consensus/manual-seal" } +test-runner ={path = "/Users/gav/Core/substrate/test-utils/test-runner" } +node-rpc-client ={path = "/Users/gav/Core/substrate/bin/node/rpc-client" } +chain-spec-builder ={path = "/Users/gav/Core/substrate/bin/utils/chain-spec-builder" } +subkey ={path = "/Users/gav/Core/substrate/bin/utils/subkey" } +beefy-gadget ={path = "/Users/gav/Core/substrate/client/beefy" } +beefy-primitives ={path = "/Users/gav/Core/substrate/primitives/beefy" } +beefy-gadget-rpc ={path = "/Users/gav/Core/substrate/client/beefy/rpc" } +sc-consensus-pow ={path = "/Users/gav/Core/substrate/client/consensus/pow" } +sp-consensus-pow ={path = "/Users/gav/Core/substrate/primitives/consensus/pow" } +pallet-atomic-swap ={path = "/Users/gav/Core/substrate/frame/atomic-swap" } +pallet-beefy ={path = "/Users/gav/Core/substrate/frame/beefy" } +pallet-beefy-mmr ={path = "/Users/gav/Core/substrate/frame/beefy-mmr" } +beefy-merkle-tree ={path = "/Users/gav/Core/substrate/frame/beefy-mmr/primitives" } +pallet-elections ={path = "/Users/gav/Core/substrate/frame/elections" } +pallet-example ={path = "/Users/gav/Core/substrate/frame/example" } +pallet-example-offchain-worker ={path = "/Users/gav/Core/substrate/frame/example-offchain-worker" } +pallet-example-parallel ={path = "/Users/gav/Core/substrate/frame/example-parallel" } +pallet-nicks ={path = "/Users/gav/Core/substrate/frame/nicks" } +pallet-node-authorization ={path = "/Users/gav/Core/substrate/frame/node-authorization" } +pallet-scored-pool ={path = "/Users/gav/Core/substrate/frame/scored-pool" } +pallet-staking-reward-fn ={path = "/Users/gav/Core/substrate/frame/staking/reward-fn" } +sp-api-test ={path = "/Users/gav/Core/substrate/primitives/api/test" } +sp-application-crypto-test ={path = "/Users/gav/Core/substrate/primitives/application-crypto/test" } +sp-arithmetic-fuzzer ={path = "/Users/gav/Core/substrate/primitives/arithmetic/fuzzer" } +sp-npos-elections-fuzzer ={path = "/Users/gav/Core/substrate/primitives/npos-elections/fuzzer" } +sp-runtime-interface-test ={path = "/Users/gav/Core/substrate/primitives/runtime-interface/test" } +sp-runtime-interface-test-wasm-deprecated ={path = "/Users/gav/Core/substrate/primitives/runtime-interface/test-wasm-deprecated" } +substrate-test-utils-test-crate ={path = "/Users/gav/Core/substrate/test-utils/test-crate" } +substrate-frame-rpc-support ={path = "/Users/gav/Core/substrate/utils/frame/rpc/support" } +generate-bags ={path = "/Users/gav/Core/substrate/utils/frame/generate-bags" } +node-runtime-generate-bags ={path = "/Users/gav/Core/substrate/utils/frame/generate-bags/node-runtime" } # Configuration for building a .deb package - for use with `cargo-deb` [package.metadata.deb] diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index b8c88a9f7608..c4643fc0becc 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -774,6 +774,7 @@ impl TryFrom for Response { None => None, })), NewResponse::Null => Ok(Self::Null), + _ => Err(()), } } } diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index decd9e3066e5..b74a4106f1e4 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -145,6 +145,22 @@ pub mod prelude { } } +#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] +pub struct PalletInfo { + #[codec(compact)] pub index: u32, + pub name: Vec, + pub module_name: Vec, + #[codec(compact)] pub major: u32, + #[codec(compact)] pub minor: u32, + #[codec(compact)] pub patch: u32, +} + +#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] +pub enum MaybeErrorCode { + Success, + Error(Vec), +} + /// Response data to a query. #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] pub enum Response { @@ -156,6 +172,10 @@ pub enum Response { ExecutionResult(Option<(u32, Error)>), /// An XCM version. Version(super::Version), + /// The index, instance name, pallet name and version of some pallets. + PalletsInfo(Vec), + /// The error of a dispatch attempt, or `None` if the dispatch executed without error. + DispatchResult(MaybeErrorCode), } impl Default for Response { @@ -164,6 +184,17 @@ impl Default for Response { } } +/// Information regarding the composition of a query response. +#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] +pub struct QueryResponseInfo { + /// The destination to which the query response message should be send. + pub destination: MultiLocation, + /// The `query_id` field of the `QueryResponse` message. + #[codec(compact)] pub query_id: QueryId, + /// The `max_weight` field of the `QueryResponse` message. + #[codec(compact)] pub max_weight: Weight, +} + /// Cross-Consensus Message: A message from one consensus system to another. /// /// Consensus systems that may send and receive messages include blockchains and smart contracts. @@ -230,7 +261,7 @@ pub enum Instruction { query_id: QueryId, response: Response, #[codec(compact)] - max_weight: u64, + max_weight: Weight, }, /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets @@ -379,7 +410,7 @@ pub enum Instruction { query_id: QueryId, dest: MultiLocation, #[codec(compact)] - max_response_weight: u64, + max_response_weight: Weight, }, /// Remove the asset(s) (`assets`) from the Holding Register and place equivalent assets under @@ -496,7 +527,7 @@ pub enum Instruction { dest: MultiLocation, assets: MultiAssetFilter, #[codec(compact)] - max_response_weight: u64, + max_response_weight: Weight, }, /// Pay for the execution of some XCM `xcm` and `orders` with up to `weight` @@ -594,7 +625,7 @@ pub enum Instruction { #[codec(compact)] query_id: QueryId, #[codec(compact)] - max_response_weight: u64, + max_response_weight: Weight, }, /// Cancel the effect of a previous `SubscribeVersion` instruction. @@ -637,6 +668,59 @@ pub enum Instruction { /// Errors: /// - `ExpectationFalse`: If the value of the Error Register is not equal to the parameter. ExpectError(Option<(u32, Error)>), + + /// Query the existence of a particular pallet type. + /// + /// - `name`: The name of the pallet to query. + /// - `response_info`: Information for making the response. + /// + /// Sends a `QueryResponse` to Origin whose data field `PalletsInfo` containing the information + /// of all pallets on the local chain whose name is equal to `name`. This is empty in the case + /// that the local chain is not based on Substrate Frame. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction* + /// + /// Errors: *Fallible*. + QueryPallet { + name: Vec, + response_info: QueryResponseInfo, + }, + + /// Dispatch a call into a pallet in the Frame system. This provides a means of ensuring that + /// the pallet continues to exist with a known version. + /// + /// - `origin_kind`: The means of expressing the message origin as a dispatch origin. + /// - `name`: The name of the pallet to which to dispatch a message. + /// - `major`, `minor`: The major and minor version of the pallet. The major version + /// must be equal and the minor version of the pallet must be at least as great. + /// - `pallet_index`: The index of the pallet to be called. + /// - `call_index`: The index of the dispatchable to be called. + /// - `params`: The encoded parameters of the dispatchable. + /// - `query_id`: If present, then a `QueryResponse` + /// whose `query_id` and `max_weight` are the given `QueryId`and `Weight` values is sent to + /// the given `MultiLocation` value with a `DispatchResult` response corresponding to the + /// error status of the "inner" dispatch. This only happens if the dispatch was actually + /// made - if an error happened prior to dispatch, then the Error Register is set and the + /// operation aborted as usual. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction* + /// + /// Errors: *Fallible*. + Dispatch { + origin_kind: OriginKind, + #[codec(compact)] require_weight_at_most: Weight, + name: Vec, + #[codec(compact)] major: u32, + #[codec(compact)] minor: u32, + #[codec(compact)] pallet_index: u32, + #[codec(compact)] call_index: u32, + params: Vec, + response_info: Option, + }, } impl Xcm { @@ -698,6 +782,29 @@ impl Instruction { ExpectAsset(assets) => ExpectAsset(assets), ExpectOrigin(origin) => ExpectOrigin(origin), ExpectError(error) => ExpectError(error), + QueryPallet { name, response_info } => + QueryPallet { name, response_info }, + Dispatch { + origin_kind, + require_weight_at_most, + name, + major, + minor, + pallet_index, + call_index, + params, + response_info, + } => Dispatch { + origin_kind, + require_weight_at_most, + name, + major, + minor, + pallet_index, + call_index, + params, + response_info, + }, } } } @@ -750,6 +857,23 @@ impl> GetWeight for Instruction { ExpectAsset(assets) => W::expect_asset(assets), ExpectOrigin(origin) => W::expect_origin(origin), ExpectError(error) => W::expect_error(error), + QueryPallet { .. } => W::query_pallet(), + Dispatch { + origin_kind, + require_weight_at_most, + pallet_index, + call_index, + params, + response_info, + .. + } => W::dispatch( + origin_kind, + require_weight_at_most, + pallet_index, + call_index, + params, + response_info, + ), } } } diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 8fb19e718c49..4d2b0453a7af 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -96,6 +96,15 @@ pub enum Error { /// Used by `ExpectAsset`, `ExpectError` and `ExpectOrigin` when the expectation was not true. #[codec(index = 22)] ExpectationFalse, + /// The provided pallet index was not found. + #[codec(index = 23)] + PalletNotFound, + /// The given pallet's name is different to that expected. + #[codec(index = 24)] + NameMismatch, + /// The given pallet's version has an incompatible version to that expected. + #[codec(index = 25)] + VersionIncompatible, // Errors that happen prior to instructions being executed. These fall outside of the XCM spec. /// XCM version not able to be handled. @@ -426,4 +435,17 @@ pub trait XcmWeightInfo { fn expect_error(_error: &Option<(u32, Error)>) -> Weight { 0 } + fn query_pallet() -> Weight { + 0 + } + fn dispatch( + _origin_kind: &OriginKind, + require_weight_at_most: &Weight, + _pallet_index: &u32, + _call_index: &u32, + _params: &Vec, + _response_info: &Option, + ) -> Weight { + *require_weight_at_most + } } diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 7bbbb8873747..82ca77788369 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -172,6 +172,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; + type AllPalletsInfo = AllPallets; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index e7d81dc8328c..46b0d048eb3a 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -18,10 +18,9 @@ use crate::traits::{ ClaimAssets, ConvertOrigin, DropAssets, FilterAssetLocation, InvertLocation, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; -use frame_support::{ - dispatch::{Dispatchable, Parameter}, - weights::{GetDispatchInfo, PostDispatchInfo}, -}; +use frame_support::dispatch::{Dispatchable, Parameter}; +use frame_support::traits::PalletInfoAccess; +use frame_support::weights::{GetDispatchInfo, PostDispatchInfo}; use xcm::latest::SendXcm; /// The trait to parameterize the `XcmExecutor`. @@ -68,4 +67,7 @@ pub trait Config { /// How we handle version subscription requests. type SubscriptionService: VersionChangeNotifier; + + /// Information on all pallets. + type AllPalletsInfo: PalletInfoAccess; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index ed4e5c4dcc94..c39b006944a7 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -20,14 +20,11 @@ use frame_support::{ dispatch::{Dispatchable, Weight}, ensure, weights::GetDispatchInfo, + traits::PalletInfoAccess, }; use sp_runtime::traits::Saturating; use sp_std::{marker::PhantomData, prelude::*}; -use xcm::latest::{ - Error as XcmError, ExecuteXcm, - Instruction::{self, *}, - MultiAssets, MultiLocation, Outcome, Response, SendXcm, Xcm, -}; +use xcm::latest::{Error as XcmError, ExecuteXcm, Instruction::{self, *}, MaybeErrorCode, MultiAssets, MultiLocation, Outcome, PalletInfo, QueryResponseInfo, Response, SendXcm, Xcm}; pub mod traits; use traits::{ @@ -466,6 +463,84 @@ impl XcmExecutor { ensure!(self.error == error, XcmError::ExpectationFalse); Ok(()) }, + QueryPallet { name, response_info } => { + let pallets = Config::AllPalletsInfo::infos() + .into_iter() + .filter(|x| x.name.as_bytes() == &name[..]) + .map(|x| PalletInfo { + index: x.index as u32, + name: x.name.as_bytes().into(), + module_name: x.module_name.as_bytes().into(), + major: x.crate_version.major as u32, + minor: x.crate_version.minor as u32, + patch: x.crate_version.patch as u32, + }) + .collect::>(); + let QueryResponseInfo { destination, query_id, max_weight } = response_info; + let response = Response::PalletsInfo(pallets); + let instruction = QueryResponse { query_id, response, max_weight }; + let message = Xcm(vec![instruction]); + Config::XcmSender::send_xcm(destination, message).map_err(Into::into) + }, + Dispatch { + origin_kind, + require_weight_at_most, + name, + major, + minor, + pallet_index, + call_index, + params, + response_info, + } => { + // We assume that the Relay-chain is allowed to use transact on this parachain. + let origin = self.origin.clone().ok_or(XcmError::BadOrigin)?; + + let pallet = Config::AllPalletsInfo::infos() + .into_iter() + .find(|x| x.index == pallet_index) + .ok_or(XcmError::PalletNotFound)?; + ensure!(pallet.name.as_bytes() == &name[..], XcmError::NameMismatch); + ensure!(pallet.crate_version.major as u32 == major, XcmError::VersionIncompatible); + ensure!(pallet.crate_version.minor as u32 >= minor, XcmError::VersionIncompatible); + + // TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain + let mut encoded_call = vec![pallet_index as u8, call_index as u8]; + encoded_call.extend(params); + let message_call = Config::Call::decode(&mut &encoded_call[..]) + .map_err(|_| XcmError::FailedToDecode)?; + + let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_kind) + .map_err(|_| XcmError::BadOrigin)?; + let weight = message_call.get_dispatch_info().weight; + ensure!(weight <= require_weight_at_most, XcmError::TooMuchWeightRequired); + let (actual_weight, error_code) = match message_call.dispatch(dispatch_origin) { + Ok(post_info) => (post_info.actual_weight, MaybeErrorCode::Success), + Err(error_and_info) => { + let error = MaybeErrorCode::Error(error_and_info.error.encode(); + let actual_weight = error_and_info.post_info.actual_weight; + (actual_weight, error) + }, + }; + let actual_weight = actual_weight.unwrap_or(weight); + let surplus = weight.saturating_sub(actual_weight); + // We assume that the `Config::Weigher` will counts the `require_weight_at_most` + // for the estimate of how much weight this instruction will take. Now that we know + // that it's less, we credit it. + // + // We make the adjustment for the total surplus, which is used eventually + // reported back to the caller and this ensures that they account for the total + // weight consumed correctly (potentially allowing them to do more operations in a + // block than they otherwise would). + self.total_surplus.saturating_accrue(surplus); + if let Some(QueryResponseInfo { destination, query_id, max_weight }) = response_info { + let response = Response::DispatchResult(error_code); + let instruction = QueryResponse { query_id, response, max_weight }; + let message = Xcm(vec![instruction]); + Config::XcmSender::send_xcm(destination, message).map_err(Into::into) + } + Ok(()) + }, ExchangeAsset { .. } => Err(XcmError::Unimplemented), HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), From 8740a351a6e61aad3ab11e83205307352dc6ca48 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 18 Oct 2021 23:58:35 +0200 Subject: [PATCH 005/231] Update xcm/src/v3/mod.rs Co-authored-by: Keith Yeung --- xcm/src/v3/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index b74a4106f1e4..9a5bfffd6e53 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -//! Version 1 of the Cross-Consensus Message format data structures. +//! Version 3 of the Cross-Consensus Message format data structures. use super::v2::{Instruction as OldInstruction, Response as OldResponse, Xcm as OldXcm}; use crate::{DoubleEncoded, GetWeight}; From ebafb3d73955adcf3c1e4af330fe3eedba0b7669 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 19 Oct 2021 10:15:04 +0200 Subject: [PATCH 006/231] Fixes --- xcm/xcm-executor/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index c39b006944a7..424b85fc314a 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -22,6 +22,7 @@ use frame_support::{ weights::GetDispatchInfo, traits::PalletInfoAccess, }; +use parity_scale_codec::{Encode, Decode}; use sp_runtime::traits::Saturating; use sp_std::{marker::PhantomData, prelude::*}; use xcm::latest::{Error as XcmError, ExecuteXcm, Instruction::{self, *}, MaybeErrorCode, MultiAssets, MultiLocation, Outcome, PalletInfo, QueryResponseInfo, Response, SendXcm, Xcm}; @@ -498,7 +499,7 @@ impl XcmExecutor { let pallet = Config::AllPalletsInfo::infos() .into_iter() - .find(|x| x.index == pallet_index) + .find(|x| x.index == pallet_index as usize) .ok_or(XcmError::PalletNotFound)?; ensure!(pallet.name.as_bytes() == &name[..], XcmError::NameMismatch); ensure!(pallet.crate_version.major as u32 == major, XcmError::VersionIncompatible); @@ -517,7 +518,7 @@ impl XcmExecutor { let (actual_weight, error_code) = match message_call.dispatch(dispatch_origin) { Ok(post_info) => (post_info.actual_weight, MaybeErrorCode::Success), Err(error_and_info) => { - let error = MaybeErrorCode::Error(error_and_info.error.encode(); + let error = MaybeErrorCode::Error(error_and_info.error.encode()); let actual_weight = error_and_info.post_info.actual_weight; (actual_weight, error) }, @@ -537,7 +538,7 @@ impl XcmExecutor { let response = Response::DispatchResult(error_code); let instruction = QueryResponse { query_id, response, max_weight }; let message = Xcm(vec![instruction]); - Config::XcmSender::send_xcm(destination, message).map_err(Into::into) + Config::XcmSender::send_xcm(destination, message).map_err(XcmError::from)?; } Ok(()) }, From 4b363d3d4b7f2162767e86752aa9b0f22d380751 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 19 Oct 2021 13:43:59 +0200 Subject: [PATCH 007/231] Latest Substrate naming --- bridges/bin/millau/runtime/src/lib.rs | 9 +++++++-- bridges/bin/rialto/runtime/src/lib.rs | 4 ++-- runtime/common/src/integration_tests.rs | 4 ++-- runtime/kusama/src/lib.rs | 4 ++-- runtime/parachains/src/disputes.rs | 6 +++--- runtime/polkadot/src/lib.rs | 4 ++-- runtime/rococo/src/lib.rs | 4 ++-- runtime/test-runtime/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 4 ++-- xcm/xcm-builder/tests/mock/mod.rs | 2 +- xcm/xcm-executor/src/config.rs | 4 ++-- xcm/xcm-executor/src/lib.rs | 7 +++---- 12 files changed, 29 insertions(+), 25 deletions(-) diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 65c54c3046c1..c15ffa6f205f 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -444,8 +444,13 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = - frame_executive::Executive, Runtime, AllPallets>; +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + PalletInstancesRevExSystem, +>; impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 3a8b8651e346..55bfab73e843 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -570,7 +570,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllPallets, + PalletInstancesRevExSystem, >; impl_runtime_apis! { @@ -843,7 +843,7 @@ impl_runtime_apis! { ); list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeMillauGrandpa); - let storage_info = AllPalletsWithSystem::storage_info(); + let storage_info = PalletInstances::storage_info(); return (list, storage_info) } diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index ad750602b0db..6fdd5d9c69fd 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -288,12 +288,12 @@ fn run_to_block(n: u32) { assert!(System::block_number() < n); while System::block_number() < n { let block_number = System::block_number(); - AllPallets::on_finalize(block_number); + PalletInstancesRevExSystem::on_finalize(block_number); System::on_finalize(block_number); System::set_block_number(block_number + 1); System::on_initialize(block_number + 1); maybe_new_session(block_number + 1); - AllPallets::on_initialize(block_number + 1); + PalletInstancesRevExSystem::on_initialize(block_number + 1); } } diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 4a8cf6b95d2e..124cf1ade3f5 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1556,7 +1556,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllPallets, + PalletInstancesRevExSystem, ( CouncilStoragePrefixMigration, TechnicalCommitteeStoragePrefixMigration, @@ -2090,7 +2090,7 @@ sp_api::impl_runtime_apis! { list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_vesting, Vesting); - let storage_info = AllPalletsWithSystem::storage_info(); + let storage_info = PalletInstances::storage_info(); return (list, storage_info) } diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 4059ed637868..2d49638e22a3 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -1208,7 +1208,7 @@ fn check_signature( mod tests { use super::*; use crate::mock::{ - new_test_ext, AccountId, AllPallets, Initializer, MockGenesisConfig, System, Test, + new_test_ext, AccountId, PalletInstancesRevExSystem, Initializer, MockGenesisConfig, System, Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, PUNISH_VALIDATORS_INCONCLUSIVE, REWARD_VALIDATORS, }; @@ -1240,12 +1240,12 @@ mod tests { // circumvent requirement to have bitfields and headers in block for testing purposes crate::paras_inherent::Included::::set(Some(())); - AllPallets::on_finalize(b); + PalletInstancesRevExSystem::on_finalize(b); System::finalize(); } System::initialize(&(b + 1), &Default::default(), &Default::default(), InitKind::Full); - AllPallets::on_initialize(b + 1); + PalletInstancesRevExSystem::on_initialize(b + 1); if let Some(new_session) = new_session(b + 1) { Initializer::test_trigger_on_new_session( diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index c43fbcb85393..ce356a6b4127 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1348,7 +1348,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllPallets, + PalletInstancesRevExSystem, ( SetInitialHostConfiguration, BountiesPrefixMigration, @@ -1941,7 +1941,7 @@ sp_api::impl_runtime_apis! { list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_vesting, Vesting); - let storage_info = AllPalletsWithSystem::storage_info(); + let storage_info = PalletInstances::storage_info(); return (list, storage_info) } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index d0a0c4dbda73..d325eae901b4 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -157,7 +157,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllPallets, + PalletInstancesRevExSystem, (), >; /// The payload being signed in transactions. @@ -1603,7 +1603,7 @@ sp_api::impl_runtime_apis! { list_benchmark!(list, extra, runtime_parachains::disputes, ParasDisputes); list_benchmark!(list, extra, runtime_parachains::paras, Paras); - let storage_info = AllPalletsWithSystem::storage_info(); + let storage_info = PalletInstances::storage_info(); return (list, storage_info) } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index bb1db523d33e..eb8d0c112a22 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -710,7 +710,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllPallets, + PalletInstancesRevExSystem, >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 55ef0c129c2a..cf298327f783 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1134,7 +1134,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllPallets, + PalletInstancesRevExSystem, (StakingBagsListMigrationV8,), >; /// The payload being signed in transactions. @@ -1509,7 +1509,7 @@ sp_api::impl_runtime_apis! { // NOTE: Make sure you point to the individual modules below. list_benchmark!(list, extra, pallet_xcm_benchmarks::fungible, XcmBalances); - let storage_info = AllPalletsWithSystem::storage_info(); + let storage_info = PalletInstances::storage_info(); return (list, storage_info) } diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 82ca77788369..cf1f444d01dc 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -172,7 +172,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type AllPalletsInfo = AllPallets; + type PalletInstancesInfo = PalletInstances; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 46b0d048eb3a..1042773a7dcd 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -19,7 +19,7 @@ use crate::traits::{ ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; use frame_support::dispatch::{Dispatchable, Parameter}; -use frame_support::traits::PalletInfoAccess; +use frame_support::traits::PalletsInfoAccess; use frame_support::weights::{GetDispatchInfo, PostDispatchInfo}; use xcm::latest::SendXcm; @@ -69,5 +69,5 @@ pub trait Config { type SubscriptionService: VersionChangeNotifier; /// Information on all pallets. - type AllPalletsInfo: PalletInfoAccess; + type PalletInstancesInfo: PalletsInfoAccess; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 424b85fc314a..3b8b3fcbae5d 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -20,7 +20,7 @@ use frame_support::{ dispatch::{Dispatchable, Weight}, ensure, weights::GetDispatchInfo, - traits::PalletInfoAccess, + traits::PalletsInfoAccess, }; use parity_scale_codec::{Encode, Decode}; use sp_runtime::traits::Saturating; @@ -465,7 +465,7 @@ impl XcmExecutor { Ok(()) }, QueryPallet { name, response_info } => { - let pallets = Config::AllPalletsInfo::infos() + let pallets = Config::PalletInstancesInfo::infos() .into_iter() .filter(|x| x.name.as_bytes() == &name[..]) .map(|x| PalletInfo { @@ -494,10 +494,9 @@ impl XcmExecutor { params, response_info, } => { - // We assume that the Relay-chain is allowed to use transact on this parachain. let origin = self.origin.clone().ok_or(XcmError::BadOrigin)?; - let pallet = Config::AllPalletsInfo::infos() + let pallet = Config::PalletInstancesInfo::infos() .into_iter() .find(|x| x.index == pallet_index as usize) .ok_or(XcmError::PalletNotFound)?; From 90413408614d1e888d754252c1353e39f99da9e2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 19 Oct 2021 13:45:39 +0200 Subject: [PATCH 008/231] Formatting --- runtime/parachains/src/disputes.rs | 6 +-- xcm/src/v3/mod.rs | 63 +++++++++++++++++------------- xcm/xcm-executor/src/config.rs | 8 ++-- xcm/xcm-executor/src/lib.rs | 14 +++++-- 4 files changed, 53 insertions(+), 38 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 2d49638e22a3..3a2d74cc529b 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -1208,9 +1208,9 @@ fn check_signature( mod tests { use super::*; use crate::mock::{ - new_test_ext, AccountId, PalletInstancesRevExSystem, Initializer, MockGenesisConfig, System, Test, - PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, PUNISH_VALIDATORS_INCONCLUSIVE, - REWARD_VALIDATORS, + new_test_ext, AccountId, Initializer, MockGenesisConfig, PalletInstancesRevExSystem, + System, Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, + PUNISH_VALIDATORS_INCONCLUSIVE, REWARD_VALIDATORS, }; use frame_support::{ assert_err, assert_noop, assert_ok, assert_storage_noop, diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 9a5bfffd6e53..b6f4d7b1e2d3 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -147,12 +147,16 @@ pub mod prelude { #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] pub struct PalletInfo { - #[codec(compact)] pub index: u32, + #[codec(compact)] + pub index: u32, pub name: Vec, pub module_name: Vec, - #[codec(compact)] pub major: u32, - #[codec(compact)] pub minor: u32, - #[codec(compact)] pub patch: u32, + #[codec(compact)] + pub major: u32, + #[codec(compact)] + pub minor: u32, + #[codec(compact)] + pub patch: u32, } #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] @@ -187,12 +191,14 @@ impl Default for Response { /// Information regarding the composition of a query response. #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] pub struct QueryResponseInfo { - /// The destination to which the query response message should be send. + /// The destination to which the query response message should be send. pub destination: MultiLocation, /// The `query_id` field of the `QueryResponse` message. - #[codec(compact)] pub query_id: QueryId, + #[codec(compact)] + pub query_id: QueryId, /// The `max_weight` field of the `QueryResponse` message. - #[codec(compact)] pub max_weight: Weight, + #[codec(compact)] + pub max_weight: Weight, } /// Cross-Consensus Message: A message from one consensus system to another. @@ -670,27 +676,24 @@ pub enum Instruction { ExpectError(Option<(u32, Error)>), /// Query the existence of a particular pallet type. - /// + /// /// - `name`: The name of the pallet to query. /// - `response_info`: Information for making the response. - /// + /// /// Sends a `QueryResponse` to Origin whose data field `PalletsInfo` containing the information /// of all pallets on the local chain whose name is equal to `name`. This is empty in the case /// that the local chain is not based on Substrate Frame. - /// + /// /// Safety: No concerns. - /// + /// /// Kind: *Instruction* - /// + /// /// Errors: *Fallible*. - QueryPallet { - name: Vec, - response_info: QueryResponseInfo, - }, - + QueryPallet { name: Vec, response_info: QueryResponseInfo }, + /// Dispatch a call into a pallet in the Frame system. This provides a means of ensuring that /// the pallet continues to exist with a known version. - /// + /// /// - `origin_kind`: The means of expressing the message origin as a dispatch origin. /// - `name`: The name of the pallet to which to dispatch a message. /// - `major`, `minor`: The major and minor version of the pallet. The major version @@ -704,20 +707,25 @@ pub enum Instruction { /// error status of the "inner" dispatch. This only happens if the dispatch was actually /// made - if an error happened prior to dispatch, then the Error Register is set and the /// operation aborted as usual. - /// + /// /// Safety: No concerns. - /// + /// /// Kind: *Instruction* - /// + /// /// Errors: *Fallible*. Dispatch { origin_kind: OriginKind, - #[codec(compact)] require_weight_at_most: Weight, + #[codec(compact)] + require_weight_at_most: Weight, name: Vec, - #[codec(compact)] major: u32, - #[codec(compact)] minor: u32, - #[codec(compact)] pallet_index: u32, - #[codec(compact)] call_index: u32, + #[codec(compact)] + major: u32, + #[codec(compact)] + minor: u32, + #[codec(compact)] + pallet_index: u32, + #[codec(compact)] + call_index: u32, params: Vec, response_info: Option, }, @@ -782,8 +790,7 @@ impl Instruction { ExpectAsset(assets) => ExpectAsset(assets), ExpectOrigin(origin) => ExpectOrigin(origin), ExpectError(error) => ExpectError(error), - QueryPallet { name, response_info } => - QueryPallet { name, response_info }, + QueryPallet { name, response_info } => QueryPallet { name, response_info }, Dispatch { origin_kind, require_weight_at_most, diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 1042773a7dcd..e328127c7f7d 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -18,9 +18,11 @@ use crate::traits::{ ClaimAssets, ConvertOrigin, DropAssets, FilterAssetLocation, InvertLocation, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; -use frame_support::dispatch::{Dispatchable, Parameter}; -use frame_support::traits::PalletsInfoAccess; -use frame_support::weights::{GetDispatchInfo, PostDispatchInfo}; +use frame_support::{ + dispatch::{Dispatchable, Parameter}, + traits::PalletsInfoAccess, + weights::{GetDispatchInfo, PostDispatchInfo}, +}; use xcm::latest::SendXcm; /// The trait to parameterize the `XcmExecutor`. diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 3b8b3fcbae5d..3d422308cc11 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -19,13 +19,18 @@ use frame_support::{ dispatch::{Dispatchable, Weight}, ensure, - weights::GetDispatchInfo, traits::PalletsInfoAccess, + weights::GetDispatchInfo, }; -use parity_scale_codec::{Encode, Decode}; +use parity_scale_codec::{Decode, Encode}; use sp_runtime::traits::Saturating; use sp_std::{marker::PhantomData, prelude::*}; -use xcm::latest::{Error as XcmError, ExecuteXcm, Instruction::{self, *}, MaybeErrorCode, MultiAssets, MultiLocation, Outcome, PalletInfo, QueryResponseInfo, Response, SendXcm, Xcm}; +use xcm::latest::{ + Error as XcmError, ExecuteXcm, + Instruction::{self, *}, + MaybeErrorCode, MultiAssets, MultiLocation, Outcome, PalletInfo, QueryResponseInfo, Response, + SendXcm, Xcm, +}; pub mod traits; use traits::{ @@ -533,7 +538,8 @@ impl XcmExecutor { // weight consumed correctly (potentially allowing them to do more operations in a // block than they otherwise would). self.total_surplus.saturating_accrue(surplus); - if let Some(QueryResponseInfo { destination, query_id, max_weight }) = response_info { + if let Some(QueryResponseInfo { destination, query_id, max_weight }) = response_info + { let response = Response::DispatchResult(error_code); let instruction = QueryResponse { query_id, response, max_weight }; let message = Xcm(vec![instruction]); From d4866a144699c0076dc5507143246c31ec103788 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 20 Oct 2021 13:45:31 +0200 Subject: [PATCH 009/231] Introduce into runtimes --- runtime/kusama/src/lib.rs | 1 + runtime/rococo/src/lib.rs | 1 + runtime/test-runtime/src/xcm_config.rs | 1 + runtime/westend/src/lib.rs | 1 + xcm/pallet-xcm-benchmarks/src/fungible/mock.rs | 1 + xcm/pallet-xcm/src/mock.rs | 1 + 6 files changed, 6 insertions(+) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 124cf1ade3f5..eaa1c9922a46 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1359,6 +1359,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; + type PalletInstancesInfo = PalletInstances; } parameter_types! { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index d325eae901b4..9694f9162842 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -690,6 +690,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; + type PalletInstancesInfo = PalletInstances; } parameter_types! { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 3a3c762c6b03..d73c59762b44 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -89,4 +89,5 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = super::Xcm; type AssetClaims = super::Xcm; type SubscriptionService = super::Xcm; + type PalletInstancesInfo = (); } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index cf298327f783..5bddead013fe 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -995,6 +995,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; + type PalletInstancesInfo = PalletInstances; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 8666dc6caa4d..273134ac0024 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -140,6 +140,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type PalletInstancesInfo = (); } impl crate::Config for Test { diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 8b6174c5b722..a66fc7ce56b2 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -264,6 +264,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; + type PalletInstancesInfo = PalletInstances; } pub type LocalOriginToLocation = SignedToAccountId32; From 451a588b8365ef53a49d9642c5e05e001aa86505 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 20 Oct 2021 15:53:10 +0200 Subject: [PATCH 010/231] Back to nesting --- bridges/bin/millau/runtime/src/lib.rs | 2 +- bridges/bin/rialto/runtime/src/lib.rs | 4 ++-- runtime/common/src/integration_tests.rs | 4 ++-- runtime/kusama/src/lib.rs | 6 +++--- runtime/parachains/src/disputes.rs | 6 +++--- runtime/polkadot/src/lib.rs | 4 ++-- runtime/rococo/src/lib.rs | 6 +++--- runtime/test-runtime/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 6 +++--- xcm/pallet-xcm/src/mock.rs | 2 +- xcm/xcm-builder/tests/mock/mod.rs | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index c15ffa6f205f..88fb045b8cc1 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -449,7 +449,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - PalletInstancesRevExSystem, + AllPallets, >; impl_runtime_apis! { diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 55bfab73e843..3a8b8651e346 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -570,7 +570,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - PalletInstancesRevExSystem, + AllPallets, >; impl_runtime_apis! { @@ -843,7 +843,7 @@ impl_runtime_apis! { ); list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeMillauGrandpa); - let storage_info = PalletInstances::storage_info(); + let storage_info = AllPalletsWithSystem::storage_info(); return (list, storage_info) } diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index 6fdd5d9c69fd..ad750602b0db 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -288,12 +288,12 @@ fn run_to_block(n: u32) { assert!(System::block_number() < n); while System::block_number() < n { let block_number = System::block_number(); - PalletInstancesRevExSystem::on_finalize(block_number); + AllPallets::on_finalize(block_number); System::on_finalize(block_number); System::set_block_number(block_number + 1); System::on_initialize(block_number + 1); maybe_new_session(block_number + 1); - PalletInstancesRevExSystem::on_initialize(block_number + 1); + AllPallets::on_initialize(block_number + 1); } } diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index eaa1c9922a46..cff846eeb47d 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1359,7 +1359,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = PalletInstances; + type PalletInstancesInfo = AllPallets; } parameter_types! { @@ -1557,7 +1557,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - PalletInstancesRevExSystem, + AllPallets, ( CouncilStoragePrefixMigration, TechnicalCommitteeStoragePrefixMigration, @@ -2091,7 +2091,7 @@ sp_api::impl_runtime_apis! { list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_vesting, Vesting); - let storage_info = PalletInstances::storage_info(); + let storage_info = AllPalletsWithSystem::storage_info(); return (list, storage_info) } diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 3a2d74cc529b..2fb2ebd32b93 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -1208,7 +1208,7 @@ fn check_signature( mod tests { use super::*; use crate::mock::{ - new_test_ext, AccountId, Initializer, MockGenesisConfig, PalletInstancesRevExSystem, + new_test_ext, AccountId, Initializer, MockGenesisConfig, AllPallets, System, Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, PUNISH_VALIDATORS_INCONCLUSIVE, REWARD_VALIDATORS, }; @@ -1240,12 +1240,12 @@ mod tests { // circumvent requirement to have bitfields and headers in block for testing purposes crate::paras_inherent::Included::::set(Some(())); - PalletInstancesRevExSystem::on_finalize(b); + AllPallets::on_finalize(b); System::finalize(); } System::initialize(&(b + 1), &Default::default(), &Default::default(), InitKind::Full); - PalletInstancesRevExSystem::on_initialize(b + 1); + AllPallets::on_initialize(b + 1); if let Some(new_session) = new_session(b + 1) { Initializer::test_trigger_on_new_session( diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index ce356a6b4127..c43fbcb85393 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1348,7 +1348,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - PalletInstancesRevExSystem, + AllPallets, ( SetInitialHostConfiguration, BountiesPrefixMigration, @@ -1941,7 +1941,7 @@ sp_api::impl_runtime_apis! { list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_vesting, Vesting); - let storage_info = PalletInstances::storage_info(); + let storage_info = AllPalletsWithSystem::storage_info(); return (list, storage_info) } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 9694f9162842..22f0c7318980 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -157,7 +157,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - PalletInstancesRevExSystem, + AllPallets, (), >; /// The payload being signed in transactions. @@ -690,7 +690,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = PalletInstances; + type PalletInstancesInfo = AllPallets; } parameter_types! { @@ -1604,7 +1604,7 @@ sp_api::impl_runtime_apis! { list_benchmark!(list, extra, runtime_parachains::disputes, ParasDisputes); list_benchmark!(list, extra, runtime_parachains::paras, Paras); - let storage_info = PalletInstances::storage_info(); + let storage_info = AllPalletsWithSystem::storage_info(); return (list, storage_info) } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index eb8d0c112a22..bb1db523d33e 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -710,7 +710,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - PalletInstancesRevExSystem, + AllPallets, >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 5bddead013fe..fd11728a4836 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -995,7 +995,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = PalletInstances; + type PalletInstancesInfo = AllPallets; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location @@ -1135,7 +1135,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - PalletInstancesRevExSystem, + AllPallets, (StakingBagsListMigrationV8,), >; /// The payload being signed in transactions. @@ -1510,7 +1510,7 @@ sp_api::impl_runtime_apis! { // NOTE: Make sure you point to the individual modules below. list_benchmark!(list, extra, pallet_xcm_benchmarks::fungible, XcmBalances); - let storage_info = PalletInstances::storage_info(); + let storage_info = AllPalletsWithSystem::storage_info(); return (list, storage_info) } diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index a66fc7ce56b2..d772d4e75f77 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -264,7 +264,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = PalletInstances; + type PalletInstancesInfo = AllPallets; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index cf1f444d01dc..3c05a7e4f451 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -172,7 +172,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = PalletInstances; + type PalletInstancesInfo = AllPallets; } pub type LocalOriginToLocation = SignedToAccountId32; From c9e3d7f750d0d2dd1c1c3ae750834ae8f8331a17 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 20 Oct 2021 19:22:19 +0200 Subject: [PATCH 011/231] Formatting --- runtime/parachains/src/disputes.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 2fb2ebd32b93..4059ed637868 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -1208,9 +1208,9 @@ fn check_signature( mod tests { use super::*; use crate::mock::{ - new_test_ext, AccountId, Initializer, MockGenesisConfig, AllPallets, - System, Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, - PUNISH_VALIDATORS_INCONCLUSIVE, REWARD_VALIDATORS, + new_test_ext, AccountId, AllPallets, Initializer, MockGenesisConfig, System, Test, + PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, PUNISH_VALIDATORS_INCONCLUSIVE, + REWARD_VALIDATORS, }; use frame_support::{ assert_err, assert_noop, assert_ok, assert_storage_noop, From 4b47b2b2741d6eca45efb34e9b8e0c0bf3df3d8b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 11:17:38 +0200 Subject: [PATCH 012/231] Bump Substrate --- Cargo.lock | 381 +++++++++++++++--------------------- Cargo.toml | 217 -------------------- xcm/src/v3/mod.rs | 5 +- xcm/src/v3/traits.rs | 2 +- xcm/xcm-executor/src/lib.rs | 3 +- 5 files changed, 165 insertions(+), 443 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 767f8662cba5..8aa380a3b57e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -467,6 +467,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "beefy-primitives", "fnv", @@ -494,6 +495,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -513,10 +515,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" [[package]] name = "beefy-primitives" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "scale-info", @@ -1906,6 +1910,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", ] @@ -1923,6 +1928,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -1942,6 +1948,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "Inflector", "chrono", @@ -1967,6 +1974,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -1980,6 +1988,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -2007,6 +2016,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "bitflags", "frame-metadata", @@ -2033,6 +2043,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2044,6 +2055,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.0", @@ -2055,6 +2067,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "proc-macro2", "quote", @@ -2064,6 +2077,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2086,6 +2100,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -2096,6 +2111,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "log", @@ -2112,6 +2128,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -2126,6 +2143,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "sp-api", @@ -2134,6 +2152,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "sp-api", @@ -2346,6 +2365,7 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generate-bags" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "chrono", "frame-election-provider-support", @@ -4586,6 +4606,7 @@ checksum = "13370dae44474229701bb69b90b4f4dca6404cb0357a2d50d635f1171dc3aa7b" [[package]] name = "pallet-assets" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4599,6 +4620,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -4614,6 +4636,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -4628,6 +4651,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4651,6 +4675,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4670,6 +4695,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4684,6 +4710,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "beefy-primitives", "frame-support", @@ -4699,6 +4726,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -4723,6 +4751,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4807,6 +4836,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4823,6 +4853,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4838,6 +4869,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4861,6 +4893,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4878,6 +4911,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4892,6 +4926,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4914,6 +4949,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "enumflags2", "frame-benchmarking", @@ -4929,6 +4965,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4948,6 +4985,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4964,6 +5002,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -4980,6 +5019,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -4997,6 +5037,7 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -5012,6 +5053,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5028,6 +5070,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -5042,6 +5085,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -5055,6 +5099,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -5071,6 +5116,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5093,6 +5139,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -5107,6 +5154,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -5120,6 +5168,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -5135,6 +5184,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -5155,6 +5205,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -5170,6 +5221,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -5183,6 +5235,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5205,6 +5258,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -5215,6 +5269,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "log", "sp-arithmetic", @@ -5223,6 +5278,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -5236,6 +5292,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -5253,6 +5310,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -5271,6 +5329,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-support", "frame-system", @@ -5287,6 +5346,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5303,6 +5363,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5313,6 +5374,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -5329,6 +5391,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -5344,6 +5407,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-benchmarking", "frame-support", @@ -7714,6 +7778,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "env_logger 0.9.0", "jsonrpsee-proc-macros", @@ -7976,6 +8041,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "log", "sp-core", @@ -7986,6 +8052,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "derive_more", @@ -8012,6 +8079,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -8034,6 +8102,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8049,6 +8118,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -8064,6 +8134,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -8074,6 +8145,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "chrono", "fdlimit", @@ -8111,6 +8183,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "fnv", "futures 0.3.17", @@ -8138,6 +8211,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "hash-db", "kvdb", @@ -8162,6 +8236,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "futures 0.3.17", @@ -8185,6 +8260,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "derive_more", @@ -8227,6 +8303,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "derive_more", "futures 0.3.17", @@ -8250,6 +8327,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8262,6 +8340,7 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "assert_matches", "async-trait", @@ -8295,6 +8374,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "futures 0.3.17", @@ -8320,6 +8400,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "sc-client-api", "sp-authorship", @@ -8330,6 +8411,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "lazy_static", "libsecp256k1 0.6.0", @@ -8355,6 +8437,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "derive_more", "environmental", @@ -8372,6 +8455,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "log", "parity-scale-codec", @@ -8387,6 +8471,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "cfg-if 1.0.0", "libc", @@ -8404,6 +8489,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "derive_more", @@ -8440,6 +8526,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "derive_more", "finality-grandpa", @@ -8463,6 +8550,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "ansi_term 0.12.1", "futures 0.3.17", @@ -8479,6 +8567,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "derive_more", @@ -8493,6 +8582,7 @@ dependencies = [ [[package]] name = "sc-light" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "hash-db", "parity-scale-codec", @@ -8510,6 +8600,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-std", "async-trait", @@ -8560,6 +8651,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -8575,6 +8667,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "bytes 1.0.1", "fnv", @@ -8601,6 +8694,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "libp2p", @@ -8613,6 +8707,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.9.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8621,6 +8716,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "hash-db", @@ -8651,6 +8747,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "jsonrpc-core", @@ -8675,6 +8772,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "jsonrpc-core", @@ -8691,6 +8789,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "directories", @@ -8755,6 +8854,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "log", "parity-scale-codec", @@ -8768,6 +8868,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -8789,6 +8890,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "chrono", "futures 0.3.17", @@ -8806,6 +8908,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "ansi_term 0.12.1", "atty", @@ -8835,6 +8938,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -8845,6 +8949,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "intervalier", @@ -8871,6 +8976,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "derive_more", "futures 0.3.17", @@ -8884,6 +8990,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -9306,6 +9413,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "hash-db", "log", @@ -9322,6 +9430,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "blake2-rfc", "proc-macro-crate 1.1.0", @@ -9333,6 +9442,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "scale-info", @@ -9345,6 +9455,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "integer-sqrt", "num-traits", @@ -9359,6 +9470,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "scale-info", @@ -9371,6 +9483,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "parity-scale-codec", @@ -9382,6 +9495,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "sp-api", @@ -9393,6 +9507,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "log", @@ -9410,6 +9525,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "futures 0.3.17", @@ -9428,6 +9544,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "merlin", @@ -9450,6 +9567,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "scale-info", @@ -9460,6 +9578,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -9471,6 +9590,7 @@ dependencies = [ [[package]] name = "sp-core" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "base58", "blake2-rfc", @@ -9516,6 +9636,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "kvdb", "parking_lot", @@ -9524,6 +9645,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "proc-macro2", "quote", @@ -9533,6 +9655,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "environmental", "parity-scale-codec", @@ -9543,6 +9666,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "finality-grandpa", "log", @@ -9560,6 +9684,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -9573,6 +9698,7 @@ dependencies = [ [[package]] name = "sp-io" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "hash-db", @@ -9596,6 +9722,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "lazy_static", "sp-core", @@ -9606,6 +9733,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "derive_more", @@ -9622,6 +9750,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "zstd", ] @@ -9629,6 +9758,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "scale-info", @@ -9643,6 +9773,7 @@ dependencies = [ [[package]] name = "sp-npos-elections-solution-type" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -9653,6 +9784,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "sp-api", "sp-core", @@ -9662,6 +9794,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "backtrace", ] @@ -9669,6 +9802,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "rustc-hash", "serde", @@ -9678,6 +9812,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "either", "hash256-std-hasher", @@ -9699,6 +9834,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -9715,6 +9851,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "Inflector", "proc-macro-crate 1.1.0", @@ -9726,6 +9863,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "serde", "serde_json", @@ -9734,6 +9872,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "scale-info", @@ -9747,6 +9886,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "scale-info", @@ -9757,6 +9897,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "hash-db", "log", @@ -9779,10 +9920,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" [[package]] name = "sp-storage" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9795,6 +9938,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "log", "sp-core", @@ -9807,6 +9951,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "futures-timer 3.0.2", @@ -9822,6 +9967,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "sp-std", @@ -9833,6 +9979,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "sp-api", "sp-runtime", @@ -9841,6 +9988,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "log", @@ -9856,6 +10004,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "hash-db", "memory-db", @@ -9870,6 +10019,7 @@ dependencies = [ [[package]] name = "sp-version" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9885,6 +10035,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -9895,6 +10046,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10122,6 +10274,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "platforms", ] @@ -10129,6 +10282,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.17", @@ -10150,6 +10304,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.9.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-std", "derive_more", @@ -10163,6 +10318,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "async-trait", "futures 0.3.17", @@ -10189,6 +10345,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "futures 0.3.17", "substrate-test-utils-derive", @@ -10198,6 +10355,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -10208,6 +10366,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "ansi_term 0.12.1", "build-helper", @@ -10360,6 +10519,7 @@ dependencies = [ [[package]] name = "test-runner" version = "0.9.0" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "frame-system", "futures 0.3.17", @@ -10800,6 +10960,7 @@ checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#11754462c426c782bd7eb0416b4eddee5c475439" dependencies = [ "jsonrpsee-ws-client", "log", @@ -11777,223 +11938,3 @@ dependencies = [ "cc", "libc", ] - -[[patch.unused]] -name = "chain-spec-builder" -version = "2.0.0" - -[[patch.unused]] -name = "node-bench" -version = "0.9.0-dev" - -[[patch.unused]] -name = "node-cli" -version = "3.0.0-dev" - -[[patch.unused]] -name = "node-executor" -version = "3.0.0-dev" - -[[patch.unused]] -name = "node-inspect" -version = "0.9.0-dev" - -[[patch.unused]] -name = "node-primitives" -version = "2.0.0" - -[[patch.unused]] -name = "node-rpc" -version = "3.0.0-dev" - -[[patch.unused]] -name = "node-rpc-client" -version = "2.0.0" - -[[patch.unused]] -name = "node-runtime" -version = "3.0.0-dev" - -[[patch.unused]] -name = "node-runtime-generate-bags" -version = "3.0.0" - -[[patch.unused]] -name = "node-template" -version = "3.0.0" - -[[patch.unused]] -name = "node-template-runtime" -version = "3.0.0" - -[[patch.unused]] -name = "node-testing" -version = "3.0.0-dev" - -[[patch.unused]] -name = "pallet-atomic-swap" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-aura" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-contracts" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-contracts-primitives" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-contracts-proc-macro" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-contracts-rpc" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-contracts-rpc-runtime-api" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-elections" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-example" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-example-offchain-worker" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-example-parallel" -version = "3.0.0-dev" - -[[patch.unused]] -name = "pallet-lottery" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-node-authorization" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-randomness-collective-flip" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-scored-pool" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-template" -version = "3.0.0" - -[[patch.unused]] -name = "pallet-transaction-storage" -version = "4.0.0-dev" - -[[patch.unused]] -name = "pallet-uniques" -version = "4.0.0-dev" - -[[patch.unused]] -name = "sc-consensus-aura" -version = "0.10.0-dev" - -[[patch.unused]] -name = "sc-consensus-pow" -version = "0.10.0-dev" - -[[patch.unused]] -name = "sc-network-test" -version = "0.8.0" - -[[patch.unused]] -name = "sc-runtime-test" -version = "2.0.0" - -[[patch.unused]] -name = "sc-service-test" -version = "2.0.0" - -[[patch.unused]] -name = "sp-api-test" -version = "2.0.1" - -[[patch.unused]] -name = "sp-application-crypto-test" -version = "2.0.0" - -[[patch.unused]] -name = "sp-arithmetic-fuzzer" -version = "2.0.0" - -[[patch.unused]] -name = "sp-consensus-aura" -version = "0.10.0-dev" - -[[patch.unused]] -name = "sp-consensus-pow" -version = "0.10.0-dev" - -[[patch.unused]] -name = "sp-npos-elections-fuzzer" -version = "2.0.0-alpha.5" - -[[patch.unused]] -name = "sp-runtime-interface-test" -version = "2.0.0" - -[[patch.unused]] -name = "sp-runtime-interface-test-wasm" -version = "2.0.0" - -[[patch.unused]] -name = "sp-runtime-interface-test-wasm-deprecated" -version = "2.0.0" - -[[patch.unused]] -name = "sp-sandbox" -version = "0.10.0-dev" - -[[patch.unused]] -name = "sp-test-primitives" -version = "2.0.0" - -[[patch.unused]] -name = "subkey" -version = "2.0.1" - -[[patch.unused]] -name = "substrate-frame-cli" -version = "4.0.0-dev" - -[[patch.unused]] -name = "substrate-frame-rpc-support" -version = "3.0.0" - -[[patch.unused]] -name = "substrate-test-runtime" -version = "2.0.0" - -[[patch.unused]] -name = "substrate-test-runtime-client" -version = "2.0.0" - -[[patch.unused]] -name = "substrate-test-runtime-transaction-pool" -version = "2.0.0" - -[[patch.unused]] -name = "substrate-test-utils-test-crate" -version = "0.1.0" - -[[patch.unused]] -name = "test-runner-example" -version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 4930ad1791ea..8ab176c69b13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -117,223 +117,6 @@ panic = "unwind" runtime-benchmarks= [ "polkadot-cli/runtime-benchmarks" ] try-runtime = [ "polkadot-cli/try-runtime" ] disputes = [ "polkadot-cli/disputes" ] -[patch."https://github.com/paritytech/substrate"] -node-template ={path = "/Users/gav/Core/substrate/bin/node-template/node" } -frame-benchmarking ={path = "/Users/gav/Core/substrate/frame/benchmarking" } -frame-support ={path = "/Users/gav/Core/substrate/frame/support" } -frame-support-procedural ={path = "/Users/gav/Core/substrate/frame/support/procedural" } -frame-support-procedural-tools ={path = "/Users/gav/Core/substrate/frame/support/procedural/tools" } -frame-support-procedural-tools-derive ={path = "/Users/gav/Core/substrate/frame/support/procedural/tools/derive" } -sp-arithmetic ={path = "/Users/gav/Core/substrate/primitives/arithmetic" } -sp-debug-derive ={path = "/Users/gav/Core/substrate/primitives/debug-derive" } -sp-std ={path = "/Users/gav/Core/substrate/primitives/std" } -sp-core ={path = "/Users/gav/Core/substrate/primitives/core" } -sp-externalities ={path = "/Users/gav/Core/substrate/primitives/externalities" } -sp-storage ={path = "/Users/gav/Core/substrate/primitives/storage" } -sp-runtime-interface ={path = "/Users/gav/Core/substrate/primitives/runtime-interface" } -sp-runtime-interface-proc-macro ={path = "/Users/gav/Core/substrate/primitives/runtime-interface/proc-macro" } -sp-tracing ={path = "/Users/gav/Core/substrate/primitives/tracing" } -sp-wasm-interface ={path = "/Users/gav/Core/substrate/primitives/wasm-interface" } -sp-io ={path = "/Users/gav/Core/substrate/primitives/io" } -sp-keystore ={path = "/Users/gav/Core/substrate/primitives/keystore" } -sp-state-machine ={path = "/Users/gav/Core/substrate/primitives/state-machine" } -sp-panic-handler ={path = "/Users/gav/Core/substrate/primitives/panic-handler" } -sp-trie ={path = "/Users/gav/Core/substrate/primitives/trie" } -sp-runtime ={path = "/Users/gav/Core/substrate/primitives/runtime" } -sp-application-crypto ={path = "/Users/gav/Core/substrate/primitives/application-crypto" } -sp-api ={path = "/Users/gav/Core/substrate/primitives/api" } -sp-api-proc-macro ={path = "/Users/gav/Core/substrate/primitives/api/proc-macro" } -sp-version ={path = "/Users/gav/Core/substrate/primitives/version" } -sp-version-proc-macro ={path = "/Users/gav/Core/substrate/primitives/version/proc-macro" } -sp-test-primitives ={path = "/Users/gav/Core/substrate/primitives/test-primitives" } -substrate-test-runtime-client ={path = "/Users/gav/Core/substrate/test-utils/runtime/client" } -sc-block-builder ={path = "/Users/gav/Core/substrate/client/block-builder" } -sc-client-api ={path = "/Users/gav/Core/substrate/client/api" } -substrate-prometheus-endpoint ={path = "/Users/gav/Core/substrate/utils/prometheus" } -sc-executor ={path = "/Users/gav/Core/substrate/client/executor" } -sc-executor-common ={path = "/Users/gav/Core/substrate/client/executor/common" } -sc-allocator ={path = "/Users/gav/Core/substrate/client/allocator" } -sp-maybe-compressed-blob ={path = "/Users/gav/Core/substrate/primitives/maybe-compressed-blob" } -sp-serializer ={path = "/Users/gav/Core/substrate/primitives/serializer" } -sc-executor-wasmi ={path = "/Users/gav/Core/substrate/client/executor/wasmi" } -sc-executor-wasmtime ={path = "/Users/gav/Core/substrate/client/executor/wasmtime" } -sc-runtime-test ={path = "/Users/gav/Core/substrate/client/executor/runtime-test" } -sp-sandbox ={path = "/Users/gav/Core/substrate/primitives/sandbox" } -sp-tasks ={path = "/Users/gav/Core/substrate/primitives/tasks" } -substrate-wasm-builder ={path = "/Users/gav/Core/substrate/utils/wasm-builder" } -sc-tracing ={path = "/Users/gav/Core/substrate/client/tracing" } -sc-rpc-server ={path = "/Users/gav/Core/substrate/client/rpc-servers" } -sc-tracing-proc-macro ={path = "/Users/gav/Core/substrate/client/tracing/proc-macro" } -sp-blockchain ={path = "/Users/gav/Core/substrate/primitives/blockchain" } -sp-consensus ={path = "/Users/gav/Core/substrate/primitives/consensus/common" } -sp-inherents ={path = "/Users/gav/Core/substrate/primitives/inherents" } -sp-database ={path = "/Users/gav/Core/substrate/primitives/database" } -sp-rpc ={path = "/Users/gav/Core/substrate/primitives/rpc" } -substrate-test-runtime ={path = "/Users/gav/Core/substrate/test-utils/runtime" } -frame-system ={path = "/Users/gav/Core/substrate/frame/system" } -frame-system-rpc-runtime-api ={path = "/Users/gav/Core/substrate/frame/system/rpc/runtime-api" } -pallet-babe ={path = "/Users/gav/Core/substrate/frame/babe" } -pallet-authorship ={path = "/Users/gav/Core/substrate/frame/authorship" } -sp-authorship ={path = "/Users/gav/Core/substrate/primitives/authorship" } -pallet-session ={path = "/Users/gav/Core/substrate/frame/session" } -pallet-timestamp ={path = "/Users/gav/Core/substrate/frame/timestamp" } -sp-timestamp ={path = "/Users/gav/Core/substrate/primitives/timestamp" } -sp-session ={path = "/Users/gav/Core/substrate/primitives/session" } -sp-staking ={path = "/Users/gav/Core/substrate/primitives/staking" } -sp-consensus-babe ={path = "/Users/gav/Core/substrate/primitives/consensus/babe" } -sp-consensus-slots ={path = "/Users/gav/Core/substrate/primitives/consensus/slots" } -sp-consensus-vrf ={path = "/Users/gav/Core/substrate/primitives/consensus/vrf" } -frame-election-provider-support ={path = "/Users/gav/Core/substrate/frame/election-provider-support" } -sp-npos-elections ={path = "/Users/gav/Core/substrate/primitives/npos-elections" } -sp-npos-elections-solution-type ={path = "/Users/gav/Core/substrate/primitives/npos-elections/solution-type" } -substrate-test-utils ={path = "/Users/gav/Core/substrate/test-utils" } -substrate-test-utils-derive ={path = "/Users/gav/Core/substrate/test-utils/derive" } -sc-service ={path = "/Users/gav/Core/substrate/client/service" } -sc-chain-spec ={path = "/Users/gav/Core/substrate/client/chain-spec" } -sc-chain-spec-derive ={path = "/Users/gav/Core/substrate/client/chain-spec/derive" } -sc-network ={path = "/Users/gav/Core/substrate/client/network" } -fork-tree ={path = "/Users/gav/Core/substrate/utils/fork-tree" } -sc-consensus ={path = "/Users/gav/Core/substrate/client/consensus/common" } -sc-utils ={path = "/Users/gav/Core/substrate/client/utils" } -sc-peerset ={path = "/Users/gav/Core/substrate/client/peerset" } -sp-finality-grandpa ={path = "/Users/gav/Core/substrate/primitives/finality-grandpa" } -sc-telemetry ={path = "/Users/gav/Core/substrate/client/telemetry" } -sc-client-db ={path = "/Users/gav/Core/substrate/client/db" } -sc-state-db ={path = "/Users/gav/Core/substrate/client/state-db" } -sc-informant ={path = "/Users/gav/Core/substrate/client/informant" } -sc-transaction-pool-api ={path = "/Users/gav/Core/substrate/client/transaction-pool/api" } -sc-keystore ={path = "/Users/gav/Core/substrate/client/keystore" } -sc-light ={path = "/Users/gav/Core/substrate/client/light" } -sc-offchain ={path = "/Users/gav/Core/substrate/client/offchain" } -sp-offchain ={path = "/Users/gav/Core/substrate/primitives/offchain" } -sc-transaction-pool ={path = "/Users/gav/Core/substrate/client/transaction-pool" } -sp-transaction-pool ={path = "/Users/gav/Core/substrate/primitives/transaction-pool" } -substrate-test-runtime-transaction-pool ={path = "/Users/gav/Core/substrate/test-utils/runtime/transaction-pool" } -sc-rpc ={path = "/Users/gav/Core/substrate/client/rpc" } -sc-rpc-api ={path = "/Users/gav/Core/substrate/client/rpc-api" } -sp-block-builder ={path = "/Users/gav/Core/substrate/primitives/block-builder" } -sp-transaction-storage-proof ={path = "/Users/gav/Core/substrate/primitives/transaction-storage-proof" } -pallet-balances ={path = "/Users/gav/Core/substrate/frame/balances" } -pallet-transaction-payment ={path = "/Users/gav/Core/substrate/frame/transaction-payment" } -pallet-offences ={path = "/Users/gav/Core/substrate/frame/offences" } -pallet-staking ={path = "/Users/gav/Core/substrate/frame/staking" } -pallet-bags-list ={path = "/Users/gav/Core/substrate/frame/bags-list" } -pallet-staking-reward-curve ={path = "/Users/gav/Core/substrate/frame/staking/reward-curve" } -sp-consensus-aura ={path = "/Users/gav/Core/substrate/primitives/consensus/aura" } -sp-keyring ={path = "/Users/gav/Core/substrate/primitives/keyring" } -substrate-test-client ={path = "/Users/gav/Core/substrate/test-utils/client" } -sp-runtime-interface-test-wasm ={path = "/Users/gav/Core/substrate/primitives/runtime-interface/test-wasm" } -frame-benchmarking-cli ={path = "/Users/gav/Core/substrate/utils/frame/benchmarking-cli" } -sc-cli ={path = "/Users/gav/Core/substrate/client/cli" } -node-template-runtime ={path = "/Users/gav/Core/substrate/bin/node-template/runtime" } -frame-executive ={path = "/Users/gav/Core/substrate/frame/executive" } -frame-system-benchmarking ={path = "/Users/gav/Core/substrate/frame/system/benchmarking" } -pallet-aura ={path = "/Users/gav/Core/substrate/frame/aura" } -pallet-grandpa ={path = "/Users/gav/Core/substrate/frame/grandpa" } -pallet-randomness-collective-flip ={path = "/Users/gav/Core/substrate/frame/randomness-collective-flip" } -pallet-sudo ={path = "/Users/gav/Core/substrate/frame/sudo" } -pallet-template ={path = "/Users/gav/Core/substrate/bin/node-template/pallets/template" } -pallet-transaction-payment-rpc-runtime-api ={path = "/Users/gav/Core/substrate/frame/transaction-payment/rpc/runtime-api" } -pallet-transaction-payment-rpc ={path = "/Users/gav/Core/substrate/frame/transaction-payment/rpc" } -sc-basic-authorship ={path = "/Users/gav/Core/substrate/client/basic-authorship" } -sc-proposer-metrics ={path = "/Users/gav/Core/substrate/client/proposer-metrics" } -sc-consensus-aura ={path = "/Users/gav/Core/substrate/client/consensus/aura" } -sc-consensus-slots ={path = "/Users/gav/Core/substrate/client/consensus/slots" } -sc-network-test ={path = "/Users/gav/Core/substrate/client/network/test" } -sc-finality-grandpa ={path = "/Users/gav/Core/substrate/client/finality-grandpa" } -sc-network-gossip ={path = "/Users/gav/Core/substrate/client/network-gossip" } -substrate-frame-rpc-system ={path = "/Users/gav/Core/substrate/utils/frame/rpc/system" } -substrate-build-script-utils ={path = "/Users/gav/Core/substrate/utils/build-script-utils" } -node-bench ={path = "/Users/gav/Core/substrate/bin/node/bench" } -node-primitives ={path = "/Users/gav/Core/substrate/bin/node/primitives" } -node-runtime ={path = "/Users/gav/Core/substrate/bin/node/runtime" } -frame-try-runtime ={path = "/Users/gav/Core/substrate/frame/try-runtime" } -pallet-assets ={path = "/Users/gav/Core/substrate/frame/assets" } -pallet-authority-discovery ={path = "/Users/gav/Core/substrate/frame/authority-discovery" } -sp-authority-discovery ={path = "/Users/gav/Core/substrate/primitives/authority-discovery" } -pallet-bounties ={path = "/Users/gav/Core/substrate/frame/bounties" } -pallet-treasury ={path = "/Users/gav/Core/substrate/frame/treasury" } -pallet-collective ={path = "/Users/gav/Core/substrate/frame/collective" } -pallet-contracts ={path = "/Users/gav/Core/substrate/frame/contracts" } -pallet-contracts-primitives ={path = "/Users/gav/Core/substrate/frame/contracts/common" } -pallet-contracts-proc-macro ={path = "/Users/gav/Core/substrate/frame/contracts/proc-macro" } -pallet-utility ={path = "/Users/gav/Core/substrate/frame/utility" } -pallet-contracts-rpc-runtime-api ={path = "/Users/gav/Core/substrate/frame/contracts/rpc/runtime-api" } -pallet-democracy ={path = "/Users/gav/Core/substrate/frame/democracy" } -pallet-scheduler ={path = "/Users/gav/Core/substrate/frame/scheduler" } -pallet-election-provider-multi-phase ={path = "/Users/gav/Core/substrate/frame/election-provider-multi-phase" } -pallet-elections-phragmen ={path = "/Users/gav/Core/substrate/frame/elections-phragmen" } -pallet-gilt ={path = "/Users/gav/Core/substrate/frame/gilt" } -pallet-identity ={path = "/Users/gav/Core/substrate/frame/identity" } -pallet-im-online ={path = "/Users/gav/Core/substrate/frame/im-online" } -pallet-indices ={path = "/Users/gav/Core/substrate/frame/indices" } -pallet-lottery ={path = "/Users/gav/Core/substrate/frame/lottery" } -frame-support-test ={path = "/Users/gav/Core/substrate/frame/support/test" } -frame-support-test-pallet ={path = "/Users/gav/Core/substrate/frame/support/test/pallet" } -pallet-membership ={path = "/Users/gav/Core/substrate/frame/membership" } -pallet-mmr ={path = "/Users/gav/Core/substrate/frame/merkle-mountain-range" } -pallet-mmr-primitives ={path = "/Users/gav/Core/substrate/frame/merkle-mountain-range/primitives" } -pallet-multisig ={path = "/Users/gav/Core/substrate/frame/multisig" } -pallet-offences-benchmarking ={path = "/Users/gav/Core/substrate/frame/offences/benchmarking" } -pallet-proxy ={path = "/Users/gav/Core/substrate/frame/proxy" } -pallet-recovery ={path = "/Users/gav/Core/substrate/frame/recovery" } -pallet-session-benchmarking ={path = "/Users/gav/Core/substrate/frame/session/benchmarking" } -pallet-society ={path = "/Users/gav/Core/substrate/frame/society" } -pallet-tips ={path = "/Users/gav/Core/substrate/frame/tips" } -pallet-transaction-storage ={path = "/Users/gav/Core/substrate/frame/transaction-storage" } -pallet-uniques ={path = "/Users/gav/Core/substrate/frame/uniques" } -pallet-vesting ={path = "/Users/gav/Core/substrate/frame/vesting" } -node-testing ={path = "/Users/gav/Core/substrate/bin/node/testing" } -node-executor ={path = "/Users/gav/Core/substrate/bin/node/executor" } -node-cli ={path = "/Users/gav/Core/substrate/bin/node/cli" } -node-inspect ={path = "/Users/gav/Core/substrate/bin/node/inspect" } -node-rpc ={path = "/Users/gav/Core/substrate/bin/node/rpc" } -pallet-contracts-rpc ={path = "/Users/gav/Core/substrate/frame/contracts/rpc" } -pallet-mmr-rpc ={path = "/Users/gav/Core/substrate/frame/merkle-mountain-range/rpc" } -sc-consensus-babe ={path = "/Users/gav/Core/substrate/client/consensus/babe" } -sc-consensus-epochs ={path = "/Users/gav/Core/substrate/client/consensus/epochs" } -sc-consensus-babe-rpc ={path = "/Users/gav/Core/substrate/client/consensus/babe/rpc" } -sc-finality-grandpa-rpc ={path = "/Users/gav/Core/substrate/client/finality-grandpa/rpc" } -sc-sync-state-rpc ={path = "/Users/gav/Core/substrate/client/sync-state-rpc" } -sc-authority-discovery ={path = "/Users/gav/Core/substrate/client/authority-discovery" } -sc-consensus-uncles ={path = "/Users/gav/Core/substrate/client/consensus/uncles" } -try-runtime-cli ={path = "/Users/gav/Core/substrate/utils/frame/try-runtime/cli" } -remote-externalities ={path = "/Users/gav/Core/substrate/utils/frame/remote-externalities" } -sc-service-test ={path = "/Users/gav/Core/substrate/client/service/test" } -substrate-frame-cli ={path = "/Users/gav/Core/substrate/utils/frame/frame-utilities-cli" } -test-runner-example ={path = "/Users/gav/Core/substrate/bin/node/test-runner-example" } -sc-consensus-manual-seal ={path = "/Users/gav/Core/substrate/client/consensus/manual-seal" } -test-runner ={path = "/Users/gav/Core/substrate/test-utils/test-runner" } -node-rpc-client ={path = "/Users/gav/Core/substrate/bin/node/rpc-client" } -chain-spec-builder ={path = "/Users/gav/Core/substrate/bin/utils/chain-spec-builder" } -subkey ={path = "/Users/gav/Core/substrate/bin/utils/subkey" } -beefy-gadget ={path = "/Users/gav/Core/substrate/client/beefy" } -beefy-primitives ={path = "/Users/gav/Core/substrate/primitives/beefy" } -beefy-gadget-rpc ={path = "/Users/gav/Core/substrate/client/beefy/rpc" } -sc-consensus-pow ={path = "/Users/gav/Core/substrate/client/consensus/pow" } -sp-consensus-pow ={path = "/Users/gav/Core/substrate/primitives/consensus/pow" } -pallet-atomic-swap ={path = "/Users/gav/Core/substrate/frame/atomic-swap" } -pallet-beefy ={path = "/Users/gav/Core/substrate/frame/beefy" } -pallet-beefy-mmr ={path = "/Users/gav/Core/substrate/frame/beefy-mmr" } -beefy-merkle-tree ={path = "/Users/gav/Core/substrate/frame/beefy-mmr/primitives" } -pallet-elections ={path = "/Users/gav/Core/substrate/frame/elections" } -pallet-example ={path = "/Users/gav/Core/substrate/frame/example" } -pallet-example-offchain-worker ={path = "/Users/gav/Core/substrate/frame/example-offchain-worker" } -pallet-example-parallel ={path = "/Users/gav/Core/substrate/frame/example-parallel" } -pallet-nicks ={path = "/Users/gav/Core/substrate/frame/nicks" } -pallet-node-authorization ={path = "/Users/gav/Core/substrate/frame/node-authorization" } -pallet-scored-pool ={path = "/Users/gav/Core/substrate/frame/scored-pool" } -pallet-staking-reward-fn ={path = "/Users/gav/Core/substrate/frame/staking/reward-fn" } -sp-api-test ={path = "/Users/gav/Core/substrate/primitives/api/test" } -sp-application-crypto-test ={path = "/Users/gav/Core/substrate/primitives/application-crypto/test" } -sp-arithmetic-fuzzer ={path = "/Users/gav/Core/substrate/primitives/arithmetic/fuzzer" } -sp-npos-elections-fuzzer ={path = "/Users/gav/Core/substrate/primitives/npos-elections/fuzzer" } -sp-runtime-interface-test ={path = "/Users/gav/Core/substrate/primitives/runtime-interface/test" } -sp-runtime-interface-test-wasm-deprecated ={path = "/Users/gav/Core/substrate/primitives/runtime-interface/test-wasm-deprecated" } -substrate-test-utils-test-crate ={path = "/Users/gav/Core/substrate/test-utils/test-crate" } -substrate-frame-rpc-support ={path = "/Users/gav/Core/substrate/utils/frame/rpc/support" } -generate-bags ={path = "/Users/gav/Core/substrate/utils/frame/generate-bags" } -node-runtime-generate-bags ={path = "/Users/gav/Core/substrate/utils/frame/generate-bags/node-runtime" } # Configuration for building a .deb package - for use with `cargo-deb` [package.metadata.deb] diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index b6f4d7b1e2d3..592ef96dd7d7 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -663,9 +663,8 @@ pub enum Instruction { /// Kind: *Instruction* /// /// Errors: - /// - `ExpectationFalse`: If Origin Register is not some value, or if that value is not equal to - /// the parameter. - ExpectOrigin(MultiLocation), + /// - `ExpectationFalse`: If Origin Register is not equal to the parameter. + ExpectOrigin(Option), /// Ensure that the Error Register equals some given value and throw an error if not. /// diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 4d2b0453a7af..fc1cd692cd5b 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -429,7 +429,7 @@ pub trait XcmWeightInfo { fn expect_asset(_assets: &MultiAssets) -> Weight { 0 } - fn expect_origin(_origin: &MultiLocation) -> Weight { + fn expect_origin(_origin: &Option) -> Weight { 0 } fn expect_error(_error: &Option<(u32, Error)>) -> Weight { diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 3d422308cc11..322968832da2 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -461,8 +461,7 @@ impl XcmExecutor { ExpectAsset(assets) => self.holding.ensure_contains(&assets).map_err(|_| XcmError::ExpectationFalse), ExpectOrigin(origin) => { - let origin_ref = self.origin.as_ref().ok_or(XcmError::ExpectationFalse)?; - ensure!(origin_ref == &origin, XcmError::ExpectationFalse); + ensure!(self.origin == origin, XcmError::ExpectationFalse); Ok(()) }, ExpectError(error) => { From b6cb3366cc321736b587df060bb67564c550273d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 11:38:24 +0200 Subject: [PATCH 013/231] Fixes --- xcm/xcm-builder/src/mock.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index 4efc02b7e191..37d5ebb12737 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -340,4 +340,5 @@ impl Config for TestConfig { type AssetTrap = TestAssetTrap; type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; + type PalletInstancesInfo = (); // TODO: TestAllPallets, for testing new instructions. } From e7e90f831de2a6068162c7c8c3c78dec1395d4ac Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 11:41:15 +0200 Subject: [PATCH 014/231] Docs --- xcm/src/v3/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 592ef96dd7d7..5bcd305fe534 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -643,11 +643,13 @@ pub enum Instruction { /// Reduce Holding by up to the given assets. /// - /// Holding is reduced by up to the assets in the parameter. If this is less than the + /// Holding is reduced by as much as possible up to the assets in the parameter. It is not an + /// error if the Holding does not contain the assets (to make this an error, use `ExpectAsset` + /// prior). /// /// Kind: *Instruction* /// - /// Errors: *Fallible* + /// Errors: *Infallible* BurnAsset(MultiAssets), /// Throw an error if Holding does not contain at least the given assets. From a7869c8a473cbcd396cf87782b4178b946342c88 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 13:30:27 +0200 Subject: [PATCH 015/231] Ditch Dispatch in favor of composition --- runtime/westend/src/weights/xcm/mod.rs | 2 +- xcm/src/v0/traits.rs | 2 +- xcm/src/v1/traits.rs | 2 +- xcm/src/v2/mod.rs | 4 +- xcm/src/v3/mod.rs | 134 +++++++++++-------------- xcm/src/v3/traits.rs | 17 ++-- xcm/xcm-builder/src/tests.rs | 8 +- xcm/xcm-executor/src/lib.rs | 92 ++++++----------- 8 files changed, 107 insertions(+), 154 deletions(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 70c5731a7853..7c3f38306537 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -4,7 +4,7 @@ mod pallet_xcm_benchmarks_generic; use crate::Runtime; use frame_support::weights::Weight; use sp_std::prelude::*; -use xcm::{latest::prelude::*, DoubleEncoded}; +use xcm::{DoubleEncoded, latest::{QueryResponseInfo, prelude::*}}; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; diff --git a/xcm/src/v0/traits.rs b/xcm/src/v0/traits.rs index 3263fda4ac56..472f0c7aea93 100644 --- a/xcm/src/v0/traits.rs +++ b/xcm/src/v0/traits.rs @@ -223,7 +223,7 @@ impl ExecuteXcm for () { /// // A call to send via XCM. We don't really care about this. /// # fn main() { /// let call: Vec = ().encode(); -/// let message = Xcm::Transact { origin_type: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; +/// let message = Xcm::Transact { origin_kind: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; /// let destination = MultiLocation::X1(Junction::Parent); /// /// assert!( diff --git a/xcm/src/v1/traits.rs b/xcm/src/v1/traits.rs index d95d9e1eb84a..b0be0132c2de 100644 --- a/xcm/src/v1/traits.rs +++ b/xcm/src/v1/traits.rs @@ -238,7 +238,7 @@ impl ExecuteXcm for () { /// // A call to send via XCM. We don't really care about this. /// # fn main() { /// let call: Vec = ().encode(); -/// let message = Xcm::Transact { origin_type: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; +/// let message = Xcm::Transact { origin_kind: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; /// /// assert!( /// // Sender2 will block this. diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index c4643fc0becc..bedf5cc1f2c9 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -907,8 +907,8 @@ impl TryFrom> for Instruction { HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient }, HrmpChannelClosing { initiator, sender, recipient } => Self::HrmpChannelClosing { initiator, sender, recipient }, - Transact { origin_type, require_weight_at_most, call } => - Self::Transact { origin_type, require_weight_at_most, call: call.into() }, + Transact { origin_kind, require_weight_at_most, call } => + Self::Transact { origin_type: origin_kind, require_weight_at_most, call: call.into() }, ReportError { query_id, dest, max_response_weight } => Self::ReportError { query_id, dest, max_response_weight }, DepositAsset { assets, max_assets, beneficiary } => diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 5bcd305fe534..1c1759edf101 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -165,6 +165,12 @@ pub enum MaybeErrorCode { Error(Vec), } +impl Default for MaybeErrorCode { + fn default() -> MaybeErrorCode { + MaybeErrorCode::Success + } +} + /// Response data to a query. #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] pub enum Response { @@ -178,7 +184,7 @@ pub enum Response { Version(super::Version), /// The index, instance name, pallet name and version of some pallets. PalletsInfo(Vec), - /// The error of a dispatch attempt, or `None` if the dispatch executed without error. + /// The status of a dispatch attempt using `Transact`. DispatchResult(MaybeErrorCode), } @@ -306,9 +312,11 @@ pub enum Instruction { /// Apply the encoded transaction `call`, whose dispatch-origin should be `origin` as expressed /// by the kind of origin `origin_type`. /// - /// - `origin_type`: The means of expressing the message origin as a dispatch origin. - /// - `max_weight`: The weight of `call`; this should be at least the chain's calculated weight - /// and will be used in the weight determination arithmetic. + /// The Transact Status Register is set according to the result of dispatching the call. + /// + /// - `origin_kind`: The means of expressing the message origin as a dispatch origin. + /// - `require_weight_at_most`: The weight of `call`; this should be at least the chain's + /// calculated weight and will be used in the weight determination arithmetic. /// - `call`: The encoded transaction to be applied. /// /// Safety: No concerns. @@ -317,7 +325,7 @@ pub enum Instruction { /// /// Errors: Transact { - origin_type: OriginKind, + origin_kind: OriginKind, #[codec(compact)] require_weight_at_most: u64, call: DoubleEncoded, @@ -692,44 +700,52 @@ pub enum Instruction { /// Errors: *Fallible*. QueryPallet { name: Vec, response_info: QueryResponseInfo }, - /// Dispatch a call into a pallet in the Frame system. This provides a means of ensuring that - /// the pallet continues to exist with a known version. + /// Ensure that a particular pallet with a particular version exists. /// - /// - `origin_kind`: The means of expressing the message origin as a dispatch origin. - /// - `name`: The name of the pallet to which to dispatch a message. - /// - `major`, `minor`: The major and minor version of the pallet. The major version - /// must be equal and the minor version of the pallet must be at least as great. - /// - `pallet_index`: The index of the pallet to be called. - /// - `call_index`: The index of the dispatchable to be called. - /// - `params`: The encoded parameters of the dispatchable. - /// - `query_id`: If present, then a `QueryResponse` - /// whose `query_id` and `max_weight` are the given `QueryId`and `Weight` values is sent to - /// the given `MultiLocation` value with a `DispatchResult` response corresponding to the - /// error status of the "inner" dispatch. This only happens if the dispatch was actually - /// made - if an error happened prior to dispatch, then the Error Register is set and the - /// operation aborted as usual. + /// - `index: Compact`: The index which identifies the pallet. An error if no pallet exists at this index. + /// - `name: Vec`: Name which must be equal to the name of the pallet. + /// - `module_name: Vec`: Module name which must be equal to the name of the module in which the pallet exists. + /// - `crate_major: Compact`: Version number which must be equal to the major version of the crate which implements the pallet. + /// - `min_crate_minor: Compact`: Version number which must be at most the minor version of the crate which implements the pallet. /// /// Safety: No concerns. /// /// Kind: *Instruction* /// - /// Errors: *Fallible*. - Dispatch { - origin_kind: OriginKind, + /// Errors: + /// - `ExpectationFalse`: In case any of the expectations are broken. + ExpectPallet { #[codec(compact)] - require_weight_at_most: Weight, + index: u32, name: Vec, + module_name: Vec, #[codec(compact)] - major: u32, - #[codec(compact)] - minor: u32, - #[codec(compact)] - pallet_index: u32, + crate_major: u32, #[codec(compact)] - call_index: u32, - params: Vec, - response_info: Option, + min_crate_minor: u32, }, + + /// Send a `QueryRepsonse` message containing the value of the Transact Status Register to some + /// destination. + /// + /// - `query_response_info`: The information needed for constructing and sending the + /// `QueryResponse` message. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction* + /// + /// Errors: *Fallible*. + ReportTransactStatus(QueryResponseInfo), + + /// Set the Transact Status Register to its default, cleared, value. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction* + /// + /// Errors: *Infallible*. + ClearTransactStatus, } impl Xcm { @@ -761,8 +777,8 @@ impl Instruction { HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient }, HrmpChannelClosing { initiator, sender, recipient } => HrmpChannelClosing { initiator, sender, recipient }, - Transact { origin_type, require_weight_at_most, call } => - Transact { origin_type, require_weight_at_most, call: call.into() }, + Transact { origin_kind, require_weight_at_most, call } => + Transact { origin_kind, require_weight_at_most, call: call.into() }, ReportError { query_id, dest, max_response_weight } => ReportError { query_id, dest, max_response_weight }, DepositAsset { assets, max_assets, beneficiary } => @@ -792,27 +808,10 @@ impl Instruction { ExpectOrigin(origin) => ExpectOrigin(origin), ExpectError(error) => ExpectError(error), QueryPallet { name, response_info } => QueryPallet { name, response_info }, - Dispatch { - origin_kind, - require_weight_at_most, - name, - major, - minor, - pallet_index, - call_index, - params, - response_info, - } => Dispatch { - origin_kind, - require_weight_at_most, - name, - major, - minor, - pallet_index, - call_index, - params, - response_info, - }, + ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => + ExpectPallet { index, name, module_name, crate_major, min_crate_minor }, + ReportTransactStatus(repsonse_info) => ReportTransactStatus(repsonse_info), + ClearTransactStatus => ClearTransactStatus, } } } @@ -830,8 +829,8 @@ impl> GetWeight for Instruction { TransferAsset { assets, beneficiary } => W::transfer_asset(assets, beneficiary), TransferReserveAsset { assets, dest, xcm } => W::transfer_reserve_asset(&assets, dest, xcm), - Transact { origin_type, require_weight_at_most, call } => - W::transact(origin_type, require_weight_at_most, call), + Transact { origin_kind, require_weight_at_most, call } => + W::transact(origin_kind, require_weight_at_most, call), HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity), HrmpChannelAccepted { recipient } => W::hrmp_channel_accepted(recipient), @@ -866,22 +865,9 @@ impl> GetWeight for Instruction { ExpectOrigin(origin) => W::expect_origin(origin), ExpectError(error) => W::expect_error(error), QueryPallet { .. } => W::query_pallet(), - Dispatch { - origin_kind, - require_weight_at_most, - pallet_index, - call_index, - params, - response_info, - .. - } => W::dispatch( - origin_kind, - require_weight_at_most, - pallet_index, - call_index, - params, - response_info, - ), + ExpectPallet { index, .. } => W::expect_pallet(index), + ReportTransactStatus(response_info) => W::report_transact_status(response_info), + ClearTransactStatus => W::clear_transact_status(), } } } @@ -940,7 +926,7 @@ impl TryFrom> for Instruction { HrmpChannelClosing { initiator, sender, recipient } => Self::HrmpChannelClosing { initiator, sender, recipient }, Transact { origin_type, require_weight_at_most, call } => - Self::Transact { origin_type, require_weight_at_most, call: call.into() }, + Self::Transact { origin_kind: origin_type, require_weight_at_most, call: call.into() }, ReportError { query_id, dest, max_response_weight } => Self::ReportError { query_id, dest, max_response_weight }, DepositAsset { assets, max_assets, beneficiary } => diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index fc1cd692cd5b..bb60e518c6d9 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -438,14 +438,13 @@ pub trait XcmWeightInfo { fn query_pallet() -> Weight { 0 } - fn dispatch( - _origin_kind: &OriginKind, - require_weight_at_most: &Weight, - _pallet_index: &u32, - _call_index: &u32, - _params: &Vec, - _response_info: &Option, - ) -> Weight { - *require_weight_at_most + fn expect_pallet(_pallet_index: &u32) -> Weight { + 0 + } + fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { + 0 + } + fn clear_transact_status() -> Weight { + 0 } } diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index e3e5e24ca1b0..b37f392c8791 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -578,7 +578,7 @@ fn transacting_should_work() { AllowUnpaidFrom::set(vec![Parent.into()]); let message = Xcm::(vec![Transact { - origin_type: OriginKind::Native, + origin_kind: OriginKind::Native, require_weight_at_most: 50, call: TestCall::Any(50, None).encode().into(), }]); @@ -592,7 +592,7 @@ fn transacting_should_respect_max_weight_requirement() { AllowUnpaidFrom::set(vec![Parent.into()]); let message = Xcm::(vec![Transact { - origin_type: OriginKind::Native, + origin_kind: OriginKind::Native, require_weight_at_most: 40, call: TestCall::Any(50, None).encode().into(), }]); @@ -606,7 +606,7 @@ fn transacting_should_refund_weight() { AllowUnpaidFrom::set(vec![Parent.into()]); let message = Xcm::(vec![Transact { - origin_type: OriginKind::Native, + origin_kind: OriginKind::Native, require_weight_at_most: 50, call: TestCall::Any(50, Some(30)).encode().into(), }]); @@ -628,7 +628,7 @@ fn paid_transacting_should_refund_payment_for_unused_weight() { WithdrawAsset((Parent, 100).into()), // enough for 100 units of weight. BuyExecution { fees, weight_limit: Limited(100) }, Transact { - origin_type: OriginKind::Native, + origin_kind: OriginKind::Native, require_weight_at_most: 50, // call estimated at 50 but only takes 10. call: TestCall::Any(50, Some(10)).encode().into(), diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 322968832da2..d60bb3f580ce 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -22,7 +22,7 @@ use frame_support::{ traits::PalletsInfoAccess, weights::GetDispatchInfo, }; -use parity_scale_codec::{Decode, Encode}; +use parity_scale_codec::Encode; use sp_runtime::traits::Saturating; use sp_std::{marker::PhantomData, prelude::*}; use xcm::latest::{ @@ -62,6 +62,7 @@ pub struct XcmExecutor { pub error_handler_weight: u64, pub appendix: Xcm, pub appendix_weight: u64, + pub transact_status: MaybeErrorCode, _config: PhantomData, } @@ -167,6 +168,7 @@ impl XcmExecutor { error_handler_weight: 0, appendix: Xcm(vec![]), appendix_weight: 0, + transact_status: Default::default(), _config: PhantomData, } } @@ -299,25 +301,27 @@ impl XcmExecutor { } Ok(()) }, - Transact { origin_type, require_weight_at_most, mut call } => { + Transact { origin_kind, require_weight_at_most, mut call } => { // We assume that the Relay-chain is allowed to use transact on this parachain. let origin = self.origin.clone().ok_or(XcmError::BadOrigin)?; // TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain let message_call = call.take_decoded().map_err(|_| XcmError::FailedToDecode)?; - let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_type) + let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_kind) .map_err(|_| XcmError::BadOrigin)?; let weight = message_call.get_dispatch_info().weight; ensure!(weight <= require_weight_at_most, XcmError::TooMuchWeightRequired); - let actual_weight = match message_call.dispatch(dispatch_origin) { - Ok(post_info) => post_info.actual_weight, + let maybe_actual_weight = match message_call.dispatch(dispatch_origin) { + Ok(post_info) => { + self.transact_status = MaybeErrorCode::Success; + post_info.actual_weight + }, Err(error_and_info) => { - // Not much to do with the result as it is. It's up to the parachain to ensure that the - // message makes sense. + self.transact_status = MaybeErrorCode::Error(error_and_info.error.encode()); error_and_info.post_info.actual_weight }, - } - .unwrap_or(weight); + }; + let actual_weight = maybe_actual_weight.unwrap_or(weight); let surplus = weight.saturating_sub(actual_weight); // We assume that the `Config::Weigher` will counts the `require_weight_at_most` // for the estimate of how much weight this instruction will take. Now that we know @@ -487,65 +491,29 @@ impl XcmExecutor { let message = Xcm(vec![instruction]); Config::XcmSender::send_xcm(destination, message).map_err(Into::into) }, - Dispatch { - origin_kind, - require_weight_at_most, - name, - major, - minor, - pallet_index, - call_index, - params, - response_info, - } => { - let origin = self.origin.clone().ok_or(XcmError::BadOrigin)?; - + ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => { let pallet = Config::PalletInstancesInfo::infos() .into_iter() - .find(|x| x.index == pallet_index as usize) + .find(|x| x.index == index as usize) .ok_or(XcmError::PalletNotFound)?; ensure!(pallet.name.as_bytes() == &name[..], XcmError::NameMismatch); - ensure!(pallet.crate_version.major as u32 == major, XcmError::VersionIncompatible); - ensure!(pallet.crate_version.minor as u32 >= minor, XcmError::VersionIncompatible); - - // TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain - let mut encoded_call = vec![pallet_index as u8, call_index as u8]; - encoded_call.extend(params); - let message_call = Config::Call::decode(&mut &encoded_call[..]) - .map_err(|_| XcmError::FailedToDecode)?; - - let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_kind) - .map_err(|_| XcmError::BadOrigin)?; - let weight = message_call.get_dispatch_info().weight; - ensure!(weight <= require_weight_at_most, XcmError::TooMuchWeightRequired); - let (actual_weight, error_code) = match message_call.dispatch(dispatch_origin) { - Ok(post_info) => (post_info.actual_weight, MaybeErrorCode::Success), - Err(error_and_info) => { - let error = MaybeErrorCode::Error(error_and_info.error.encode()); - let actual_weight = error_and_info.post_info.actual_weight; - (actual_weight, error) - }, - }; - let actual_weight = actual_weight.unwrap_or(weight); - let surplus = weight.saturating_sub(actual_weight); - // We assume that the `Config::Weigher` will counts the `require_weight_at_most` - // for the estimate of how much weight this instruction will take. Now that we know - // that it's less, we credit it. - // - // We make the adjustment for the total surplus, which is used eventually - // reported back to the caller and this ensures that they account for the total - // weight consumed correctly (potentially allowing them to do more operations in a - // block than they otherwise would). - self.total_surplus.saturating_accrue(surplus); - if let Some(QueryResponseInfo { destination, query_id, max_weight }) = response_info - { - let response = Response::DispatchResult(error_code); - let instruction = QueryResponse { query_id, response, max_weight }; - let message = Xcm(vec![instruction]); - Config::XcmSender::send_xcm(destination, message).map_err(XcmError::from)?; - } + ensure!(pallet.module_name.as_bytes() == &module_name[..], XcmError::NameMismatch); + let major = pallet.crate_version.major as u32; + ensure!(major == crate_major, XcmError::VersionIncompatible); + let minor = pallet.crate_version.minor as u32; + ensure!(minor >= min_crate_minor, XcmError::VersionIncompatible); Ok(()) }, + ReportTransactStatus(QueryResponseInfo { destination, query_id, max_weight }) => { + let response = Response::DispatchResult(self.transact_status.clone()); + let instruction = QueryResponse { query_id, response, max_weight }; + let message = Xcm(vec![instruction]); + Config::XcmSender::send_xcm(destination, message).map_err(XcmError::from) + } + ClearTransactStatus => { + self.transact_status = Default::default(); + Ok(()) + } ExchangeAsset { .. } => Err(XcmError::Unimplemented), HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), From 5666b58fae867cafd06bbe955da1f4c0422f9855 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 13:55:30 +0200 Subject: [PATCH 016/231] Ditch Dispatch in favor of composition --- runtime/westend/src/weights/xcm/mod.rs | 8 +-- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- xcm/src/v2/mod.rs | 15 ++-- xcm/src/v3/mod.rs | 70 ++++++++----------- xcm/src/v3/traits.rs | 8 +-- xcm/xcm-executor/src/lib.rs | 29 ++++---- 6 files changed, 62 insertions(+), 70 deletions(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 7c3f38306537..3c5715d72e51 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -115,9 +115,7 @@ impl XcmWeightInfo for WestendXcmWeight { XcmGeneric::::descend_origin(who) } fn report_error( - _query_id: &QueryId, - _dest: &MultiLocation, - _max_response_weight: &u64, + _query_repsonse_info: &QueryResponseInfo, ) -> Weight { XcmGeneric::::report_error() } @@ -157,13 +155,13 @@ impl XcmWeightInfo for WestendXcmWeight { ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } - fn query_holding( + fn report_holding( _query_id: &u64, _dest: &MultiLocation, _assets: &MultiAssetFilter, _max_response_weight: &u64, ) -> Weight { - XcmGeneric::::query_holding() + XcmGeneric::::report_holding() } fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 5c8626f0b22a..12a72ca61d5b 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -4,7 +4,7 @@ use frame_support::dispatch::Weight; pub struct WeightInfo(sp_std::marker::PhantomData); impl WeightInfo { - pub fn query_holding() -> Weight { + pub fn report_holding() -> Weight { 1_000_000_000 } pub fn buy_execution() -> Weight { diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index bedf5cc1f2c9..eef4870a5a54 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -909,8 +909,11 @@ impl TryFrom> for Instruction { Self::HrmpChannelClosing { initiator, sender, recipient }, Transact { origin_kind, require_weight_at_most, call } => Self::Transact { origin_type: origin_kind, require_weight_at_most, call: call.into() }, - ReportError { query_id, dest, max_response_weight } => - Self::ReportError { query_id, dest, max_response_weight }, + ReportError(response_info) => Self::ReportError { + query_id: response_info.query_id, + dest: response_info.destination, + max_response_weight: response_info.max_weight, + }, DepositAsset { assets, max_assets, beneficiary } => Self::DepositAsset { assets, max_assets, beneficiary }, DepositReserveAsset { assets, max_assets, dest, xcm } => @@ -920,8 +923,12 @@ impl TryFrom> for Instruction { Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? }, InitiateTeleport { assets, dest, xcm } => Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? }, - QueryHolding { query_id, dest, assets, max_response_weight } => - Self::QueryHolding { query_id, dest, assets, max_response_weight }, + ReportHolding { response_info, assets } => Self::QueryHolding { + query_id: response_info.query_id, + dest: response_info.destination, + assets, + max_response_weight: response_info.max_weight, + }, BuyExecution { fees, weight_limit } => Self::BuyExecution { fees, weight_limit }, ClearOrigin => Self::ClearOrigin, DescendOrigin(who) => Self::DescendOrigin(who), diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 1c1759edf101..cc9d39c96639 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -407,25 +407,14 @@ pub enum Instruction { /// Immediately report the contents of the Error Register to the given destination via XCM. /// - /// A `QueryResponse` message of type `ExecutionOutcome` is sent to `dest` with the given - /// `query_id` and the outcome of the XCM. + /// A `QueryResponse` message of type `ExecutionOutcome` is sent to the described destination. /// - /// - `query_id`: An identifier that will be replicated into the returned XCM message. - /// - `dest`: A valid destination for the returned XCM message. - /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which - /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the - /// response may not execute at all. + /// - `response_info`: Information for making the response. /// /// Kind: *Instruction* /// /// Errors: - ReportError { - #[codec(compact)] - query_id: QueryId, - dest: MultiLocation, - #[codec(compact)] - max_response_weight: Weight, - }, + ReportError(QueryResponseInfo), /// Remove the asset(s) (`assets`) from the Holding Register and place equivalent assets under /// the ownership of `beneficiary` within this consensus system. @@ -519,29 +508,21 @@ pub enum Instruction { /// Errors: InitiateTeleport { assets: MultiAssetFilter, dest: MultiLocation, xcm: Xcm<()> }, - /// Send a `Balances` XCM message with the `assets` value equal to the holding contents, or a - /// portion thereof. + /// Report to a given destination the contents of the Holding Register. /// - /// - `query_id`: An identifier that will be replicated into the returned XCM message. - /// - `dest`: A valid destination for the returned XCM message. This may be limited to the - /// current origin. + /// A `QueryResponse` message of type `Assets` is sent to the described destination. + /// + /// - `response_info`: Information for making the response. /// - `assets`: A filter for the assets that should be reported back. The assets reported back /// will be, asset-wise, *the lesser of this value and the holding register*. No wildcards /// will be used when reporting assets back. - /// - `max_response_weight`: The maximum amount of weight that the `QueryResponse` item which - /// is sent as a reply may take to execute. NOTE: If this is unexpectedly large then the - /// response may not execute at all. /// /// Kind: *Instruction* /// /// Errors: - QueryHolding { - #[codec(compact)] - query_id: QueryId, - dest: MultiLocation, + ReportHolding { + response_info: QueryResponseInfo, assets: MultiAssetFilter, - #[codec(compact)] - max_response_weight: Weight, }, /// Pay for the execution of some XCM `xcm` and `orders` with up to `weight` @@ -779,8 +760,7 @@ impl Instruction { HrmpChannelClosing { initiator, sender, recipient }, Transact { origin_kind, require_weight_at_most, call } => Transact { origin_kind, require_weight_at_most, call: call.into() }, - ReportError { query_id, dest, max_response_weight } => - ReportError { query_id, dest, max_response_weight }, + ReportError(response_info) => ReportError(response_info), DepositAsset { assets, max_assets, beneficiary } => DepositAsset { assets, max_assets, beneficiary }, DepositReserveAsset { assets, max_assets, dest, xcm } => @@ -789,8 +769,7 @@ impl Instruction { InitiateReserveWithdraw { assets, reserve, xcm } => InitiateReserveWithdraw { assets, reserve, xcm }, InitiateTeleport { assets, dest, xcm } => InitiateTeleport { assets, dest, xcm }, - QueryHolding { query_id, dest, assets, max_response_weight } => - QueryHolding { query_id, dest, assets, max_response_weight }, + ReportHolding { response_info, assets } => ReportHolding { response_info, assets }, BuyExecution { fees, weight_limit } => BuyExecution { fees, weight_limit }, ClearOrigin => ClearOrigin, DescendOrigin(who) => DescendOrigin(who), @@ -838,8 +817,7 @@ impl> GetWeight for Instruction { W::hrmp_channel_closing(initiator, sender, recipient), ClearOrigin => W::clear_origin(), DescendOrigin(who) => W::descend_origin(who), - ReportError { query_id, dest, max_response_weight } => - W::report_error(query_id, dest, max_response_weight), + ReportError(response_info) => W::report_error(&response_info), DepositAsset { assets, max_assets, beneficiary } => W::deposit_asset(assets, max_assets, beneficiary), DepositReserveAsset { assets, max_assets, dest, xcm } => @@ -848,8 +826,8 @@ impl> GetWeight for Instruction { InitiateReserveWithdraw { assets, reserve, xcm } => W::initiate_reserve_withdraw(assets, reserve, xcm), InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm), - QueryHolding { query_id, dest, assets, max_response_weight } => - W::query_holding(query_id, dest, assets, max_response_weight), + ReportHolding { response_info: QueryResponseInfo, assets } => + W::report_holding(&response_info, &assets), BuyExecution { fees, weight_limit } => W::buy_execution(fees, weight_limit), RefundSurplus => W::refund_surplus(), SetErrorHandler(xcm) => W::set_error_handler(xcm), @@ -927,8 +905,14 @@ impl TryFrom> for Instruction { Self::HrmpChannelClosing { initiator, sender, recipient }, Transact { origin_type, require_weight_at_most, call } => Self::Transact { origin_kind: origin_type, require_weight_at_most, call: call.into() }, - ReportError { query_id, dest, max_response_weight } => - Self::ReportError { query_id, dest, max_response_weight }, + ReportError { query_id, dest, max_response_weight } => { + let response_info = QueryResponseInfo { + destination: dest, + query_id, + max_weight: max_response_weight, + }; + Self::ReportError(response_info) + }, DepositAsset { assets, max_assets, beneficiary } => Self::DepositAsset { assets, max_assets, beneficiary }, DepositReserveAsset { assets, max_assets, dest, xcm } => @@ -938,8 +922,14 @@ impl TryFrom> for Instruction { Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? }, InitiateTeleport { assets, dest, xcm } => Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? }, - QueryHolding { query_id, dest, assets, max_response_weight } => - Self::QueryHolding { query_id, dest, assets, max_response_weight }, + ReportHolding { query_id, dest, assets, max_response_weight } => { + let response_info = QueryResponseInfo { + destination: dest, + query_id, + max_weight: max_response_weight, + }; + Self::ReportHolding { response_info, assets } + }, BuyExecution { fees, weight_limit } => Self::BuyExecution { fees, weight_limit }, ClearOrigin => Self::ClearOrigin, DescendOrigin(who) => Self::DescendOrigin(who), diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index bb60e518c6d9..1dd326802f61 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -388,7 +388,7 @@ pub trait XcmWeightInfo { fn hrmp_channel_closing(initiator: &u32, sender: &u32, recipient: &u32) -> Weight; fn clear_origin() -> Weight; fn descend_origin(who: &InteriorMultiLocation) -> Weight; - fn report_error(query_id: &QueryId, dest: &MultiLocation, max_response_weight: &u64) -> Weight; + fn report_error(response_info: &QueryResponseInfo) -> Weight; fn relayed_from(who: &Junctions, message: &alloc::boxed::Box>) -> Weight; fn deposit_asset( assets: &MultiAssetFilter, @@ -408,11 +408,9 @@ pub trait XcmWeightInfo { xcm: &Xcm<()>, ) -> Weight; fn initiate_teleport(assets: &MultiAssetFilter, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight; - fn query_holding( - query_id: &u64, - dest: &MultiLocation, + fn report_holding( + response_info: &QueryResponseInfo, assets: &MultiAssetFilter, - max_response_weight: &u64, ) -> Weight; fn buy_execution(fees: &MultiAsset, weight_limit: &WeightLimit) -> Weight; fn refund_surplus() -> Weight; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index d60bb3f580ce..7b2c7861b8a1 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -349,13 +349,10 @@ impl XcmExecutor { self.origin = None; Ok(()) }, - ReportError { query_id, dest, max_response_weight: max_weight } => { + ReportError(response_info) => { // Report the given result by sending a QueryResponse XCM to a previously given outcome // destination if one was registered. - let response = Response::ExecutionResult(self.error); - let message = QueryResponse { query_id, response, max_weight }; - Config::XcmSender::send_xcm(dest, Xcm(vec![message]))?; - Ok(()) + Self::respond(Response::ExecutionResult(self.error), response_info) }, DepositAsset { assets, max_assets, beneficiary } => { let deposited = self.holding.limited_saturating_take(assets, max_assets as usize); @@ -391,12 +388,9 @@ impl XcmExecutor { message.extend(xcm.0.into_iter()); Config::XcmSender::send_xcm(dest, Xcm(message)).map_err(Into::into) }, - QueryHolding { query_id, dest, assets, max_response_weight } => { + ReportHolding { response_info: QueryResponseInfo, assets } => { let assets = Self::reanchored(self.holding.min(&assets), &dest)?; - let max_weight = max_response_weight; - let response = Response::Assets(assets); - let instruction = QueryResponse { query_id, response, max_weight }; - Config::XcmSender::send_xcm(dest, Xcm(vec![instruction])).map_err(Into::into) + Self::respond(Response::Assets(assets), response_info) }, BuyExecution { fees, weight_limit } => { // There is no need to buy any weight is `weight_limit` is `Unlimited` since it @@ -504,11 +498,8 @@ impl XcmExecutor { ensure!(minor >= min_crate_minor, XcmError::VersionIncompatible); Ok(()) }, - ReportTransactStatus(QueryResponseInfo { destination, query_id, max_weight }) => { - let response = Response::DispatchResult(self.transact_status.clone()); - let instruction = QueryResponse { query_id, response, max_weight }; - let message = Xcm(vec![instruction]); - Config::XcmSender::send_xcm(destination, message).map_err(XcmError::from) + ReportTransactStatus(response_info) => { + Self::respond(Response::DispatchResult(self.transact_status.clone()), response_info) } ClearTransactStatus => { self.transact_status = Default::default(); @@ -521,6 +512,14 @@ impl XcmExecutor { } } + /// Send a bare `QueryResponse` message containing `response` informed by the given `info`. + fn respond(response: Response, info: QueryResponseInfo) -> Result<(), XcmError> { + let QueryResponseInfo { destination, query_id, max_weight } = info; + let instruction = QueryResponse { query_id, response, max_weight }; + let message = Xcm([instruction]); + Config::XcmSender::send_xcm(destination, message).map_err(Into::into) + } + fn reanchored(mut assets: Assets, dest: &MultiLocation) -> Result { let inv_dest = Config::LocationInverter::invert_location(&dest) .map_err(|()| XcmError::MultiLocationNotInvertible)?; From 8766961c684fa5426a956efe375e37f358fecdf6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 14:10:34 +0200 Subject: [PATCH 017/231] Fixes --- xcm/pallet-xcm/src/lib.rs | 13 ++++++++----- xcm/src/v3/mod.rs | 4 ++-- xcm/xcm-builder/tests/scenarios.rs | 27 ++++++++++----------------- xcm/xcm-executor/src/lib.rs | 6 +++--- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 6456f9ee36b9..00c6c5c274f4 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -40,6 +40,7 @@ use sp_std::{ }; use xcm::prelude::*; use xcm_executor::traits::ConvertOrigin; +use xcm::latest::QueryResponseInfo; use frame_support::PalletId; pub use pallet::*; @@ -970,10 +971,11 @@ pub mod pallet { timeout: T::BlockNumber, ) -> Result { let responder = responder.into(); - let dest = T::LocationInverter::invert_location(&responder) + let destination = T::LocationInverter::invert_location(&responder) .map_err(|()| XcmError::MultiLocationNotInvertible)?; let query_id = Self::new_query(responder, timeout); - let report_error = Xcm(vec![ReportError { dest, query_id, max_response_weight: 0 }]); + let response_info = QueryResponseInfo { destination, query_id, max_weight: 0 }; + let report_error = Xcm(vec![ReportError(response_info)]); message.0.insert(0, SetAppendix(report_error)); Ok(query_id) } @@ -1005,12 +1007,13 @@ pub mod pallet { timeout: T::BlockNumber, ) -> Result<(), XcmError> { let responder = responder.into(); - let dest = T::LocationInverter::invert_location(&responder) + let destination = T::LocationInverter::invert_location(&responder) .map_err(|()| XcmError::MultiLocationNotInvertible)?; let notify: ::Call = notify.into(); - let max_response_weight = notify.get_dispatch_info().weight; + let max_weight = notify.get_dispatch_info().weight; let query_id = Self::new_notify_query(responder, notify, timeout); - let report_error = Xcm(vec![ReportError { dest, query_id, max_response_weight }]); + let response_info = QueryResponseInfo { destination, query_id, max_weight }; + let report_error = Xcm(vec![ReportError(response_info)]); message.0.insert(0, SetAppendix(report_error)); Ok(()) } diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index cc9d39c96639..51cdcfedc828 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -826,7 +826,7 @@ impl> GetWeight for Instruction { InitiateReserveWithdraw { assets, reserve, xcm } => W::initiate_reserve_withdraw(assets, reserve, xcm), InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm), - ReportHolding { response_info: QueryResponseInfo, assets } => + ReportHolding { response_info, assets } => W::report_holding(&response_info, &assets), BuyExecution { fees, weight_limit } => W::buy_execution(fees, weight_limit), RefundSurplus => W::refund_surplus(), @@ -922,7 +922,7 @@ impl TryFrom> for Instruction { Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? }, InitiateTeleport { assets, dest, xcm } => Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? }, - ReportHolding { query_id, dest, assets, max_response_weight } => { + QueryHolding { query_id, dest, assets, max_response_weight } => { let response_info = QueryResponseInfo { destination: dest, query_id, diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index 077a6590d576..5a9369fb1d59 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -21,7 +21,7 @@ use mock::{ }; use polkadot_parachain::primitives::Id as ParaId; use sp_runtime::traits::AccountIdConversion; -use xcm::latest::prelude::*; +use xcm::latest::{QueryResponseInfo, prelude::*}; use xcm_executor::XcmExecutor; pub const ALICE: AccountId = AccountId::new([0u8; 32]); @@ -82,9 +82,12 @@ fn query_holding_works() { kusama_like_with_balances(balances).execute_with(|| { let other_para_id = 3000; let amount = REGISTER_AMOUNT; - let query_id = 1234; let weight = 4 * BaseXcmWeight::get(); - let max_response_weight = 1_000_000_000; + let response_info = QueryResponseInfo { + destination: Parachain(PARA_ID).into(), + query_id: 1234, + max_weight: 1_000_000_000, + }; let r = XcmExecutor::::execute_xcm( Parachain(PARA_ID).into(), Xcm(vec![ @@ -96,12 +99,7 @@ fn query_holding_works() { beneficiary: OnlyChild.into(), // invalid destination }, // is not triggered becasue the deposit fails - QueryHolding { - query_id, - dest: Parachain(PARA_ID).into(), - assets: All.into(), - max_response_weight, - }, + ReportHolding { response_info: response_info.clone(), assets: All.into() }, ]), weight, ); @@ -128,12 +126,7 @@ fn query_holding_works() { beneficiary: Parachain(other_para_id).into(), }, // used to get a notification in case of success - QueryHolding { - query_id, - dest: Parachain(PARA_ID).into(), - assets: All.into(), - max_response_weight: 1_000_000_000, - }, + ReportHolding { response_info: response_info.clone(), assets: All.into() }, ]), weight, ); @@ -146,9 +139,9 @@ fn query_holding_works() { vec![( Parachain(PARA_ID).into(), Xcm(vec![QueryResponse { - query_id, + query_id: response_info.query_id, response: Response::Assets(vec![].into()), - max_weight: 1_000_000_000, + max_weight: response_info.max_weight, }]), )] ); diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 7b2c7861b8a1..5aeacf5be9b8 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -388,8 +388,8 @@ impl XcmExecutor { message.extend(xcm.0.into_iter()); Config::XcmSender::send_xcm(dest, Xcm(message)).map_err(Into::into) }, - ReportHolding { response_info: QueryResponseInfo, assets } => { - let assets = Self::reanchored(self.holding.min(&assets), &dest)?; + ReportHolding { response_info, assets } => { + let assets = Self::reanchored(self.holding.min(&assets), &response_info.destination)?; Self::respond(Response::Assets(assets), response_info) }, BuyExecution { fees, weight_limit } => { @@ -516,7 +516,7 @@ impl XcmExecutor { fn respond(response: Response, info: QueryResponseInfo) -> Result<(), XcmError> { let QueryResponseInfo { destination, query_id, max_weight } = info; let instruction = QueryResponse { query_id, response, max_weight }; - let message = Xcm([instruction]); + let message = Xcm(vec![instruction]); Config::XcmSender::send_xcm(destination, message).map_err(Into::into) } From 6c69d8b09fa882bfb0eeb34710d2aac1f5efd2ef Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 20:10:41 +0200 Subject: [PATCH 018/231] =?UTF-8?q?Remove=20max=5Fassets=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xcm/pallet-xcm/src/lib.rs | 13 +++- xcm/src/v1/multiasset.rs | 23 ++++++ xcm/src/v2/mod.rs | 31 +++++--- xcm/src/v3/mod.rs | 62 +++++++-------- xcm/src/v3/traits.rs | 2 - xcm/xcm-builder/src/filter_asset_location.rs | 2 +- xcm/xcm-builder/src/mock.rs | 4 +- xcm/xcm-builder/src/tests.rs | 33 ++++---- xcm/xcm-builder/tests/scenarios.rs | 20 ++--- xcm/xcm-executor/src/assets.rs | 82 ++++++++++++-------- xcm/xcm-executor/src/lib.rs | 8 +- 11 files changed, 158 insertions(+), 122 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 00c6c5c274f4..60486c056e08 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -491,9 +491,14 @@ pub mod pallet { match (maybe_assets, maybe_dest) { (Ok(assets), Ok(dest)) => { use sp_std::vec; + let count = assets.len() as u32; let mut message = Xcm(vec![ WithdrawAsset(assets), - InitiateTeleport { assets: Wild(All), dest, xcm: Xcm(vec![]) }, + InitiateTeleport { + assets: Wild(AllCounted(count)), + dest, + xcm: Xcm(vec![]), + }, ]); T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000 + w) }, @@ -529,7 +534,7 @@ pub mod pallet { let assets = assets.into(); let mut remote_message = Xcm(vec![ BuyExecution { fees, weight_limit: Limited(0) }, - DepositAsset { assets: Wild(All), max_assets, beneficiary }, + DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, ]); // use local weight for remote message and hope for the best. let remote_weight = T::Weigher::weight(&mut remote_message) @@ -541,7 +546,7 @@ pub mod pallet { } let mut message = Xcm(vec![ WithdrawAsset(assets), - InitiateTeleport { assets: Wild(All), dest, xcm: remote_message.into() }, + InitiateTeleport { assets: Wild(AllCounted(max_assets)), dest, xcm: remote_message.into() }, ]); let weight = T::Weigher::weight(&mut message).map_err(|()| Error::::UnweighableMessage)?; @@ -605,7 +610,7 @@ pub mod pallet { let assets = assets.into(); let mut remote_message = Xcm(vec![ BuyExecution { fees, weight_limit: Limited(0) }, - DepositAsset { assets: Wild(All), max_assets, beneficiary }, + DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, ]); // use local weight for remote message and hope for the best. let remote_weight = T::Weigher::weight(&mut remote_message) diff --git a/xcm/src/v1/multiasset.rs b/xcm/src/v1/multiasset.rs index 129c5731542f..3b09612ffcb0 100644 --- a/xcm/src/v1/multiasset.rs +++ b/xcm/src/v1/multiasset.rs @@ -23,6 +23,9 @@ //! - `MultiAssetFilter`: A combination of `Wild` and `MultiAssets` designed for efficiently filtering an XCM holding //! account. +use crate::v3::{ + MultiAssetFilter as NewMultiAssetFilter, WildMultiAsset as NewWildMultiAsset, +}; use super::MultiLocation; use alloc::{vec, vec::Vec}; use core::{ @@ -565,3 +568,23 @@ impl TryFrom> for MultiAssetFilter { } } } + +impl From for WildMultiAsset { + fn from(old: NewWildMultiAsset) -> Self { + use NewWildMultiAsset::*; + match old { + AllOf { id, fun } | AllOfCounted { id, fun, .. } => Self::AllOf { id, fun }, + All | AllCounted(_) => Self::All, + } + } +} + +impl From for MultiAssetFilter { + fn from(old: NewMultiAssetFilter) -> Self { + use NewMultiAssetFilter::*; + match old { + Definite(x) => Self::Definite(x), + Wild(x) => Self::Wild(x.into()), + } + } +} diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index eef4870a5a54..f465ab44edf7 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -914,19 +914,30 @@ impl TryFrom> for Instruction { dest: response_info.destination, max_response_weight: response_info.max_weight, }, - DepositAsset { assets, max_assets, beneficiary } => - Self::DepositAsset { assets, max_assets, beneficiary }, - DepositReserveAsset { assets, max_assets, dest, xcm } => - Self::DepositReserveAsset { assets, max_assets, dest, xcm: xcm.try_into()? }, - ExchangeAsset { give, receive } => Self::ExchangeAsset { give, receive }, - InitiateReserveWithdraw { assets, reserve, xcm } => - Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? }, - InitiateTeleport { assets, dest, xcm } => - Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? }, + DepositAsset { assets, beneficiary } => { + let max_assets = assets.count().ok_or(())?; + Self::DepositAsset { assets: assets.into(), max_assets, beneficiary } + }, + DepositReserveAsset { assets, dest, xcm } => { + let max_assets = assets.count().ok_or(())?; + Self::DepositReserveAsset { assets: assets.into(), max_assets, dest, xcm: xcm.try_into()? } + }, + ExchangeAsset { give, receive } => + Self::ExchangeAsset { give: give.into(), receive }, + InitiateReserveWithdraw { assets, reserve, xcm } => { + // No `max_assets` here, so if there's a connt, then we cannot translate. + let assets = assets.try_into().map_err(|_| ())?; + Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? } + }, + InitiateTeleport { assets, dest, xcm } => { + // No `max_assets` here, so if there's a connt, then we cannot translate. + let assets = assets.try_into().map_err(|_| ())?; + Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? } + }, ReportHolding { response_info, assets } => Self::QueryHolding { query_id: response_info.query_id, dest: response_info.destination, - assets, + assets: assets.try_into().map_err(|_| ())?, max_response_weight: response_info.max_weight, }, BuyExecution { fees, weight_limit } => Self::BuyExecution { fees, weight_limit }, diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 51cdcfedc828..46ea23618c53 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -29,16 +29,19 @@ use parity_scale_codec::{self, Decode, Encode}; use scale_info::TypeInfo; mod traits; +mod multiasset; pub use traits::{ Error, ExecuteXcm, Outcome, Result, SendError, SendResult, SendXcm, Weight, XcmWeightInfo, }; -// These parts of XCM v1 have been unchanged in XCM v2, and are re-imported here. +pub use multiasset::{ + MultiAsset, MultiAssetFilter, MultiAssets, WildMultiAsset, WildFungibility, AssetId, + AssetInstance, Fungibility, +}; +// These parts of XCM v2 are unchanged in XCM v3, and are re-imported here. pub use super::v2::{ - Ancestor, AncestorThen, AssetId, AssetInstance, BodyId, BodyPart, Fungibility, - InteriorMultiLocation, Junction, Junctions, MultiAsset, MultiAssetFilter, MultiAssets, - MultiLocation, NetworkId, OriginKind, Parent, ParentThen, WeightLimit, WildFungibility, - WildMultiAsset, + Ancestor, AncestorThen, BodyId, BodyPart, InteriorMultiLocation, Junction, Junctions, + MultiLocation, NetworkId, OriginKind, Parent, ParentThen, WeightLimit, }; /// This module's XCM version. @@ -420,9 +423,6 @@ pub enum Instruction { /// the ownership of `beneficiary` within this consensus system. /// /// - `assets`: The asset(s) to remove from holding. - /// - `max_assets`: The maximum number of unique assets/asset instances to remove from holding. - /// Only the first `max_assets` assets/instances of those matched by `assets` will be removed, - /// prioritized under standard asset ordering. Any others will remain in holding. /// - `beneficiary`: The new owner for the assets. /// /// Kind: *Instruction* @@ -430,8 +430,6 @@ pub enum Instruction { /// Errors: DepositAsset { assets: MultiAssetFilter, - #[codec(compact)] - max_assets: u32, beneficiary: MultiLocation, }, @@ -442,9 +440,6 @@ pub enum Instruction { /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the given `effects`. /// /// - `assets`: The asset(s) to remove from holding. - /// - `max_assets`: The maximum number of unique assets/asset instances to remove from holding. - /// Only the first `max_assets` assets/instances of those matched by `assets` will be removed, - /// prioritized under standard asset ordering. Any others will remain in holding. /// - `dest`: The location whose sovereign account will own the assets and thus the effective /// beneficiary for the assets and the notification target for the reserve asset deposit /// message. @@ -456,8 +451,6 @@ pub enum Instruction { /// Errors: DepositReserveAsset { assets: MultiAssetFilter, - #[codec(compact)] - max_assets: u32, dest: MultiLocation, xcm: Xcm<()>, }, @@ -761,10 +754,10 @@ impl Instruction { Transact { origin_kind, require_weight_at_most, call } => Transact { origin_kind, require_weight_at_most, call: call.into() }, ReportError(response_info) => ReportError(response_info), - DepositAsset { assets, max_assets, beneficiary } => - DepositAsset { assets, max_assets, beneficiary }, - DepositReserveAsset { assets, max_assets, dest, xcm } => - DepositReserveAsset { assets, max_assets, dest, xcm }, + DepositAsset { assets, beneficiary } => + DepositAsset { assets, beneficiary }, + DepositReserveAsset { assets, dest, xcm } => + DepositReserveAsset { assets, dest, xcm }, ExchangeAsset { give, receive } => ExchangeAsset { give, receive }, InitiateReserveWithdraw { assets, reserve, xcm } => InitiateReserveWithdraw { assets, reserve, xcm }, @@ -818,10 +811,10 @@ impl> GetWeight for Instruction { ClearOrigin => W::clear_origin(), DescendOrigin(who) => W::descend_origin(who), ReportError(response_info) => W::report_error(&response_info), - DepositAsset { assets, max_assets, beneficiary } => - W::deposit_asset(assets, max_assets, beneficiary), - DepositReserveAsset { assets, max_assets, dest, xcm } => - W::deposit_reserve_asset(assets, max_assets, dest, xcm), + DepositAsset { assets, beneficiary } => + W::deposit_asset(assets, beneficiary), + DepositReserveAsset { assets, dest, xcm } => + W::deposit_reserve_asset(assets, dest, xcm), ExchangeAsset { give, receive } => W::exchange_asset(give, receive), InitiateReserveWithdraw { assets, reserve, xcm } => W::initiate_reserve_withdraw(assets, reserve, xcm), @@ -914,21 +907,24 @@ impl TryFrom> for Instruction { Self::ReportError(response_info) }, DepositAsset { assets, max_assets, beneficiary } => - Self::DepositAsset { assets, max_assets, beneficiary }, - DepositReserveAsset { assets, max_assets, dest, xcm } => - Self::DepositReserveAsset { assets, max_assets, dest, xcm: xcm.try_into()? }, - ExchangeAsset { give, receive } => Self::ExchangeAsset { give, receive }, - InitiateReserveWithdraw { assets, reserve, xcm } => - Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? }, + Self::DepositAsset { assets: (assets, max_assets).try_into()?, beneficiary }, + DepositReserveAsset { assets, max_assets, dest, xcm } => { + let assets = (assets, max_assets).try_into()?; + Self::DepositReserveAsset { assets, dest, xcm: xcm.try_into()? } + }, + ExchangeAsset { give, receive } => Self::ExchangeAsset { give: give.into(), receive }, + InitiateReserveWithdraw { assets, reserve, xcm } => { + Self::InitiateReserveWithdraw { assets: assets.into(), reserve, xcm: xcm.try_into()? } + }, InitiateTeleport { assets, dest, xcm } => - Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? }, + Self::InitiateTeleport { assets: assets.into(), dest, xcm: xcm.try_into()? }, QueryHolding { query_id, dest, assets, max_response_weight } => { let response_info = QueryResponseInfo { destination: dest, query_id, max_weight: max_response_weight, }; - Self::ReportHolding { response_info, assets } + Self::ReportHolding { response_info, assets: assets.into() } }, BuyExecution { fees, weight_limit } => Self::BuyExecution { fees, weight_limit }, ClearOrigin => Self::ClearOrigin, @@ -968,7 +964,7 @@ mod tests { let xcm = Xcm::<()>(vec![ ReceiveTeleportedAsset((Here, 1).into()), ClearOrigin, - DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Here.into() }, + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); let old_xcm: OldXcm<()> = OldXcm::<()>(vec![ OldInstruction::ReceiveTeleportedAsset((Here, 1).into()), @@ -990,7 +986,7 @@ mod tests { ReserveAssetDeposited((Here, 1).into()), ClearOrigin, BuyExecution { fees: (Here, 1).into(), weight_limit: Some(1).into() }, - DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Here.into() }, + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); let old_xcm = OldXcm::<()>(vec![ OldInstruction::ReserveAssetDeposited((Here, 1).into()), diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 1dd326802f61..1b9791afd530 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -392,12 +392,10 @@ pub trait XcmWeightInfo { fn relayed_from(who: &Junctions, message: &alloc::boxed::Box>) -> Weight; fn deposit_asset( assets: &MultiAssetFilter, - max_assets: &u32, beneficiary: &MultiLocation, ) -> Weight; fn deposit_reserve_asset( assets: &MultiAssetFilter, - max_assets: &u32, dest: &MultiLocation, xcm: &Xcm<()>, ) -> Weight; diff --git a/xcm/xcm-builder/src/filter_asset_location.rs b/xcm/xcm-builder/src/filter_asset_location.rs index 9794c2f44f5b..8d42f18dfe4a 100644 --- a/xcm/xcm-builder/src/filter_asset_location.rs +++ b/xcm/xcm-builder/src/filter_asset_location.rs @@ -34,6 +34,6 @@ pub struct Case(PhantomData); impl> FilterAssetLocation for Case { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { let (a, o) = T::get(); - a.contains(asset) && &o == origin + a.matches(asset) && &o == origin } } diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index 37d5ebb12737..5512f6a93bac 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -196,14 +196,14 @@ pub struct TestIsReserve; impl FilterAssetLocation for TestIsReserve { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { IS_RESERVE - .with(|r| r.borrow().get(origin).map_or(false, |v| v.iter().any(|a| a.contains(asset)))) + .with(|r| r.borrow().get(origin).map_or(false, |v| v.iter().any(|a| a.matches(asset)))) } } pub struct TestIsTeleporter; impl FilterAssetLocation for TestIsTeleporter { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { IS_TELEPORTER - .with(|r| r.borrow().get(origin).map_or(false, |v| v.iter().any(|a| a.contains(asset)))) + .with(|r| r.borrow().get(origin).map_or(false, |v| v.iter().any(|a| a.matches(asset)))) } } diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index b37f392c8791..7a44abfc2289 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -47,7 +47,7 @@ fn weigher_should_work() { let mut message = Xcm(vec![ ReserveAssetDeposited((Parent, 100).into()), BuyExecution { fees: (Parent, 1).into(), weight_limit: Limited(30) }, - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: Here.into() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); assert_eq!(::Weigher::weight(&mut message), Ok(30)); } @@ -109,7 +109,7 @@ fn allow_paid_should_work() { let mut underpaying_message = Xcm::<()>(vec![ ReserveAssetDeposited((Parent, 100).into()), BuyExecution { fees, weight_limit: Limited(20) }, - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: Here.into() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); let r = AllowTopLevelPaidExecutionFrom::>::should_execute( @@ -124,7 +124,7 @@ fn allow_paid_should_work() { let mut paying_message = Xcm::<()>(vec![ ReserveAssetDeposited((Parent, 100).into()), BuyExecution { fees, weight_limit: Limited(30) }, - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: Here.into() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); let r = AllowTopLevelPaidExecutionFrom::>::should_execute( @@ -154,7 +154,7 @@ fn paying_reserve_deposit_should_work() { let message = Xcm(vec![ ReserveAssetDeposited((Parent, 100).into()), BuyExecution { fees, weight_limit: Limited(30) }, - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: Here.into() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); let weight_limit = 50; let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); @@ -196,8 +196,7 @@ fn basic_asset_trap_should_work() { Xcm(vec![ WithdrawAsset((Here, 100).into()), DepositAsset { - assets: Wild(All), - max_assets: 0, //< Whoops! + assets: Wild(AllCounted(0)), // <<< 0 is an error. beneficiary: AccountIndex64 { index: 3, network: Any }.into(), }, ]), @@ -214,8 +213,7 @@ fn basic_asset_trap_should_work() { Xcm(vec![ ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(1).into() }, DepositAsset { - assets: Wild(All), - max_assets: 1, + assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: Any }.into(), }, ]), @@ -233,8 +231,7 @@ fn basic_asset_trap_should_work() { Xcm(vec![ ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, DepositAsset { - assets: Wild(All), - max_assets: 1, + assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: Any }.into(), }, ]), @@ -252,8 +249,7 @@ fn basic_asset_trap_should_work() { Xcm(vec![ ClaimAsset { assets: (Here, 101).into(), ticket: GeneralIndex(0).into() }, DepositAsset { - assets: Wild(All), - max_assets: 1, + assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: Any }.into(), }, ]), @@ -269,8 +265,7 @@ fn basic_asset_trap_should_work() { Xcm(vec![ ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, DepositAsset { - assets: Wild(All), - max_assets: 1, + assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: Any }.into(), }, ]), @@ -286,8 +281,7 @@ fn basic_asset_trap_should_work() { Xcm(vec![ ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, DepositAsset { - assets: Wild(All), - max_assets: 1, + assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: Any }.into(), }, ]), @@ -438,8 +432,7 @@ fn reserve_transfer_should_work() { assets: (Here, 100).into(), dest: Parachain(2).into(), xcm: Xcm::<()>(vec![DepositAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), beneficiary: three.clone(), }]), }]), @@ -455,7 +448,7 @@ fn reserve_transfer_should_work() { Xcm::<()>(vec![ ReserveAssetDeposited((Parent, 100).into()), ClearOrigin, - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: three }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: three }, ]), )] ); @@ -634,7 +627,7 @@ fn paid_transacting_should_refund_payment_for_unused_weight() { call: TestCall::Any(50, Some(10)).encode().into(), }, RefundSurplus, - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: one.clone() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: one.clone() }, ]); let weight_limit = 100; let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index 5a9369fb1d59..a4f28bd012e0 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -52,8 +52,7 @@ fn withdraw_and_deposit_works() { WithdrawAsset((Here, amount).into()), buy_execution(), DepositAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), beneficiary: Parachain(other_para_id).into(), }, ]), @@ -94,8 +93,7 @@ fn query_holding_works() { WithdrawAsset((Here, amount).into()), buy_execution(), DepositAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), beneficiary: OnlyChild.into(), // invalid destination }, // is not triggered becasue the deposit fails @@ -121,12 +119,11 @@ fn query_holding_works() { WithdrawAsset((Here, amount).into()), buy_execution(), DepositAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), beneficiary: Parachain(other_para_id).into(), }, // used to get a notification in case of success - ReportHolding { response_info: response_info.clone(), assets: All.into() }, + ReportHolding { response_info: response_info.clone(), assets: AllCounted(1).into() }, ]), weight, ); @@ -168,8 +165,7 @@ fn teleport_to_statemine_works() { let teleport_effects = vec![ buy_execution(), // unchecked mock value DepositAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), beneficiary: (1, Parachain(PARA_ID)).into(), }, ]; @@ -257,8 +253,7 @@ fn reserve_based_transfer_works() { let transfer_effects = vec![ buy_execution(), // unchecked mock value DepositAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), beneficiary: (1, Parachain(PARA_ID)).into(), }, ]; @@ -269,8 +264,7 @@ fn reserve_based_transfer_works() { WithdrawAsset((Here, amount).into()), buy_execution(), DepositReserveAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), dest: Parachain(other_para_id).into(), xcm: Xcm(transfer_effects.clone()), }, diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index 93a29d7af880..d783f1e36469 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -25,7 +25,7 @@ use xcm::latest::{ Fungibility::{Fungible, NonFungible}, MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, WildFungibility::{Fungible as WildFungible, NonFungible as WildNonFungible}, - WildMultiAsset::{All, AllOf}, + WildMultiAsset::{All, AllOf, AllCounted, AllOfCounted}, }; /// List of non-wildcard fungible and non-fungible assets. @@ -245,17 +245,18 @@ impl Assets { &mut self, mask: MultiAssetFilter, saturate: bool, - limit: usize, ) -> Result { let mut taken = Assets::new(); + let maybe_limit = mask.limit().map(|x| x as usize); match mask { - MultiAssetFilter::Wild(All) => - if self.fungible.len() + self.non_fungible.len() <= limit { + // TODO: Counted variants where we define `limit`. + MultiAssetFilter::Wild(All) | MultiAssetFilter::Wild(AllCounted(_)) => { + if maybe_limit.map_or(true, |l| self.len() <= l) { return Ok(self.swapped(Assets::new())) } else { let fungible = mem::replace(&mut self.fungible, Default::default()); fungible.into_iter().for_each(|(c, amount)| { - if taken.len() < limit { + if maybe_limit.map_or(true, |l| taken.len() < l) { taken.fungible.insert(c, amount); } else { self.fungible.insert(c, amount); @@ -263,22 +264,27 @@ impl Assets { }); let non_fungible = mem::replace(&mut self.non_fungible, Default::default()); non_fungible.into_iter().for_each(|(c, instance)| { - if taken.len() < limit { + if maybe_limit.map_or(true, |l| taken.len() < l) { taken.non_fungible.insert((c, instance)); } else { self.non_fungible.insert((c, instance)); } }); - }, - MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) => { + } + }, + MultiAssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) + | MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) + => if maybe_limit.map_or(true, |l| l >= 1) { if let Some((id, amount)) = self.fungible.remove_entry(&id) { taken.fungible.insert(id, amount); } }, - MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => { + MultiAssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) + | MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) + => { let non_fungible = mem::replace(&mut self.non_fungible, Default::default()); non_fungible.into_iter().for_each(|(c, instance)| { - if c == id && taken.len() < limit { + if c == id && maybe_limit.map_or(true, |l| taken.len() < l) { taken.non_fungible.insert((c, instance)); } else { self.non_fungible.insert((c, instance)); @@ -314,9 +320,6 @@ impl Assets { } }, } - if taken.len() == limit { - break - } } }, } @@ -328,16 +331,7 @@ impl Assets { /// Returns `Ok` with the non-wildcard equivalence of `mask` taken and mutates `self` to its value minus /// `mask` if `self` contains `asset`, and return `Err` otherwise. pub fn saturating_take(&mut self, asset: MultiAssetFilter) -> Assets { - self.general_take(asset, true, usize::max_value()) - .expect("general_take never results in error when saturating") - } - - /// Mutates `self` to its original value less `mask` and returns `true` iff it contains at least `mask`. - /// - /// Returns `Ok` with the non-wildcard equivalence of `mask` taken and mutates `self` to its value minus - /// `mask` if `self` contains `asset`, and return `Err` otherwise. - pub fn limited_saturating_take(&mut self, asset: MultiAssetFilter, limit: usize) -> Assets { - self.general_take(asset, true, limit) + self.general_take(asset, true) .expect("general_take never results in error when saturating") } @@ -346,7 +340,7 @@ impl Assets { /// Returns `Ok` with the non-wildcard equivalence of `asset` taken and mutates `self` to its value minus /// `asset` if `self` contains `asset`, and return `Err` otherwise. pub fn try_take(&mut self, mask: MultiAssetFilter) -> Result { - self.general_take(mask, false, usize::max_value()) + self.general_take(mask, false) } /// Consumes `self` and returns its original value excluding `asset` iff it contains at least `asset`. @@ -396,19 +390,41 @@ impl Assets { /// ``` pub fn min(&self, mask: &MultiAssetFilter) -> Assets { let mut masked = Assets::new(); + let maybe_limit = mask.limit().map(|x| x as usize); + if maybe_limit.map_or(false, |l| l == 0) { return masked } match mask { - MultiAssetFilter::Wild(All) => return self.clone(), - MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) => { - if let Some(&amount) = self.fungible.get(&id) { - masked.fungible.insert(id.clone(), amount); + MultiAssetFilter::Wild(All) | MultiAssetFilter::Wild(AllCounted(_)) => { + if maybe_limit.map_or(true, |l| self.len() <= l) { + return self.clone(); + } else { + for (c, &amount) in self.fungible.iter() { + masked.fungible.insert(c.clone(), amount); + if maybe_limit.map_or(false, |l| masked.len() >= l) { + return masked; + } + } + for (c, instance) in self.non_fungible.iter() { + masked.non_fungible.insert((c.clone(), instance.clone())); + if maybe_limit.map_or(false, |l| masked.len() >= l) { + return masked; + } + } } }, - MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => { - self.non_fungible.iter().for_each(|(ref c, ref instance)| { - if c == id { - masked.non_fungible.insert((c.clone(), instance.clone())); + MultiAssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) + | MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) + => if let Some(&amount) = self.fungible.get(&id) { + masked.fungible.insert(id.clone(), amount); + }, + MultiAssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) + | MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) + => for (c, instance) in self.non_fungible.iter() { + if c == id { + masked.non_fungible.insert((c.clone(), instance.clone())); + if maybe_limit.map_or(false, |l| masked.len() >= l) { + return masked; } - }); + } }, MultiAssetFilter::Definite(assets) => for asset in assets.inner().iter() { diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 5aeacf5be9b8..8ea61fa843e1 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -354,15 +354,15 @@ impl XcmExecutor { // destination if one was registered. Self::respond(Response::ExecutionResult(self.error), response_info) }, - DepositAsset { assets, max_assets, beneficiary } => { - let deposited = self.holding.limited_saturating_take(assets, max_assets as usize); + DepositAsset { assets, beneficiary } => { + let deposited = self.holding.saturating_take(assets); for asset in deposited.into_assets_iter() { Config::AssetTransactor::deposit_asset(&asset, &beneficiary)?; } Ok(()) }, - DepositReserveAsset { assets, max_assets, dest, xcm } => { - let deposited = self.holding.limited_saturating_take(assets, max_assets as usize); + DepositReserveAsset { assets, dest, xcm } => { + let deposited = self.holding.saturating_take(assets); for asset in deposited.assets_iter() { Config::AssetTransactor::deposit_asset(&asset, &dest)?; } From f9defc33944a39234d72ce6a5745084f64e82963 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 20:14:44 +0200 Subject: [PATCH 019/231] Formatting --- runtime/westend/src/weights/xcm/mod.rs | 9 ++-- xcm/pallet-xcm/src/lib.rs | 9 ++-- xcm/src/v1/multiasset.rs | 4 +- xcm/src/v2/mod.rs | 17 +++++--- xcm/src/v3/mod.rs | 51 +++++++++------------- xcm/src/v3/traits.rs | 10 +---- xcm/xcm-builder/src/mock.rs | 2 +- xcm/xcm-builder/src/tests.rs | 2 +- xcm/xcm-builder/tests/scenarios.rs | 7 ++- xcm/xcm-executor/src/assets.rs | 59 +++++++++++++------------- xcm/xcm-executor/src/lib.rs | 10 ++--- 11 files changed, 89 insertions(+), 91 deletions(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 3c5715d72e51..73ee5475870d 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -4,7 +4,10 @@ mod pallet_xcm_benchmarks_generic; use crate::Runtime; use frame_support::weights::Weight; use sp_std::prelude::*; -use xcm::{DoubleEncoded, latest::{QueryResponseInfo, prelude::*}}; +use xcm::{ + latest::{prelude::*, QueryResponseInfo}, + DoubleEncoded, +}; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; @@ -114,9 +117,7 @@ impl XcmWeightInfo for WestendXcmWeight { fn descend_origin(who: &InteriorMultiLocation) -> Weight { XcmGeneric::::descend_origin(who) } - fn report_error( - _query_repsonse_info: &QueryResponseInfo, - ) -> Weight { + fn report_error(_query_repsonse_info: &QueryResponseInfo) -> Weight { XcmGeneric::::report_error() } fn relayed_from(_who: &Junctions, _message: &Box>) -> Weight { diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 60486c056e08..981bf3233cfd 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -38,9 +38,8 @@ use sp_std::{ result::Result, vec, }; -use xcm::prelude::*; +use xcm::{latest::QueryResponseInfo, prelude::*}; use xcm_executor::traits::ConvertOrigin; -use xcm::latest::QueryResponseInfo; use frame_support::PalletId; pub use pallet::*; @@ -546,7 +545,11 @@ pub mod pallet { } let mut message = Xcm(vec![ WithdrawAsset(assets), - InitiateTeleport { assets: Wild(AllCounted(max_assets)), dest, xcm: remote_message.into() }, + InitiateTeleport { + assets: Wild(AllCounted(max_assets)), + dest, + xcm: remote_message.into(), + }, ]); let weight = T::Weigher::weight(&mut message).map_err(|()| Error::::UnweighableMessage)?; diff --git a/xcm/src/v1/multiasset.rs b/xcm/src/v1/multiasset.rs index 3b09612ffcb0..22a3908ab9ed 100644 --- a/xcm/src/v1/multiasset.rs +++ b/xcm/src/v1/multiasset.rs @@ -23,10 +23,8 @@ //! - `MultiAssetFilter`: A combination of `Wild` and `MultiAssets` designed for efficiently filtering an XCM holding //! account. -use crate::v3::{ - MultiAssetFilter as NewMultiAssetFilter, WildMultiAsset as NewWildMultiAsset, -}; use super::MultiLocation; +use crate::v3::{MultiAssetFilter as NewMultiAssetFilter, WildMultiAsset as NewWildMultiAsset}; use alloc::{vec, vec::Vec}; use core::{ cmp::Ordering, diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index f465ab44edf7..d594e90281a7 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -907,8 +907,11 @@ impl TryFrom> for Instruction { HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient }, HrmpChannelClosing { initiator, sender, recipient } => Self::HrmpChannelClosing { initiator, sender, recipient }, - Transact { origin_kind, require_weight_at_most, call } => - Self::Transact { origin_type: origin_kind, require_weight_at_most, call: call.into() }, + Transact { origin_kind, require_weight_at_most, call } => Self::Transact { + origin_type: origin_kind, + require_weight_at_most, + call: call.into(), + }, ReportError(response_info) => Self::ReportError { query_id: response_info.query_id, dest: response_info.destination, @@ -920,10 +923,14 @@ impl TryFrom> for Instruction { }, DepositReserveAsset { assets, dest, xcm } => { let max_assets = assets.count().ok_or(())?; - Self::DepositReserveAsset { assets: assets.into(), max_assets, dest, xcm: xcm.try_into()? } + Self::DepositReserveAsset { + assets: assets.into(), + max_assets, + dest, + xcm: xcm.try_into()?, + } }, - ExchangeAsset { give, receive } => - Self::ExchangeAsset { give: give.into(), receive }, + ExchangeAsset { give, receive } => Self::ExchangeAsset { give: give.into(), receive }, InitiateReserveWithdraw { assets, reserve, xcm } => { // No `max_assets` here, so if there's a connt, then we cannot translate. let assets = assets.try_into().map_err(|_| ())?; diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 46ea23618c53..3024883b7190 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -28,16 +28,16 @@ use derivative::Derivative; use parity_scale_codec::{self, Decode, Encode}; use scale_info::TypeInfo; -mod traits; mod multiasset; +mod traits; +pub use multiasset::{ + AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssetFilter, MultiAssets, + WildFungibility, WildMultiAsset, +}; pub use traits::{ Error, ExecuteXcm, Outcome, Result, SendError, SendResult, SendXcm, Weight, XcmWeightInfo, }; -pub use multiasset::{ - MultiAsset, MultiAssetFilter, MultiAssets, WildMultiAsset, WildFungibility, AssetId, - AssetInstance, Fungibility, -}; // These parts of XCM v2 are unchanged in XCM v3, and are re-imported here. pub use super::v2::{ Ancestor, AncestorThen, BodyId, BodyPart, InteriorMultiLocation, Junction, Junctions, @@ -428,10 +428,7 @@ pub enum Instruction { /// Kind: *Instruction* /// /// Errors: - DepositAsset { - assets: MultiAssetFilter, - beneficiary: MultiLocation, - }, + DepositAsset { assets: MultiAssetFilter, beneficiary: MultiLocation }, /// Remove the asset(s) (`assets`) from the Holding Register and place equivalent assets under /// the ownership of `dest` within this consensus system (i.e. deposit them into its sovereign @@ -449,11 +446,7 @@ pub enum Instruction { /// Kind: *Instruction* /// /// Errors: - DepositReserveAsset { - assets: MultiAssetFilter, - dest: MultiLocation, - xcm: Xcm<()>, - }, + DepositReserveAsset { assets: MultiAssetFilter, dest: MultiLocation, xcm: Xcm<()> }, /// Remove the asset(s) (`give`) from the Holding Register and replace them with alternative /// assets. @@ -513,10 +506,7 @@ pub enum Instruction { /// Kind: *Instruction* /// /// Errors: - ReportHolding { - response_info: QueryResponseInfo, - assets: MultiAssetFilter, - }, + ReportHolding { response_info: QueryResponseInfo, assets: MultiAssetFilter }, /// Pay for the execution of some XCM `xcm` and `orders` with up to `weight` /// picoseconds of execution time, paying for this with up to `fees` from the Holding Register. @@ -754,10 +744,8 @@ impl Instruction { Transact { origin_kind, require_weight_at_most, call } => Transact { origin_kind, require_weight_at_most, call: call.into() }, ReportError(response_info) => ReportError(response_info), - DepositAsset { assets, beneficiary } => - DepositAsset { assets, beneficiary }, - DepositReserveAsset { assets, dest, xcm } => - DepositReserveAsset { assets, dest, xcm }, + DepositAsset { assets, beneficiary } => DepositAsset { assets, beneficiary }, + DepositReserveAsset { assets, dest, xcm } => DepositReserveAsset { assets, dest, xcm }, ExchangeAsset { give, receive } => ExchangeAsset { give, receive }, InitiateReserveWithdraw { assets, reserve, xcm } => InitiateReserveWithdraw { assets, reserve, xcm }, @@ -811,16 +799,14 @@ impl> GetWeight for Instruction { ClearOrigin => W::clear_origin(), DescendOrigin(who) => W::descend_origin(who), ReportError(response_info) => W::report_error(&response_info), - DepositAsset { assets, beneficiary } => - W::deposit_asset(assets, beneficiary), + DepositAsset { assets, beneficiary } => W::deposit_asset(assets, beneficiary), DepositReserveAsset { assets, dest, xcm } => W::deposit_reserve_asset(assets, dest, xcm), ExchangeAsset { give, receive } => W::exchange_asset(give, receive), InitiateReserveWithdraw { assets, reserve, xcm } => W::initiate_reserve_withdraw(assets, reserve, xcm), InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm), - ReportHolding { response_info, assets } => - W::report_holding(&response_info, &assets), + ReportHolding { response_info, assets } => W::report_holding(&response_info, &assets), BuyExecution { fees, weight_limit } => W::buy_execution(fees, weight_limit), RefundSurplus => W::refund_surplus(), SetErrorHandler(xcm) => W::set_error_handler(xcm), @@ -896,8 +882,11 @@ impl TryFrom> for Instruction { HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient }, HrmpChannelClosing { initiator, sender, recipient } => Self::HrmpChannelClosing { initiator, sender, recipient }, - Transact { origin_type, require_weight_at_most, call } => - Self::Transact { origin_kind: origin_type, require_weight_at_most, call: call.into() }, + Transact { origin_type, require_weight_at_most, call } => Self::Transact { + origin_kind: origin_type, + require_weight_at_most, + call: call.into(), + }, ReportError { query_id, dest, max_response_weight } => { let response_info = QueryResponseInfo { destination: dest, @@ -913,8 +902,10 @@ impl TryFrom> for Instruction { Self::DepositReserveAsset { assets, dest, xcm: xcm.try_into()? } }, ExchangeAsset { give, receive } => Self::ExchangeAsset { give: give.into(), receive }, - InitiateReserveWithdraw { assets, reserve, xcm } => { - Self::InitiateReserveWithdraw { assets: assets.into(), reserve, xcm: xcm.try_into()? } + InitiateReserveWithdraw { assets, reserve, xcm } => Self::InitiateReserveWithdraw { + assets: assets.into(), + reserve, + xcm: xcm.try_into()?, }, InitiateTeleport { assets, dest, xcm } => Self::InitiateTeleport { assets: assets.into(), dest, xcm: xcm.try_into()? }, diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 1b9791afd530..8ead1380f56a 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -390,10 +390,7 @@ pub trait XcmWeightInfo { fn descend_origin(who: &InteriorMultiLocation) -> Weight; fn report_error(response_info: &QueryResponseInfo) -> Weight; fn relayed_from(who: &Junctions, message: &alloc::boxed::Box>) -> Weight; - fn deposit_asset( - assets: &MultiAssetFilter, - beneficiary: &MultiLocation, - ) -> Weight; + fn deposit_asset(assets: &MultiAssetFilter, beneficiary: &MultiLocation) -> Weight; fn deposit_reserve_asset( assets: &MultiAssetFilter, dest: &MultiLocation, @@ -406,10 +403,7 @@ pub trait XcmWeightInfo { xcm: &Xcm<()>, ) -> Weight; fn initiate_teleport(assets: &MultiAssetFilter, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight; - fn report_holding( - response_info: &QueryResponseInfo, - assets: &MultiAssetFilter, - ) -> Weight; + fn report_holding(response_info: &QueryResponseInfo, assets: &MultiAssetFilter) -> Weight; fn buy_execution(fees: &MultiAsset, weight_limit: &WeightLimit) -> Weight; fn refund_surplus() -> Weight; fn set_error_handler(xcm: &Xcm) -> Weight; diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index 5512f6a93bac..6b2bbc374795 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -340,5 +340,5 @@ impl Config for TestConfig { type AssetTrap = TestAssetTrap; type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; - type PalletInstancesInfo = (); // TODO: TestAllPallets, for testing new instructions. + type PalletInstancesInfo = (); // TODO: TestAllPallets, for testing new instructions. } diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index 7a44abfc2289..5b866f0dd287 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -196,7 +196,7 @@ fn basic_asset_trap_should_work() { Xcm(vec![ WithdrawAsset((Here, 100).into()), DepositAsset { - assets: Wild(AllCounted(0)), // <<< 0 is an error. + assets: Wild(AllCounted(0)), // <<< 0 is an error. beneficiary: AccountIndex64 { index: 3, network: Any }.into(), }, ]), diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index a4f28bd012e0..91be85517409 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -21,7 +21,7 @@ use mock::{ }; use polkadot_parachain::primitives::Id as ParaId; use sp_runtime::traits::AccountIdConversion; -use xcm::latest::{QueryResponseInfo, prelude::*}; +use xcm::latest::{prelude::*, QueryResponseInfo}; use xcm_executor::XcmExecutor; pub const ALICE: AccountId = AccountId::new([0u8; 32]); @@ -123,7 +123,10 @@ fn query_holding_works() { beneficiary: Parachain(other_para_id).into(), }, // used to get a notification in case of success - ReportHolding { response_info: response_info.clone(), assets: AllCounted(1).into() }, + ReportHolding { + response_info: response_info.clone(), + assets: AllCounted(1).into(), + }, ]), weight, ); diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index d783f1e36469..2adc8ecf893d 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -25,7 +25,7 @@ use xcm::latest::{ Fungibility::{Fungible, NonFungible}, MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, WildFungibility::{Fungible as WildFungible, NonFungible as WildNonFungible}, - WildMultiAsset::{All, AllOf, AllCounted, AllOfCounted}, + WildMultiAsset::{All, AllCounted, AllOf, AllOfCounted}, }; /// List of non-wildcard fungible and non-fungible assets. @@ -272,16 +272,15 @@ impl Assets { }); } }, - MultiAssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) - | MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) - => if maybe_limit.map_or(true, |l| l >= 1) { - if let Some((id, amount)) = self.fungible.remove_entry(&id) { - taken.fungible.insert(id, amount); - } - }, - MultiAssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) - | MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) - => { + MultiAssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) | + MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) => + if maybe_limit.map_or(true, |l| l >= 1) { + if let Some((id, amount)) = self.fungible.remove_entry(&id) { + taken.fungible.insert(id, amount); + } + }, + MultiAssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) | + MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => { let non_fungible = mem::replace(&mut self.non_fungible, Default::default()); non_fungible.into_iter().for_each(|(c, instance)| { if c == id && maybe_limit.map_or(true, |l| taken.len() < l) { @@ -391,41 +390,43 @@ impl Assets { pub fn min(&self, mask: &MultiAssetFilter) -> Assets { let mut masked = Assets::new(); let maybe_limit = mask.limit().map(|x| x as usize); - if maybe_limit.map_or(false, |l| l == 0) { return masked } + if maybe_limit.map_or(false, |l| l == 0) { + return masked + } match mask { MultiAssetFilter::Wild(All) | MultiAssetFilter::Wild(AllCounted(_)) => { if maybe_limit.map_or(true, |l| self.len() <= l) { - return self.clone(); + return self.clone() } else { for (c, &amount) in self.fungible.iter() { masked.fungible.insert(c.clone(), amount); if maybe_limit.map_or(false, |l| masked.len() >= l) { - return masked; + return masked } } for (c, instance) in self.non_fungible.iter() { masked.non_fungible.insert((c.clone(), instance.clone())); if maybe_limit.map_or(false, |l| masked.len() >= l) { - return masked; + return masked } } } }, - MultiAssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) - | MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) - => if let Some(&amount) = self.fungible.get(&id) { - masked.fungible.insert(id.clone(), amount); - }, - MultiAssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) - | MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) - => for (c, instance) in self.non_fungible.iter() { - if c == id { - masked.non_fungible.insert((c.clone(), instance.clone())); - if maybe_limit.map_or(false, |l| masked.len() >= l) { - return masked; + MultiAssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) | + MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) => + if let Some(&amount) = self.fungible.get(&id) { + masked.fungible.insert(id.clone(), amount); + }, + MultiAssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) | + MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => + for (c, instance) in self.non_fungible.iter() { + if c == id { + masked.non_fungible.insert((c.clone(), instance.clone())); + if maybe_limit.map_or(false, |l| masked.len() >= l) { + return masked + } } - } - }, + }, MultiAssetFilter::Definite(assets) => for asset in assets.inner().iter() { match asset { diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 8ea61fa843e1..5e7812a821c0 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -389,7 +389,8 @@ impl XcmExecutor { Config::XcmSender::send_xcm(dest, Xcm(message)).map_err(Into::into) }, ReportHolding { response_info, assets } => { - let assets = Self::reanchored(self.holding.min(&assets), &response_info.destination)?; + let assets = + Self::reanchored(self.holding.min(&assets), &response_info.destination)?; Self::respond(Response::Assets(assets), response_info) }, BuyExecution { fees, weight_limit } => { @@ -498,13 +499,12 @@ impl XcmExecutor { ensure!(minor >= min_crate_minor, XcmError::VersionIncompatible); Ok(()) }, - ReportTransactStatus(response_info) => { - Self::respond(Response::DispatchResult(self.transact_status.clone()), response_info) - } + ReportTransactStatus(response_info) => + Self::respond(Response::DispatchResult(self.transact_status.clone()), response_info), ClearTransactStatus => { self.transact_status = Default::default(); Ok(()) - } + }, ExchangeAsset { .. } => Err(XcmError::Unimplemented), HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), From a350033d7f332e68f601cbf38009393cb4ab1001 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 20:48:49 +0200 Subject: [PATCH 020/231] Formatting --- xcm/src/v3/traits.rs | 3 ++ xcm/xcm-builder/src/mock.rs | 2 + xcm/xcm-builder/tests/mock/mod.rs | 2 + xcm/xcm-executor/src/config.rs | 8 +++- xcm/xcm-executor/src/lib.rs | 62 ++++++++++++++++++------------- 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 8ead1380f56a..24f0f10bf30b 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -105,6 +105,9 @@ pub enum Error { /// The given pallet's version has an incompatible version to that expected. #[codec(index = 25)] VersionIncompatible, + /// The given operation would lead to an overflow of the Holding Register. + #[codec(index = 26)] + HoldingWouldOverflow, // Errors that happen prior to instructions being executed. These fall outside of the XCM spec. /// XCM version not able to be handled. diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index 6b2bbc374795..94682e6d262c 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -306,6 +306,7 @@ impl ClaimAssets for TestAssetTrap { parameter_types! { pub static SubscriptionRequests: Vec<(MultiLocation, Option<(QueryId, u64)>)> = vec![]; + pub static MaxHoldingAssetCount: usize = 4; } pub struct TestSubscriptionService; @@ -341,4 +342,5 @@ impl Config for TestConfig { type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; type PalletInstancesInfo = (); // TODO: TestAllPallets, for testing new instructions. + type MaxHoldingAssetCount = MaxHoldingAssetCount; } diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 3c05a7e4f451..db031a91361c 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -153,6 +153,7 @@ parameter_types! { pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (MultiAssetFilter::Wild(WildMultiAsset::AllOf { id: Concrete(MultiLocation::here()), fun: WildFungible }), X1(Parachain(1000)).into()); pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: usize = 4; } pub type TrustedTeleporters = (xcm_builder::Case,); @@ -173,6 +174,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; + type MaxHoldingAssetCount = MaxHoldingAssetCount; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index e328127c7f7d..4533428e8bf2 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -20,7 +20,7 @@ use crate::traits::{ }; use frame_support::{ dispatch::{Dispatchable, Parameter}, - traits::PalletsInfoAccess, + traits::{Get, PalletsInfoAccess}, weights::{GetDispatchInfo, PostDispatchInfo}, }; use xcm::latest::SendXcm; @@ -72,4 +72,10 @@ pub trait Config { /// Information on all pallets. type PalletInstancesInfo: PalletsInfoAccess; + + /// The maximum number of assets we target to have in the Holding Register at any one time. + /// + /// NOTE: In the worse case, the Holding Register may contain up to twice as many assets as this + /// and any benchmarks should take that into account. + type MaxHoldingAssetCount: Get; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 5e7812a821c0..dfcb907408da 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -19,7 +19,7 @@ use frame_support::{ dispatch::{Dispatchable, Weight}, ensure, - traits::PalletsInfoAccess, + traits::{Get, PalletsInfoAccess}, weights::GetDispatchInfo, }; use parity_scale_codec::Encode; @@ -28,8 +28,8 @@ use sp_std::{marker::PhantomData, prelude::*}; use xcm::latest::{ Error as XcmError, ExecuteXcm, Instruction::{self, *}, - MaybeErrorCode, MultiAssets, MultiLocation, Outcome, PalletInfo, QueryResponseInfo, Response, - SendXcm, Xcm, + MaybeErrorCode, MultiAsset, MultiAssets, MultiLocation, Outcome, PalletInfo, QueryResponseInfo, + Response, SendXcm, Xcm, }; pub mod traits; @@ -46,6 +46,7 @@ pub use config::Config; /// The XCM executor. pub struct XcmExecutor { pub holding: Assets, + pub holding_limit: usize, pub origin: Option, pub original_origin: MultiLocation, pub trader: Config::Trader, @@ -66,9 +67,6 @@ pub struct XcmExecutor { _config: PhantomData, } -/// The maximum recursion limit for `execute_xcm` and `execute_effects`. -pub const MAX_RECURSION_LIMIT: u32 = 8; - impl ExecuteXcm for XcmExecutor { fn execute_xcm_in_credit( origin: impl Into, @@ -114,7 +112,9 @@ impl ExecuteXcm for XcmExecutor { } } - vm.refund_surplus(); + // We silently drop any error from our attempt to refund the surplus as it's a charitable + // thing so best-effort is all we will do. + let _ = vm.refund_surplus(); drop(vm.trader); let mut weight_used = xcm_weight.saturating_sub(vm.total_surplus); @@ -158,6 +158,7 @@ impl XcmExecutor { let origin = origin.into(); Self { holding: Assets::new(), + holding_limit: Config::MaxHoldingAssetCount::get(), origin: Some(origin.clone()), original_origin: origin, trader: Config::Trader::new(), @@ -223,15 +224,29 @@ impl XcmExecutor { r } + fn subsume_asset(&mut self, asset: MultiAsset) -> Result<(), XcmError> { + ensure!(self.holding.len() <= self.holding_limit, XcmError::HoldingWouldOverflow); + self.holding.subsume(asset); + Ok(()) + } + + fn subsume_assets(&mut self, assets: Assets) -> Result<(), XcmError> { + ensure!(self.holding.len() <= self.holding_limit, XcmError::HoldingWouldOverflow); + ensure!(assets.len() <= self.holding_limit, XcmError::HoldingWouldOverflow); + self.holding.subsume_assets(assets); + Ok(()) + } + /// Refund any unused weight. - fn refund_surplus(&mut self) { + fn refund_surplus(&mut self) -> Result<(), XcmError> { let current_surplus = self.total_surplus.saturating_sub(self.total_refunded); if current_surplus > 0 { self.total_refunded.saturating_accrue(current_surplus); if let Some(w) = self.trader.refund_weight(current_surplus) { - self.holding.subsume(w); + self.subsume_asset(w)?; } } + Ok(()) } /// Process a single XCM instruction, mutating the state of the XCM virtual machine. @@ -239,23 +254,23 @@ impl XcmExecutor { match instr { WithdrawAsset(assets) => { // Take `assets` from the origin account (on-chain) and place in holding. - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); for asset in assets.drain().into_iter() { - Config::AssetTransactor::withdraw_asset(&asset, origin)?; - self.holding.subsume(asset); + Config::AssetTransactor::withdraw_asset(&asset, &origin)?; + self.subsume_asset(asset)?; } Ok(()) }, ReserveAssetDeposited(assets) => { // check whether we trust origin to be our reserve location for this asset. - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); for asset in assets.drain().into_iter() { // Must ensure that we recognise the asset as being managed by the origin. ensure!( - Config::IsReserve::filter_asset_location(&asset, origin), + Config::IsReserve::filter_asset_location(&asset, &origin), XcmError::UntrustedReserveLocation ); - self.holding.subsume(asset); + self.subsume_asset(asset)?; } Ok(()) }, @@ -281,13 +296,13 @@ impl XcmExecutor { Config::XcmSender::send_xcm(dest, Xcm(message)).map_err(Into::into) }, ReceiveTeleportedAsset(assets) => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); // check whether we trust origin to teleport this asset to us via config trait. for asset in assets.inner() { // We only trust the origin to send us assets that they identify as their // sovereign assets. ensure!( - Config::IsTeleporter::filter_asset_location(asset, origin), + Config::IsTeleporter::filter_asset_location(asset, &origin), XcmError::UntrustedTeleportLocation ); // We should check that the asset can actually be teleported in (for this to be in error, there @@ -296,8 +311,8 @@ impl XcmExecutor { Config::AssetTransactor::can_check_in(&origin, asset)?; } for asset in assets.drain().into_iter() { - Config::AssetTransactor::check_in(origin, &asset); - self.holding.subsume(asset); + Config::AssetTransactor::check_in(&origin, &asset); + self.subsume_asset(asset)?; } Ok(()) }, @@ -403,14 +418,11 @@ impl XcmExecutor { let max_fee = self.holding.try_take(fees.into()).map_err(|_| XcmError::NotHoldingFees)?; let unspent = self.trader.buy_weight(weight, max_fee)?; - self.holding.subsume_assets(unspent); + self.subsume_assets(unspent)?; } Ok(()) }, - RefundSurplus => { - self.refund_surplus(); - Ok(()) - }, + RefundSurplus => self.refund_surplus(), SetErrorHandler(mut handler) => { let handler_weight = Config::Weigher::weight(&mut handler) .map_err(|()| XcmError::WeightNotComputable)?; @@ -436,7 +448,7 @@ impl XcmExecutor { let ok = Config::AssetClaims::claim_assets(origin, &ticket, &assets); ensure!(ok, XcmError::UnknownClaim); for asset in assets.drain().into_iter() { - self.holding.subsume(asset); + self.subsume_asset(asset)?; } Ok(()) }, From b9c7e1430efcc1682141ceb0f8ea745040bcd5a5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 21:27:10 +0200 Subject: [PATCH 021/231] Fixes --- runtime/kusama/src/lib.rs | 2 ++ runtime/rococo/src/lib.rs | 2 ++ runtime/test-runtime/src/xcm_config.rs | 2 ++ runtime/westend/src/lib.rs | 2 ++ runtime/westend/src/weights/xcm/mod.rs | 2 -- .../src/fungible/benchmarking.rs | 2 -- .../src/fungible/mock.rs | 2 ++ xcm/pallet-xcm/src/mock.rs | 2 ++ xcm/pallet-xcm/src/tests.rs | 34 +++++++++---------- xcm/src/v3/mod.rs | 10 +++--- xcm/src/v3/traits.rs | 2 +- xcm/xcm-builder/src/mock.rs | 2 +- xcm/xcm-builder/tests/mock/mod.rs | 2 +- xcm/xcm-executor/integration-tests/src/lib.rs | 2 +- xcm/xcm-executor/src/config.rs | 2 +- xcm/xcm-executor/src/lib.rs | 6 ++-- xcm/xcm-simulator/example/src/lib.rs | 24 ++++++------- xcm/xcm-simulator/example/src/parachain.rs | 2 ++ xcm/xcm-simulator/example/src/relay_chain.rs | 2 ++ xcm/xcm-simulator/fuzzer/src/parachain.rs | 2 ++ xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 2 ++ 21 files changed, 62 insertions(+), 46 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index cff846eeb47d..eb2e548833e4 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1329,6 +1329,7 @@ pub type XcmRouter = ( parameter_types! { pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) }); pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1000).into()); + pub const MaxHoldingAssetCount: u32 = 64; } pub type TrustedTeleporters = (xcm_builder::Case,); @@ -1360,6 +1361,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; + type MaxHoldingAssetCount = MaxHoldingAssetCount; } parameter_types! { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 22f0c7318980..2bf76646d4c2 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -647,6 +647,7 @@ parameter_types! { pub const RococoForRockmine: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1001).into()); pub const RococoForCanvas: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1002).into()); pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 64; } pub type TrustedTeleporters = ( xcm_builder::Case, @@ -691,6 +692,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; + type MaxHoldingAssetCount = MaxHoldingAssetCount; } parameter_types! { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index d73c59762b44..90cbacdae9d2 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -25,6 +25,7 @@ use xcm_executor::{ parameter_types! { pub const OurNetwork: NetworkId = NetworkId::Polkadot; pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 16; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location @@ -90,4 +91,5 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = super::Xcm; type SubscriptionService = super::Xcm; type PalletInstancesInfo = (); + type MaxHoldingAssetCount = MaxHoldingAssetCount; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index fd11728a4836..ac84a5fa6835 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -966,6 +966,7 @@ parameter_types! { pub const WestendForWestmint: (MultiAssetFilter, MultiLocation) = (Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Westmint::get()); pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 64; } pub type TrustedTeleporters = (xcm_builder::Case,); @@ -996,6 +997,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; + type MaxHoldingAssetCount = MaxHoldingAssetCount; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 73ee5475870d..123fa2b13f75 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -126,14 +126,12 @@ impl XcmWeightInfo for WestendXcmWeight { fn deposit_asset( assets: &MultiAssetFilter, - _max_assets: &u32, // TODO use max assets? _dest: &MultiLocation, ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset( assets: &MultiAssetFilter, - _max_assets: &u32, // TODO use max assets? _dest: &MultiLocation, _xcm: &Xcm<()>, ) -> Weight { diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 3a71d771c11d..469ba731338f 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -143,7 +143,6 @@ benchmarks_instance_pallet! { executor.holding = holding; let instruction = Instruction::>::DepositAsset { assets: asset.into(), - max_assets: 1, beneficiary: dest_location, }; let xcm = Xcm(vec![instruction]); @@ -170,7 +169,6 @@ benchmarks_instance_pallet! { executor.holding = holding; let instruction = Instruction::>::DepositReserveAsset { assets: asset.into(), - max_assets: 1, dest: dest_location, xcm: Xcm::new(), }; diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 273134ac0024..c3d94a68733a 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -122,6 +122,7 @@ parameter_types! { /// Maximum number of instructions in a single XCM fragment. A sanity check against weight /// calculations getting too crazy. pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 64; } pub struct XcmConfig; @@ -141,6 +142,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); + type MaxHoldingAssetCount = MaxHoldingAssetCount; } impl crate::Config for Test { diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index d772d4e75f77..1cda1f28e256 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -239,6 +239,7 @@ parameter_types! { pub CurrencyPerSecond: (AssetId, u128) = (Concrete(RelayLocation::get()), 1); pub TrustedAssets: (MultiAssetFilter, MultiLocation) = (All.into(), Here.into()); pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 64; } pub type Barrier = ( @@ -265,6 +266,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; + type MaxHoldingAssetCount = MaxHoldingAssetCount; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index ba5459e2c890..fa0192ba7dbc 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -25,7 +25,7 @@ use frame_support::{ use polkadot_parachain::primitives::{AccountIdConversion, Id as ParaId}; use sp_runtime::traits::{BlakeTwo256, Hash}; use std::convert::TryInto; -use xcm::prelude::*; +use xcm::{latest::QueryResponseInfo, prelude::*}; use xcm_builder::AllowKnownQueryResponses; use xcm_executor::{traits::ShouldExecute, XcmExecutor}; @@ -55,11 +55,11 @@ fn report_outcome_notify_works() { assert_eq!( message, Xcm(vec![ - SetAppendix(Xcm(vec![ReportError { + SetAppendix(Xcm(vec![ReportError(QueryResponseInfo { + destination: Parent.into(), query_id: 0, - dest: Parent.into(), - max_response_weight: 1_000_000 - },])), + max_weight: 1_000_000 + }),])), TransferAsset { assets: (Here, SEND_AMOUNT).into(), beneficiary: sender.clone() }, ]) ); @@ -109,11 +109,11 @@ fn report_outcome_works() { assert_eq!( message, Xcm(vec![ - SetAppendix(Xcm(vec![ReportError { + SetAppendix(Xcm(vec![ReportError(QueryResponseInfo { + destination: Parent.into(), query_id: 0, - dest: Parent.into(), - max_response_weight: 0 - },])), + max_weight: 0 + }),])), TransferAsset { assets: (Here, SEND_AMOUNT).into(), beneficiary: sender.clone() }, ]) ); @@ -158,7 +158,7 @@ fn send_works() { ReserveAssetDeposited((Parent, SEND_AMOUNT).into()), ClearOrigin, buy_execution((Parent, SEND_AMOUNT)), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: sender.clone() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: sender.clone() }, ]); let versioned_dest = Box::new(RelayLocation::get().into()); let versioned_message = Box::new(VersionedXcm::from(message.clone())); @@ -194,7 +194,7 @@ fn send_fails_when_xcm_router_blocks() { let message = Xcm(vec![ ReserveAssetDeposited((Parent, SEND_AMOUNT).into()), buy_execution((Parent, SEND_AMOUNT)), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: sender.clone() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: sender.clone() }, ]); assert_noop!( XcmPallet::send( @@ -235,7 +235,7 @@ fn teleport_assets_works() { ReceiveTeleportedAsset((Here, SEND_AMOUNT).into()), ClearOrigin, buy_limited_execution((Here, SEND_AMOUNT), 2000), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] ); @@ -281,7 +281,7 @@ fn reserve_transfer_assets_works() { ReserveAssetDeposited((Parent, SEND_AMOUNT).into()), ClearOrigin, buy_limited_execution((Parent, SEND_AMOUNT), 2000), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] ); @@ -312,7 +312,7 @@ fn execute_withdraw_to_deposit_works() { Box::new(VersionedXcm::from(Xcm(vec![ WithdrawAsset((Here, SEND_AMOUNT).into()), buy_execution((Here, SEND_AMOUNT)), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]))), weight )); @@ -344,7 +344,7 @@ fn trapped_assets_can_be_claimed() { // This will make an error. Trap(0), // This would succeed, but we never get to it. - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest.clone() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest.clone() }, ]))), weight )); @@ -374,7 +374,7 @@ fn trapped_assets_can_be_claimed() { Box::new(VersionedXcm::from(Xcm(vec![ ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() }, buy_execution((Here, SEND_AMOUNT)), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest.clone() }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest.clone() }, ]))), weight )); @@ -389,7 +389,7 @@ fn trapped_assets_can_be_claimed() { Box::new(VersionedXcm::from(Xcm(vec![ ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() }, buy_execution((Here, SEND_AMOUNT)), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]))), weight )); diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 3024883b7190..a8b9244919ae 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -650,7 +650,7 @@ pub enum Instruction { /// Query the existence of a particular pallet type. /// - /// - `name`: The name of the pallet to query. + /// - `module_name`: The module name of the pallet to query. /// - `response_info`: Information for making the response. /// /// Sends a `QueryResponse` to Origin whose data field `PalletsInfo` containing the information @@ -662,7 +662,7 @@ pub enum Instruction { /// Kind: *Instruction* /// /// Errors: *Fallible*. - QueryPallet { name: Vec, response_info: QueryResponseInfo }, + QueryPallet { module_name: Vec, response_info: QueryResponseInfo }, /// Ensure that a particular pallet with a particular version exists. /// @@ -767,7 +767,7 @@ impl Instruction { ExpectAsset(assets) => ExpectAsset(assets), ExpectOrigin(origin) => ExpectOrigin(origin), ExpectError(error) => ExpectError(error), - QueryPallet { name, response_info } => QueryPallet { name, response_info }, + QueryPallet { module_name, response_info } => QueryPallet { module_name, response_info }, ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => ExpectPallet { index, name, module_name, crate_major, min_crate_minor }, ReportTransactStatus(repsonse_info) => ReportTransactStatus(repsonse_info), @@ -961,7 +961,7 @@ mod tests { OldInstruction::ReceiveTeleportedAsset((Here, 1).into()), OldInstruction::ClearOrigin, OldInstruction::DepositAsset { - assets: Wild(All), + assets: crate::v2::MultiAssetFilter::Wild(crate::v2::WildMultiAsset::All), max_assets: 1, beneficiary: Here.into(), }, @@ -984,7 +984,7 @@ mod tests { OldInstruction::ClearOrigin, OldInstruction::BuyExecution { fees: (Here, 1).into(), weight_limit: Some(1).into() }, OldInstruction::DepositAsset { - assets: Wild(All), + assets: crate::v2::MultiAssetFilter::Wild(crate::v2::WildMultiAsset::All), max_assets: 1, beneficiary: Here.into(), }, diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 24f0f10bf30b..5b106d5364fe 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -327,7 +327,7 @@ pub type SendResult = result::Result<(), SendError>; /// # fn main() { /// let call: Vec = ().encode(); /// let message = Xcm(vec![Instruction::Transact { -/// origin_type: OriginKind::Superuser, +/// origin_kind: OriginKind::Superuser, /// require_weight_at_most: 0, /// call: call.into(), /// }]); diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index 94682e6d262c..fe090aa4de86 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -306,7 +306,7 @@ impl ClaimAssets for TestAssetTrap { parameter_types! { pub static SubscriptionRequests: Vec<(MultiLocation, Option<(QueryId, u64)>)> = vec![]; - pub static MaxHoldingAssetCount: usize = 4; + pub static MaxHoldingAssetCount: u32 = 4; } pub struct TestSubscriptionService; diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index db031a91361c..b4242801f778 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -153,7 +153,7 @@ parameter_types! { pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (MultiAssetFilter::Wild(WildMultiAsset::AllOf { id: Concrete(MultiLocation::here()), fun: WildFungible }), X1(Parachain(1000)).into()); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: usize = 4; + pub const MaxHoldingAssetCount: u32 = 4; } pub type TrustedTeleporters = (xcm_builder::Case,); diff --git a/xcm/xcm-executor/integration-tests/src/lib.rs b/xcm/xcm-executor/integration-tests/src/lib.rs index a6673aca7a92..9e82ea95a30b 100644 --- a/xcm/xcm-executor/integration-tests/src/lib.rs +++ b/xcm/xcm-executor/integration-tests/src/lib.rs @@ -37,7 +37,7 @@ fn basic_buy_fees_message_executes() { let msg = Xcm(vec![ WithdrawAsset((Parent, 100).into()), BuyExecution { fees: (Parent, 1).into(), weight_limit: Unlimited }, - DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Parent.into() }, + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parent.into() }, ]); let mut block_builder = client.init_polkadot_block_builder(); diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 4533428e8bf2..77c0e8975c42 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -77,5 +77,5 @@ pub trait Config { /// /// NOTE: In the worse case, the Holding Register may contain up to twice as many assets as this /// and any benchmarks should take that into account. - type MaxHoldingAssetCount: Get; + type MaxHoldingAssetCount: Get; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index dfcb907408da..1e494bc5c955 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -158,7 +158,7 @@ impl XcmExecutor { let origin = origin.into(); Self { holding: Assets::new(), - holding_limit: Config::MaxHoldingAssetCount::get(), + holding_limit: Config::MaxHoldingAssetCount::get() as usize, origin: Some(origin.clone()), original_origin: origin, trader: Config::Trader::new(), @@ -479,10 +479,10 @@ impl XcmExecutor { ensure!(self.error == error, XcmError::ExpectationFalse); Ok(()) }, - QueryPallet { name, response_info } => { + QueryPallet { module_name, response_info } => { let pallets = Config::PalletInstancesInfo::infos() .into_iter() - .filter(|x| x.name.as_bytes() == &name[..]) + .filter(|x| x.module_name.as_bytes() == &module_name[..]) .map(|x| PalletInfo { index: x.index as u32, name: x.name.as_bytes().into(), diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index 2707c69c7f42..3a07db375ee4 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -106,7 +106,7 @@ mod tests { use codec::Encode; use frame_support::assert_ok; - use xcm::latest::prelude::*; + use xcm::latest::{QueryResponseInfo, prelude::*}; use xcm_simulator::TestExt; // Helper function for forming buy execution message @@ -127,7 +127,7 @@ mod tests { Here, Parachain(1), Xcm(vec![Transact { - origin_type: OriginKind::SovereignAccount, + origin_kind: OriginKind::SovereignAccount, require_weight_at_most: INITIAL_BALANCE as u64, call: remark.encode().into(), }]), @@ -154,7 +154,7 @@ mod tests { Here, Parent, Xcm(vec![Transact { - origin_type: OriginKind::SovereignAccount, + origin_kind: OriginKind::SovereignAccount, require_weight_at_most: INITIAL_BALANCE as u64, call: remark.encode().into(), }]), @@ -182,7 +182,7 @@ mod tests { Here, (Parent, Parachain(2)), Xcm(vec![Transact { - origin_type: OriginKind::SovereignAccount, + origin_kind: OriginKind::SovereignAccount, require_weight_at_most: INITIAL_BALANCE as u64, call: remark.encode().into(), }]), @@ -241,8 +241,7 @@ mod tests { WithdrawAsset((Here, send_amount).into()), buy_execution((Here, send_amount)), DepositAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), beneficiary: Parachain(2).into(), }, ]); @@ -277,15 +276,16 @@ mod tests { WithdrawAsset((Here, send_amount).into()), buy_execution((Here, send_amount)), DepositAsset { - assets: All.into(), - max_assets: 1, + assets: AllCounted(1).into(), beneficiary: Parachain(2).into(), }, - QueryHolding { - query_id: query_id_set, - dest: Parachain(1).into(), + ReportHolding { + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: query_id_set, + max_weight: 1_000_000_000, + }, assets: All.into(), - max_response_weight: 1_000_000_000, }, ]); // Send withdraw and deposit with query holding diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 8d68b498ca21..5be6d4684a88 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -122,6 +122,7 @@ parameter_types! { pub const UnitWeightCost: Weight = 1; pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 64; } pub type LocalAssetTransactor = @@ -146,6 +147,7 @@ impl Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type MaxHoldingAssetCount = MaxHoldingAssetCount; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 8dcb5f1f310b..dfe235d2a954 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -117,6 +117,7 @@ parameter_types! { pub const BaseXcmWeight: Weight = 1_000; pub KsmPerSecond: (AssetId, u128) = (Concrete(KsmLocation::get()), 1); pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 64; } pub type XcmRouter = super::RelayChainXcmRouter; @@ -138,6 +139,7 @@ impl Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type MaxHoldingAssetCount = MaxHoldingAssetCount; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 3911bf8e3578..96c527fee69b 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -122,6 +122,7 @@ parameter_types! { pub const UnitWeightCost: Weight = 1; pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 64; } pub type LocalAssetTransactor = @@ -146,6 +147,7 @@ impl Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type MaxHoldingAssetCount = MaxHoldingAssetCount; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 8dcb5f1f310b..dfe235d2a954 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -117,6 +117,7 @@ parameter_types! { pub const BaseXcmWeight: Weight = 1_000; pub KsmPerSecond: (AssetId, u128) = (Concrete(KsmLocation::get()), 1); pub const MaxInstructions: u32 = 100; + pub const MaxHoldingAssetCount: u32 = 64; } pub type XcmRouter = super::RelayChainXcmRouter; @@ -138,6 +139,7 @@ impl Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type MaxHoldingAssetCount = MaxHoldingAssetCount; } pub type LocalOriginToLocation = SignedToAccountId32; From 756d05eec945dfdc227ac0efc034ae3806f442a9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 21:32:11 +0200 Subject: [PATCH 022/231] Fixes --- runtime/westend/src/weights/xcm/mod.rs | 4 +--- xcm/xcm-simulator/example/src/parachain.rs | 1 + xcm/xcm-simulator/example/src/relay_chain.rs | 1 + xcm/xcm-simulator/fuzzer/src/parachain.rs | 1 + xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 123fa2b13f75..3515c16db6d2 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -155,10 +155,8 @@ impl XcmWeightInfo for WestendXcmWeight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } fn report_holding( - _query_id: &u64, - _dest: &MultiLocation, + _response_info: &QueryResponseInfo, _assets: &MultiAssetFilter, - _max_response_weight: &u64, ) -> Weight { XcmGeneric::::report_holding() } diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 5be6d4684a88..b4028b78f201 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -147,6 +147,7 @@ impl Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type PalletInstancesInfo = (); type MaxHoldingAssetCount = MaxHoldingAssetCount; } diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index dfe235d2a954..b8b2c7f6e314 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -139,6 +139,7 @@ impl Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type PalletInstancesInfo = (); type MaxHoldingAssetCount = MaxHoldingAssetCount; } diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 96c527fee69b..be64a968f583 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -147,6 +147,7 @@ impl Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type PalletInstancesInfo = (); type MaxHoldingAssetCount = MaxHoldingAssetCount; } diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index dfe235d2a954..b8b2c7f6e314 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -139,6 +139,7 @@ impl Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); + type PalletInstancesInfo = (); type MaxHoldingAssetCount = MaxHoldingAssetCount; } From b6c63f81c5e9f89becb231a848ed6a6b01adccc4 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 21 Oct 2021 23:54:45 +0200 Subject: [PATCH 023/231] Fixes --- xcm/xcm-executor/integration-tests/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/xcm-executor/integration-tests/src/lib.rs b/xcm/xcm-executor/integration-tests/src/lib.rs index 9e82ea95a30b..5f49aa2384f0 100644 --- a/xcm/xcm-executor/integration-tests/src/lib.rs +++ b/xcm/xcm-executor/integration-tests/src/lib.rs @@ -154,7 +154,7 @@ fn query_response_fires() { assert_eq!( polkadot_test_runtime::Xcm::query(query_id), Some(QueryStatus::Ready { - response: VersionedResponse::V2(Response::ExecutionResult(None)), + response: VersionedResponse::V3(Response::ExecutionResult(None)), at: 2u32.into() }), ) From 25a69b7388d24f05e2a76748211bb0a25716419c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 00:54:11 +0200 Subject: [PATCH 024/231] Formatting --- runtime/westend/src/weights/xcm/mod.rs | 10 ++-------- xcm/src/v3/mod.rs | 3 ++- xcm/xcm-simulator/example/src/lib.rs | 12 +++--------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 3515c16db6d2..f88dcf5d093c 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -124,10 +124,7 @@ impl XcmWeightInfo for WestendXcmWeight { XcmGeneric::::relayed_from() } - fn deposit_asset( - assets: &MultiAssetFilter, - _dest: &MultiLocation, - ) -> Weight { + fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset( @@ -154,10 +151,7 @@ impl XcmWeightInfo for WestendXcmWeight { ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } - fn report_holding( - _response_info: &QueryResponseInfo, - _assets: &MultiAssetFilter, - ) -> Weight { + fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight { XcmGeneric::::report_holding() } fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index a8b9244919ae..f62713188a32 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -767,7 +767,8 @@ impl Instruction { ExpectAsset(assets) => ExpectAsset(assets), ExpectOrigin(origin) => ExpectOrigin(origin), ExpectError(error) => ExpectError(error), - QueryPallet { module_name, response_info } => QueryPallet { module_name, response_info }, + QueryPallet { module_name, response_info } => + QueryPallet { module_name, response_info }, ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => ExpectPallet { index, name, module_name, crate_major, min_crate_minor }, ReportTransactStatus(repsonse_info) => ReportTransactStatus(repsonse_info), diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index 3a07db375ee4..e21e217a75ce 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -106,7 +106,7 @@ mod tests { use codec::Encode; use frame_support::assert_ok; - use xcm::latest::{QueryResponseInfo, prelude::*}; + use xcm::latest::{prelude::*, QueryResponseInfo}; use xcm_simulator::TestExt; // Helper function for forming buy execution message @@ -240,10 +240,7 @@ mod tests { let message = Xcm(vec![ WithdrawAsset((Here, send_amount).into()), buy_execution((Here, send_amount)), - DepositAsset { - assets: AllCounted(1).into(), - beneficiary: Parachain(2).into(), - }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Parachain(2).into() }, ]); // Send withdraw and deposit assert_ok!(ParachainPalletXcm::send_xcm(Here, Parent, message.clone())); @@ -275,10 +272,7 @@ mod tests { let message = Xcm(vec![ WithdrawAsset((Here, send_amount).into()), buy_execution((Here, send_amount)), - DepositAsset { - assets: AllCounted(1).into(), - beneficiary: Parachain(2).into(), - }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Parachain(2).into() }, ReportHolding { response_info: QueryResponseInfo { destination: Parachain(1).into(), From 37384ae0fbc666e6a147d8272494b85c3434da98 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 01:11:50 +0200 Subject: [PATCH 025/231] Missing file --- xcm/src/v3/multiasset.rs | 214 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 xcm/src/v3/multiasset.rs diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs new file mode 100644 index 000000000000..07d23619363b --- /dev/null +++ b/xcm/src/v3/multiasset.rs @@ -0,0 +1,214 @@ +// Copyright 2020 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Cross-Consensus Message format asset data structures. +//! +//! This encompasses four types for representing assets: +//! - `MultiAsset`: A description of a single asset, either an instance of a non-fungible or some amount of a fungible. +//! - `MultiAssets`: A collection of `MultiAsset`s. These are stored in a `Vec` and sorted with fungibles first. +//! - `Wild`: A single asset wildcard, this can either be "all" assets, or all assets of a specific kind. +//! - `MultiAssetFilter`: A combination of `Wild` and `MultiAssets` designed for efficiently filtering an XCM holding +//! account. + +use super::MultiLocation; +use crate::v2::{MultiAssetFilter as OldMultiAssetFilter, WildMultiAsset as OldWildMultiAsset}; +use alloc::{vec, vec::Vec}; +use core::convert::TryFrom; +use parity_scale_codec::{Decode, Encode}; +use scale_info::TypeInfo; + +/// These are unchanged from XCM version 2 to version 3. +pub use crate::v2::{ + AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssets, WildFungibility, +}; + +/// A wildcard representing a set of assets. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +pub enum WildMultiAsset { + /// All assets in Holding. + All, + /// All assets in Holding of a given fungibility and ID. + AllOf { id: AssetId, fun: WildFungibility }, + /// All assets in Holding, up to `u32` individual assets (different instances of non-fungibles + /// are separate assets). + AllCounted(#[codec(compact)] u32), + /// All assets in Holding of a given fungibility and ID up to `count` individual assets + /// (different instances of non-fungibles are separate assets). + AllOfCounted { + id: AssetId, + fun: WildFungibility, + #[codec(compact)] + count: u32, + }, +} + +impl From for WildMultiAsset { + fn from(old: OldWildMultiAsset) -> WildMultiAsset { + use OldWildMultiAsset::*; + match old { + AllOf { id, fun } => Self::AllOf { id, fun }, + All => Self::All, + } + } +} + +impl From<(OldWildMultiAsset, u32)> for WildMultiAsset { + fn from(old: (OldWildMultiAsset, u32)) -> WildMultiAsset { + use OldWildMultiAsset::*; + let count = old.1; + match old.0 { + AllOf { id, fun } => Self::AllOfCounted { id, fun, count }, + All => Self::AllCounted(count), + } + } +} + +impl WildMultiAsset { + /// Returns true if the wild element of `self` matches `inner`. + /// + /// Note that for `Counted` variants of wildcards, then it will disregard the count except for + /// always returning `false` when equal to 0. + pub fn matches(&self, inner: &MultiAsset) -> bool { + use WildMultiAsset::*; + match self { + AllOfCounted { count: 0, .. } | AllCounted(0) => false, + AllOf { fun, id } | AllOfCounted { id, fun, .. } => + inner.fun.is_kind(*fun) && &inner.id == id, + All | AllCounted(_) => true, + } + } + + /// Prepend a `MultiLocation` to any concrete asset components, giving it a new root location. + pub fn reanchor(&mut self, prepend: &MultiLocation) -> Result<(), ()> { + use WildMultiAsset::*; + match self { + AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } => + id.reanchor(prepend).map_err(|_| ()), + All | AllCounted(_) => Ok(()), + } + } + + /// Maximum count of assets allowed to match, if any. + pub fn count(&self) -> Option { + use WildMultiAsset::*; + match self { + AllOfCounted { count, .. } | AllCounted(count) => Some(*count), + All | AllOf { .. } => None, + } + } + + /// Explicit limit on number of assets allowed to match, if any. + pub fn limit(&self) -> Option { + self.count() + } +} + +impl, B: Into> From<(A, B)> for WildMultiAsset { + fn from((id, fun): (A, B)) -> WildMultiAsset { + WildMultiAsset::AllOf { fun: fun.into(), id: id.into() } + } +} + +/// `MultiAsset` collection, either `MultiAssets` or a single wildcard. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +pub enum MultiAssetFilter { + Definite(MultiAssets), + Wild(WildMultiAsset), +} + +impl> From for MultiAssetFilter { + fn from(x: T) -> Self { + Self::Wild(x.into()) + } +} + +impl From for MultiAssetFilter { + fn from(x: MultiAsset) -> Self { + Self::Definite(vec![x].into()) + } +} + +impl From> for MultiAssetFilter { + fn from(x: Vec) -> Self { + Self::Definite(x.into()) + } +} + +impl From for MultiAssetFilter { + fn from(x: MultiAssets) -> Self { + Self::Definite(x) + } +} + +impl MultiAssetFilter { + /// Returns true if `inner` would be matched by `self`. + /// + /// Note that for `Counted` variants of wildcards, then it will disregard the count except for + /// always returning `false` when equal to 0. + pub fn matches(&self, inner: &MultiAsset) -> bool { + match self { + MultiAssetFilter::Definite(ref assets) => assets.contains(inner), + MultiAssetFilter::Wild(ref wild) => wild.matches(inner), + } + } + + /// Prepend a `MultiLocation` to any concrete asset components, giving it a new root location. + pub fn reanchor(&mut self, prepend: &MultiLocation) -> Result<(), ()> { + match self { + MultiAssetFilter::Definite(ref mut assets) => assets.reanchor(prepend), + MultiAssetFilter::Wild(ref mut wild) => wild.reanchor(prepend), + } + } + + /// Maximum count of assets it is possible to match, if known. + pub fn count(&self) -> Option { + use MultiAssetFilter::*; + match self { + Definite(x) => Some(x.len() as u32), + Wild(x) => x.count(), + } + } + + /// Explicit limit placed on the number of items, if any. + pub fn limit(&self) -> Option { + use MultiAssetFilter::*; + match self { + Definite(_) => None, + Wild(x) => x.limit(), + } + } +} + +impl From for MultiAssetFilter { + fn from(old: OldMultiAssetFilter) -> MultiAssetFilter { + match old { + OldMultiAssetFilter::Definite(x) => Self::Definite(x.into()), + OldMultiAssetFilter::Wild(x) => Self::Wild(x.into()), + } + } +} + +impl TryFrom<(OldMultiAssetFilter, u32)> for MultiAssetFilter { + type Error = (); + fn try_from(old: (OldMultiAssetFilter, u32)) -> Result { + let count = old.1; + Ok(match old.0 { + OldMultiAssetFilter::Definite(x) if count >= x.len() as u32 => Self::Definite(x.into()), + OldMultiAssetFilter::Wild(x) => Self::Wild((x, count).into()), + _ => return Err(()), + }) + } +} From 63e3c82c7b838cf8b78f9b72014c0574937003e7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 21 Oct 2021 17:07:31 -0700 Subject: [PATCH 026/231] Fix tests --- xcm/pallet-xcm/src/tests.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index fa0192ba7dbc..cd719e5ea91d 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -429,7 +429,7 @@ fn basic_subscription_works() { ); assert_eq!( VersionNotifiers::::iter().collect::>(), - vec![(2, remote.clone().into(), 0)] + vec![(XCM_VERSION, remote.clone().into(), 0)] ); assert_eq!( @@ -610,9 +610,9 @@ fn subscription_side_upgrades_work_with_notify() { assert_eq!( contents, vec![ - (2, Parachain(1000).into().versioned(), (69, 0, 2)), - (2, Parachain(1001).into().versioned(), (70, 0, 2)), - (2, Parachain(1002).into().versioned(), (71, 0, 2)), + (XCM_VERSION, Parachain(1000).into().versioned(), (69, 0, 2)), + (XCM_VERSION, Parachain(1001).into().versioned(), (70, 0, 2)), + (XCM_VERSION, Parachain(1002).into().versioned(), (71, 0, 2)), ] ); }); @@ -639,9 +639,9 @@ fn subscription_side_upgrades_work_without_notify() { assert_eq!( contents, vec![ - (2, Parachain(1000).into().versioned(), (69, 0, 2)), - (2, Parachain(1001).into().versioned(), (70, 0, 2)), - (2, Parachain(1002).into().versioned(), (71, 0, 2)), + (XCM_VERSION, Parachain(1000).into().versioned(), (69, 0, 2)), + (XCM_VERSION, Parachain(1001).into().versioned(), (70, 0, 2)), + (XCM_VERSION, Parachain(1002).into().versioned(), (71, 0, 2)), ] ); }); @@ -669,7 +669,7 @@ fn subscriber_side_subscription_works() { assert_eq!(take_sent_xcm(), vec![]); // This message cannot be sent to a v1 remote. - let v2_msg = Xcm::<()>(vec![Trap(0)]); + let v2_msg = xcm::v2::Xcm::<()>(vec![xcm::v2::Instruction::Trap(0)]); assert_eq!(XcmPallet::wrap_version(&remote, v2_msg.clone()), Err(())); let message = Xcm(vec![ @@ -701,7 +701,7 @@ fn auto_subscription_works() { query_id: 1, response: xcm::v1::Response::Assets(vec![].into()), }; - let v2_msg = Xcm::<()>(vec![Trap(0)]); + let v2_msg = xcm::v2::Xcm::<()>(vec![xcm::v2::Instruction::Trap(0)]); assert_eq!( XcmPallet::wrap_version(&remote0, v1_msg.clone()), Ok(VersionedXcm::from(v1_msg.clone())), @@ -815,9 +815,9 @@ fn subscription_side_upgrades_work_with_multistage_notify() { assert_eq!( contents, vec![ - (2, Parachain(1000).into().versioned(), (69, 0, 2)), - (2, Parachain(1001).into().versioned(), (70, 0, 2)), - (2, Parachain(1002).into().versioned(), (71, 0, 2)), + (XCM_VERSION, Parachain(1000).into().versioned(), (69, 0, 2)), + (XCM_VERSION, Parachain(1001).into().versioned(), (70, 0, 2)), + (XCM_VERSION, Parachain(1002).into().versioned(), (71, 0, 2)), ] ); }); From 50c9e89d50d492f67d06ff6fe2224138b79dd21c Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 21 Oct 2021 18:58:21 -0700 Subject: [PATCH 027/231] Add Deposit(Reserve)?Asset roundtrip test --- xcm/src/v3/mod.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index f62713188a32..af2c937ef8b4 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -937,6 +937,7 @@ impl TryFrom> for Instruction { #[cfg(test)] mod tests { use super::{prelude::*, *}; + use crate::v2::{MultiAssetFilter as OldMultiAssetFilter, WildMultiAsset as OldWildMultiAsset}; #[test] fn basic_roundtrip_works() { @@ -994,4 +995,47 @@ mod tests { let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); assert_eq!(new_xcm, xcm); } + + #[test] + fn deposit_asset_roundtrip_works() { + let xcm = Xcm::<()>(vec![ + WithdrawAsset((Here, 1).into()), + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, + ]); + let old_xcm = OldXcm::<()>(vec![ + OldInstruction::WithdrawAsset((Here, 1).into()), + OldInstruction::DepositAsset { + assets: OldMultiAssetFilter::Wild(OldWildMultiAsset::All), + max_assets: 1, + beneficiary: Here.into(), + }, + ]); + assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); + let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); + assert_eq!(new_xcm, xcm); + } + + #[test] + fn deposit_reserve_asset_roundtrip_works() { + let xcm = Xcm::<()>(vec![ + WithdrawAsset((Here, 1).into()), + DepositReserveAsset { + assets: Wild(AllCounted(1)), + dest: Here.into(), + xcm: Xcm::<()>(vec![]), + }, + ]); + let old_xcm = OldXcm::<()>(vec![ + OldInstruction::WithdrawAsset((Here, 1).into()), + OldInstruction::DepositReserveAsset { + assets: OldMultiAssetFilter::Wild(OldWildMultiAsset::All), + max_assets: 1, + dest: Here.into(), + xcm: OldXcm::<()>(vec![]), + }, + ]); + assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); + let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); + assert_eq!(new_xcm, xcm); + } } From 31c4e68ba282181079cee4a95055f9b2bb4ddf18 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 10:49:17 +0200 Subject: [PATCH 028/231] Fixes --- .../src/fungible/benchmarking.rs | 8 ++++---- xcm/pallet-xcm-benchmarks/src/lib.rs | 17 ++++++++++------- xcm/pallet-xcm/src/tests.rs | 2 +- xcm/xcm-executor/src/lib.rs | 11 ++++++++--- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 469ba731338f..c535df1426f0 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -38,7 +38,7 @@ benchmarks_instance_pallet! { withdraw_asset { let (sender_account, sender_location) = account_and_location::(1); - let worst_case_holding = worst_case_holding(); + let worst_case_holding = worst_case_holding::(0); let asset = T::get_multi_asset(); >::deposit_asset(&asset, &sender_location).unwrap(); @@ -129,7 +129,7 @@ benchmarks_instance_pallet! { deposit_asset { let asset = T::get_multi_asset(); - let mut holding = worst_case_holding(); + let mut holding = worst_case_holding::(1); // Add our asset to the holding. holding.subsume(asset.clone()); @@ -155,7 +155,7 @@ benchmarks_instance_pallet! { deposit_reserve_asset { let asset = T::get_multi_asset(); - let mut holding = worst_case_holding(); + let mut holding = worst_case_holding::(1); // Add our asset to the holding. holding.subsume(asset.clone()); @@ -182,7 +182,7 @@ benchmarks_instance_pallet! { initiate_teleport { let asset = T::get_multi_asset(); - let mut holding = worst_case_holding(); + let mut holding = worst_case_holding::(0); // Add our asset to the holding. holding.subsume(asset.clone()); diff --git a/xcm/pallet-xcm-benchmarks/src/lib.rs b/xcm/pallet-xcm-benchmarks/src/lib.rs index cfbb3a478f67..aac155c07407 100644 --- a/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -20,9 +20,10 @@ use codec::Encode; use frame_benchmarking::account; +use frame_support::traits::Get; use sp_std::prelude::*; use xcm::latest::prelude::*; -use xcm_executor::{traits::Convert, Assets}; +use xcm_executor::{traits::Convert, Assets, Config as XcmConfig}; pub mod fungible; @@ -35,7 +36,7 @@ pub trait Config: frame_system::Config { /// /// These might affect the execution of XCM messages, such as defining how the /// `TransactAsset` is implemented. - type XcmConfig: xcm_executor::Config; + type XcmConfig: XcmConfig; /// A converter between a multi-location to a sovereign account. type AccountIdConverter: Convert; @@ -52,17 +53,19 @@ pub type ExecutorOf = xcm_executor::XcmExecutor<::XcmConfig>; /// The overarching call type. pub type OverArchingCallOf = ::Call; /// The asset transactor of our executor -pub type AssetTransactorOf = <::XcmConfig as xcm_executor::Config>::AssetTransactor; +pub type AssetTransactorOf = <::XcmConfig as XcmConfig>::AssetTransactor; /// The call type of executor's config. Should eventually resolve to the same overarching call type. -pub type XcmCallOf = <::XcmConfig as xcm_executor::Config>::Call; +pub type XcmCallOf = <::XcmConfig as XcmConfig>::Call; /// The worst case number of assets in the holding. const HOLDING_FUNGIBLES: u32 = 99; const HOLDING_NON_FUNGIBLES: u32 = 99; -pub fn worst_case_holding() -> Assets { +pub fn worst_case_holding(depositable_count: u32) -> Assets { let fungibles_amount: u128 = 100; // TODO probably update - (0..HOLDING_FUNGIBLES) + let holding_fungibles = (::MaxHoldingAssetCount::get()) / 2 - depositable_count; + let holding_non_fungibles = holding_fungibles; + (0..holding_fungibles) .map(|i| { MultiAsset { id: Concrete(GeneralIndex(i as u128).into()), @@ -71,7 +74,7 @@ pub fn worst_case_holding() -> Assets { .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) - .chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset { + .chain((0..holding_non_fungibles).map(|i| MultiAsset { id: Concrete(GeneralIndex(i as u128).into()), fun: NonFungible(asset_instance_from(i)), })) diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index cd719e5ea91d..a12c396f245a 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -668,7 +668,7 @@ fn subscriber_side_subscription_works() { assert_eq!(r, Outcome::Complete(weight)); assert_eq!(take_sent_xcm(), vec![]); - // This message cannot be sent to a v1 remote. + // This message cannot be sent to a v2 remote. let v2_msg = xcm::v2::Xcm::<()>(vec![xcm::v2::Instruction::Trap(0)]); assert_eq!(XcmPallet::wrap_version(&remote, v2_msg.clone()), Err(())); diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 1e494bc5c955..28a4dc098c4c 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -225,14 +225,19 @@ impl XcmExecutor { } fn subsume_asset(&mut self, asset: MultiAsset) -> Result<(), XcmError> { - ensure!(self.holding.len() <= self.holding_limit, XcmError::HoldingWouldOverflow); + // worst-case, holding.len becomes 2 * holding_limit. + ensure!(self.holding.len() + 1 <= self.holding_limit * 2, XcmError::HoldingWouldOverflow); self.holding.subsume(asset); Ok(()) } fn subsume_assets(&mut self, assets: Assets) -> Result<(), XcmError> { - ensure!(self.holding.len() <= self.holding_limit, XcmError::HoldingWouldOverflow); - ensure!(assets.len() <= self.holding_limit, XcmError::HoldingWouldOverflow); + // worst-case, holding.len becomes 2 * holding_limit. + // this guarantees that if holding.len() == holding_limit and you have holding_limit more + // items (which has a best case outcome of holding.len() == holding_limit), then you'll + // be guaranteed of making the operation. + let worst_case_holding_len = self.holding.len() + assets.len(); + ensure!(worst_case_holding_len <= self.holding_limit * 2, XcmError::HoldingWouldOverflow); self.holding.subsume_assets(assets); Ok(()) } From 722f1576f63d995a75a419261eec3ca44735067c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 10:53:53 +0200 Subject: [PATCH 029/231] Formatting --- runtime/kusama/src/lib.rs | 4 ++-- runtime/rococo/src/lib.rs | 4 ++-- runtime/test-runtime/src/xcm_config.rs | 4 ++-- runtime/westend/src/lib.rs | 4 ++-- xcm/pallet-xcm-benchmarks/src/fungible/mock.rs | 4 ++-- xcm/pallet-xcm-benchmarks/src/lib.rs | 3 ++- xcm/pallet-xcm/src/mock.rs | 4 ++-- xcm/xcm-builder/src/mock.rs | 4 ++-- xcm/xcm-builder/tests/mock/mod.rs | 4 ++-- xcm/xcm-executor/src/config.rs | 2 +- xcm/xcm-executor/src/lib.rs | 2 +- xcm/xcm-simulator/example/src/parachain.rs | 4 ++-- xcm/xcm-simulator/example/src/relay_chain.rs | 4 ++-- xcm/xcm-simulator/fuzzer/src/parachain.rs | 4 ++-- xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 4 ++-- 15 files changed, 28 insertions(+), 27 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index eb2e548833e4..27c3ef581b27 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1329,7 +1329,7 @@ pub type XcmRouter = ( parameter_types! { pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) }); pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1000).into()); - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = (xcm_builder::Case,); @@ -1361,7 +1361,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } parameter_types! { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 2bf76646d4c2..8a2c19f92da1 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -647,7 +647,7 @@ parameter_types! { pub const RococoForRockmine: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1001).into()); pub const RococoForCanvas: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1002).into()); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = ( xcm_builder::Case, @@ -692,7 +692,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } parameter_types! { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 90cbacdae9d2..632908deb271 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -25,7 +25,7 @@ use xcm_executor::{ parameter_types! { pub const OurNetwork: NetworkId = NetworkId::Polkadot; pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 16; + pub const MaxAssetsIntoHolding: u32 = 16; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location @@ -91,5 +91,5 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = super::Xcm; type SubscriptionService = super::Xcm; type PalletInstancesInfo = (); - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index ac84a5fa6835..19350aa64d11 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -966,7 +966,7 @@ parameter_types! { pub const WestendForWestmint: (MultiAssetFilter, MultiLocation) = (Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Westmint::get()); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = (xcm_builder::Case,); @@ -997,7 +997,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index c3d94a68733a..4d7902160c11 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -122,7 +122,7 @@ parameter_types! { /// Maximum number of instructions in a single XCM fragment. A sanity check against weight /// calculations getting too crazy. pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub struct XcmConfig; @@ -142,7 +142,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } impl crate::Config for Test { diff --git a/xcm/pallet-xcm-benchmarks/src/lib.rs b/xcm/pallet-xcm-benchmarks/src/lib.rs index aac155c07407..5d90763c823b 100644 --- a/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -63,7 +63,8 @@ const HOLDING_NON_FUNGIBLES: u32 = 99; pub fn worst_case_holding(depositable_count: u32) -> Assets { let fungibles_amount: u128 = 100; // TODO probably update - let holding_fungibles = (::MaxHoldingAssetCount::get()) / 2 - depositable_count; + let holding_fungibles = + (::MaxAssetsIntoHolding::get()) / 2 - depositable_count; let holding_non_fungibles = holding_fungibles; (0..holding_fungibles) .map(|i| { diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 1cda1f28e256..d105c3b6a970 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -239,7 +239,7 @@ parameter_types! { pub CurrencyPerSecond: (AssetId, u128) = (Concrete(RelayLocation::get()), 1); pub TrustedAssets: (MultiAssetFilter, MultiLocation) = (All.into(), Here.into()); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type Barrier = ( @@ -266,7 +266,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index fe090aa4de86..e4146980438e 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -306,7 +306,7 @@ impl ClaimAssets for TestAssetTrap { parameter_types! { pub static SubscriptionRequests: Vec<(MultiLocation, Option<(QueryId, u64)>)> = vec![]; - pub static MaxHoldingAssetCount: u32 = 4; + pub static MaxAssetsIntoHolding: u32 = 4; } pub struct TestSubscriptionService; @@ -342,5 +342,5 @@ impl Config for TestConfig { type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; type PalletInstancesInfo = (); // TODO: TestAllPallets, for testing new instructions. - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index b4242801f778..f490cb0fbf9b 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -153,7 +153,7 @@ parameter_types! { pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (MultiAssetFilter::Wild(WildMultiAsset::AllOf { id: Concrete(MultiLocation::here()), fun: WildFungible }), X1(Parachain(1000)).into()); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 4; + pub const MaxAssetsIntoHolding: u32 = 4; } pub type TrustedTeleporters = (xcm_builder::Case,); @@ -174,7 +174,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPallets; - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 77c0e8975c42..aff5a129d633 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -77,5 +77,5 @@ pub trait Config { /// /// NOTE: In the worse case, the Holding Register may contain up to twice as many assets as this /// and any benchmarks should take that into account. - type MaxHoldingAssetCount: Get; + type MaxAssetsIntoHolding: Get; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 28a4dc098c4c..ba721ced4aae 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -158,7 +158,7 @@ impl XcmExecutor { let origin = origin.into(); Self { holding: Assets::new(), - holding_limit: Config::MaxHoldingAssetCount::get() as usize, + holding_limit: Config::MaxAssetsIntoHolding::get() as usize, origin: Some(origin.clone()), original_origin: origin, trader: Config::Trader::new(), diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index b4028b78f201..eb8a61bb0d14 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -122,7 +122,7 @@ parameter_types! { pub const UnitWeightCost: Weight = 1; pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type LocalAssetTransactor = @@ -148,7 +148,7 @@ impl Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index b8b2c7f6e314..951d533c4e96 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -117,7 +117,7 @@ parameter_types! { pub const BaseXcmWeight: Weight = 1_000; pub KsmPerSecond: (AssetId, u128) = (Concrete(KsmLocation::get()), 1); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type XcmRouter = super::RelayChainXcmRouter; @@ -140,7 +140,7 @@ impl Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index be64a968f583..07fe752618e3 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -122,7 +122,7 @@ parameter_types! { pub const UnitWeightCost: Weight = 1; pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type LocalAssetTransactor = @@ -148,7 +148,7 @@ impl Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index b8b2c7f6e314..951d533c4e96 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -117,7 +117,7 @@ parameter_types! { pub const BaseXcmWeight: Weight = 1_000; pub KsmPerSecond: (AssetId, u128) = (Concrete(KsmLocation::get()), 1); pub const MaxInstructions: u32 = 100; - pub const MaxHoldingAssetCount: u32 = 64; + pub const MaxAssetsIntoHolding: u32 = 64; } pub type XcmRouter = super::RelayChainXcmRouter; @@ -140,7 +140,7 @@ impl Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); - type MaxHoldingAssetCount = MaxHoldingAssetCount; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } pub type LocalOriginToLocation = SignedToAccountId32; From 9f2773b022fea4a21c95759681ad39e5f7828b19 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 13:52:27 +0200 Subject: [PATCH 030/231] Fixes --- xcm/pallet-xcm-benchmarks/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/lib.rs b/xcm/pallet-xcm-benchmarks/src/lib.rs index 5d90763c823b..ae5ef11d8fc4 100644 --- a/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -57,10 +57,6 @@ pub type AssetTransactorOf = <::XcmConfig as XcmConfig>::AssetTr /// The call type of executor's config. Should eventually resolve to the same overarching call type. pub type XcmCallOf = <::XcmConfig as XcmConfig>::Call; -/// The worst case number of assets in the holding. -const HOLDING_FUNGIBLES: u32 = 99; -const HOLDING_NON_FUNGIBLES: u32 = 99; - pub fn worst_case_holding(depositable_count: u32) -> Assets { let fungibles_amount: u128 = 100; // TODO probably update let holding_fungibles = From 7b620d4ea22cdf103cf077bd61a6ee910b187e8d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 14:02:24 +0200 Subject: [PATCH 031/231] Fixes --- bridges/primitives/chain-rococo/src/lib.rs | 2 +- runtime/kusama/src/lib.rs | 2 +- runtime/polkadot/src/lib.rs | 2 +- runtime/rococo/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index b4faae00eeb3..303a0d49ac66 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -42,7 +42,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: sp_version::create_runtime_str!("rococo"), impl_name: sp_version::create_runtime_str!("parity-rococo-v1.6"), authoring_version: 0, - spec_version: 9100, + spec_version: 9130, impl_version: 0, apis: sp_version::create_apis_vec![[]], transaction_version: 0, diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 27c3ef581b27..134b9166a1bf 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kusama"), impl_name: create_runtime_str!("parity-kusama"), authoring_version: 2, - spec_version: 9120, + spec_version: 9130, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index c43fbcb85393..12b028d752a3 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -105,7 +105,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("polkadot"), impl_name: create_runtime_str!("parity-polkadot"), authoring_version: 0, - spec_version: 9120, + spec_version: 9130, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 8a2c19f92da1..c5f58a390226 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -106,7 +106,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("rococo"), impl_name: create_runtime_str!("parity-rococo-v1.8"), authoring_version: 0, - spec_version: 9106, + spec_version: 9130, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 19350aa64d11..22d1f43f073a 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -116,7 +116,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("westend"), impl_name: create_runtime_str!("parity-westend"), authoring_version: 2, - spec_version: 9120, + spec_version: 9130, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, From 2648507b6ddde75bd6a6538a0182b1f4dbf875cb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 14:51:03 +0200 Subject: [PATCH 032/231] Fixes --- xcm/src/v1/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/src/v1/traits.rs b/xcm/src/v1/traits.rs index b0be0132c2de..d95d9e1eb84a 100644 --- a/xcm/src/v1/traits.rs +++ b/xcm/src/v1/traits.rs @@ -238,7 +238,7 @@ impl ExecuteXcm for () { /// // A call to send via XCM. We don't really care about this. /// # fn main() { /// let call: Vec = ().encode(); -/// let message = Xcm::Transact { origin_kind: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; +/// let message = Xcm::Transact { origin_type: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; /// /// assert!( /// // Sender2 will block this. From 5711b2c4f29c57a7610e77a826c00d8c57bdac0a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 14:52:11 +0200 Subject: [PATCH 033/231] Fixes --- xcm/src/v3/traits.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 5b106d5364fe..7a3e3a291a1a 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -288,7 +288,7 @@ pub type SendResult = result::Result<(), SendError>; /// /// # Example /// ```rust -/// # use xcm::v2::prelude::*; +/// # use xcm::v3::prelude::*; /// # use parity_scale_codec::Encode; /// /// /// A sender that only passes the message through and does nothing. @@ -327,7 +327,7 @@ pub type SendResult = result::Result<(), SendError>; /// # fn main() { /// let call: Vec = ().encode(); /// let message = Xcm(vec![Instruction::Transact { -/// origin_kind: OriginKind::Superuser, +/// origin_type: OriginKind::Superuser, /// require_weight_at_most: 0, /// call: call.into(), /// }]); From 5c25268840fca3db86f202258515947a2c670e2d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 14:52:43 +0200 Subject: [PATCH 034/231] Fixes --- xcm/src/v0/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/src/v0/traits.rs b/xcm/src/v0/traits.rs index 472f0c7aea93..3263fda4ac56 100644 --- a/xcm/src/v0/traits.rs +++ b/xcm/src/v0/traits.rs @@ -223,7 +223,7 @@ impl ExecuteXcm for () { /// // A call to send via XCM. We don't really care about this. /// # fn main() { /// let call: Vec = ().encode(); -/// let message = Xcm::Transact { origin_kind: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; +/// let message = Xcm::Transact { origin_type: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; /// let destination = MultiLocation::X1(Junction::Parent); /// /// assert!( From df32fb01bd207bff0b3d92c1e3b1cc2a53392f92 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 15:45:42 +0200 Subject: [PATCH 035/231] Fixes --- xcm/src/v3/traits.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 7a3e3a291a1a..2ff9d476fa07 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -327,7 +327,7 @@ pub type SendResult = result::Result<(), SendError>; /// # fn main() { /// let call: Vec = ().encode(); /// let message = Xcm(vec![Instruction::Transact { -/// origin_type: OriginKind::Superuser, +/// origin_kind: OriginKind::Superuser, /// require_weight_at_most: 0, /// call: call.into(), /// }]); @@ -378,7 +378,7 @@ pub trait XcmWeightInfo { fn transfer_asset(assets: &MultiAssets, beneficiary: &MultiLocation) -> Weight; fn transfer_reserve_asset(assets: &MultiAssets, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight; fn transact( - origin_type: &OriginKind, + origin_kind: &OriginKind, require_weight_at_most: &u64, call: &DoubleEncoded, ) -> Weight; From 87d996a0a72687abc1c6a2443a48d07182a814de Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 19:28:48 +0200 Subject: [PATCH 036/231] Fixes and spelling --- xcm/pallet-xcm/src/lib.rs | 2 +- xcm/src/v3/mod.rs | 2 +- xcm/src/v3/multiasset.rs | 10 ++++++++ xcm/xcm-executor/src/assets.rs | 29 ++++++++++++++++++++-- xcm/xcm-executor/src/traits/on_response.rs | 2 +- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 981bf3233cfd..9fcb48783ea4 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -1093,7 +1093,7 @@ pub mod pallet { /// Start notifying `location` should the XCM version of this chain change. /// /// When it does, this type should ensure a `QueryResponse` message is sent with the given - /// `query_id` & `max_weight` and with a `response` of `Repsonse::Version`. This should happen + /// `query_id` & `max_weight` and with a `response` of `Response::Version`. This should happen /// until/unless `stop` is called with the correct `query_id`. /// /// If the `location` has an ongoing notification and when this function is called, then an diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index af2c937ef8b4..0310a9f0c0fd 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -689,7 +689,7 @@ pub enum Instruction { min_crate_minor: u32, }, - /// Send a `QueryRepsonse` message containing the value of the Transact Status Register to some + /// Send a `QueryResponse` message containing the value of the Transact Status Register to some /// destination. /// /// - `query_response_info`: The information needed for constructing and sending the diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index 07d23619363b..7407aba831c1 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -114,6 +114,16 @@ impl WildMultiAsset { pub fn limit(&self) -> Option { self.count() } + + /// Consume self and return the equivalent version but counted and with the `count` set to the + /// given parameter. + pub fn counted(self, count: u32) -> Self { + use WildMultiAsset::*; + match self { + AllOfCounted { fun, id, .. } | AllOf { fun, id } => AllOfCounted { fun, id, count }, + All | AllCounted(_) => AllCounted(count), + } + } } impl, B: Into> From<(A, B)> for WildMultiAsset { diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index 2adc8ecf893d..c1d82ba36b3e 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -236,7 +236,8 @@ impl Assets { /// reducing it by assets it does not contain. In this case, the function is infallible. If `saturate` is `false` /// and `mask` references a definite asset which `self` does not contain then an error is returned. /// - /// The number of unique assets which are removed will never be any greater than `limit`. + /// The number of unique assets which are removed will respect the `count` parameter in the + /// counted wildcard variants. /// /// Returns `Ok` with the definite assets token from `self` and mutates `self` to its value minus /// `mask`. Returns `Err` in the non-saturating case where `self` did not contain (enough of) a definite asset to @@ -372,7 +373,8 @@ impl Assets { /// Return the assets in `self`, but (asset-wise) of no greater value than `mask`. /// - /// Result is undefined if `mask` includes elements which match to the same asset more than once. + /// The number of unique assets which are returned will respect the `count` parameter in the + /// counted wildcard variants of `mask`. /// /// Example: /// @@ -567,6 +569,29 @@ mod tests { assert!(all_min.assets_iter().eq(assets.assets_iter())); } + #[test] + fn min_counted_works() { + let mut assets = test_assets(); + assets.subsume(AF(1, 100)); + assets.subsume(ANF(2, 20)); + assets.subsume(CF(300)); + assets.subsume(CNF(40)); + // Push same group of tokens again + assets.subsume(AF(1, 100)); + assets.subsume(ANF(2, 20)); + assets.subsume(CF(300)); + assets.subsume(CNF(40)); + let fungible = WildMultiAsset::from((vec![1], WildFungible)).counted(2).into(); + let non_fungible = WildMultiAsset::from((vec![1], WildFungible)).counted(2).into(); + + let fungible = assets.min(&fungible); + let fungible = fungible.assets_iter().collect::>(); + assert_eq!(fungible, vec![AF(1, 100)]); + let non_fungible = assets.min(&non_fungible); + let non_fungible = non_fungible.assets_iter().collect::>(); + assert_eq!(non_fungible, vec![ANF(2, 20)]); + } + #[test] fn min_all_abstract_works() { let assets = test_assets(); diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index a34d5264c093..9d65b7471de5 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -48,7 +48,7 @@ pub trait VersionChangeNotifier { /// Start notifying `location` should the XCM version of this chain change. /// /// When it does, this type should ensure a `QueryResponse` message is sent with the given - /// `query_id` & `max_weight` and with a `response` of `Repsonse::Version`. This should happen + /// `query_id` & `max_weight` and with a `response` of `Response::Version`. This should happen /// until/unless `stop` is called with the correct `query_id`. /// /// If the `location` has an ongoing notification and when this function is called, then an From 7bc5b206dacacbf8391d9dbdac2430db68824223 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 22 Oct 2021 19:49:10 +0200 Subject: [PATCH 037/231] Tests for Assets --- xcm/xcm-executor/src/assets.rs | 113 ++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 9 deletions(-) diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index c1d82ba36b3e..50b029d0d191 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -571,25 +571,36 @@ mod tests { #[test] fn min_counted_works() { - let mut assets = test_assets(); - assets.subsume(AF(1, 100)); - assets.subsume(ANF(2, 20)); - assets.subsume(CF(300)); - assets.subsume(CNF(40)); - // Push same group of tokens again + let mut assets = Assets::new(); assets.subsume(AF(1, 100)); assets.subsume(ANF(2, 20)); - assets.subsume(CF(300)); assets.subsume(CNF(40)); + assets.subsume(AF(10, 50)); + assets.subsume(ANF(2, 40)); + assets.subsume(ANF(2, 30)); + assets.subsume(CF(3000)); + assets.subsume(CNF(80)); + assets.subsume(ANF(3, 10)); let fungible = WildMultiAsset::from((vec![1], WildFungible)).counted(2).into(); - let non_fungible = WildMultiAsset::from((vec![1], WildFungible)).counted(2).into(); + let non_fungible = WildMultiAsset::from((vec![2], WildNonFungible)).counted(2).into(); + let all = WildMultiAsset::AllCounted(6).into(); let fungible = assets.min(&fungible); let fungible = fungible.assets_iter().collect::>(); assert_eq!(fungible, vec![AF(1, 100)]); let non_fungible = assets.min(&non_fungible); let non_fungible = non_fungible.assets_iter().collect::>(); - assert_eq!(non_fungible, vec![ANF(2, 20)]); + assert_eq!(non_fungible, vec![ANF(2, 20), ANF(2, 30)]); + let all = assets.min(&all); + let all = all.assets_iter().collect::>(); + assert_eq!(all, vec![ + CF(3000), + AF(1, 100), + AF(10, 50), + CNF(40), + CNF(80), + ANF(2, 20), + ]); } #[test] @@ -709,4 +720,88 @@ mod tests { let assets = assets1.into_assets_iter().collect::>(); assert_eq!(assets, vec![AF(1, 50), ANF(2, 20)]); } + + #[test] + fn try_take_all_counted_works() { + let mut assets = Assets::new(); + assets.subsume(AF(1, 100)); + assets.subsume(ANF(2, 20)); + assets.subsume(CNF(40)); + assets.subsume(AF(10, 50)); + assets.subsume(ANF(2, 40)); + assets.subsume(ANF(2, 30)); + assets.subsume(CF(3000)); + assets.subsume(CNF(80)); + assets.subsume(ANF(3, 10)); + let all = assets.try_take(WildMultiAsset::AllCounted(6).into()).unwrap(); + assert_eq!(MultiAssets::from(all).inner(), &vec![ + CF(3000), + AF(1, 100), + AF(10, 50), + CNF(40), + CNF(80), + ANF(2, 20), + ]); + assert_eq!(MultiAssets::from(assets).inner(), &vec![ + ANF(2, 30), + ANF(2, 40), + ANF(3, 10), + ]); + } + + #[test] + fn try_take_fungibles_counted_works() { + let mut assets = Assets::new(); + assets.subsume(AF(1, 100)); + assets.subsume(ANF(2, 20)); + assets.subsume(CNF(40)); + assets.subsume(AF(10, 50)); + assets.subsume(ANF(2, 40)); + assets.subsume(ANF(2, 30)); + assets.subsume(CF(3000)); + assets.subsume(CNF(80)); + assets.subsume(ANF(3, 10)); + let mask = WildMultiAsset::from((vec![1], WildFungible)).counted(2).into(); + let taken = assets.try_take(mask).unwrap(); + assert_eq!(MultiAssets::from(taken).inner(), &vec![ AF(1, 100) ]); + assert_eq!(MultiAssets::from(assets).inner(), &vec![ + CF(3000), + AF(10, 50), + CNF(40), + CNF(80), + ANF(2, 20), + ANF(2, 30), + ANF(2, 40), + ANF(3, 10), + ]); + } + + #[test] + fn try_take_non_fungibles_counted_works() { + let mut assets = Assets::new(); + assets.subsume(AF(1, 100)); + assets.subsume(ANF(2, 20)); + assets.subsume(CNF(40)); + assets.subsume(AF(10, 50)); + assets.subsume(ANF(2, 40)); + assets.subsume(ANF(2, 30)); + assets.subsume(CF(3000)); + assets.subsume(CNF(80)); + assets.subsume(ANF(3, 10)); + let mask = WildMultiAsset::from((vec![2], WildNonFungible)).counted(2).into(); + let taken = assets.try_take(mask).unwrap(); + assert_eq!(MultiAssets::from(taken).inner(), &vec![ + ANF(2, 20), + ANF(2, 30), + ]); + assert_eq!(MultiAssets::from(assets).inner(), &vec![ + CF(3000), + AF(1, 100), + AF(10, 50), + CNF(40), + CNF(80), + ANF(2, 40), + ANF(3, 10), + ]); + } } From 8358bb09532c4e07e5258003c2ae0abd415a5afb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 23 Oct 2021 00:10:02 +0200 Subject: [PATCH 038/231] Formatting --- xcm/xcm-builder/src/mock.rs | 24 +++++++++- xcm/xcm-builder/src/tests.rs | 8 ++++ xcm/xcm-builder/tests/scenarios.rs | 4 +- xcm/xcm-executor/src/assets.rs | 70 +++++++++++------------------- 4 files changed, 58 insertions(+), 48 deletions(-) diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index e4146980438e..6e21ca00a524 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -19,6 +19,7 @@ pub use crate::{ AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, LocationInverter, TakeWeightCredit, }; +use frame_support::traits::{CrateVersion, PalletInfoData, PalletsInfoAccess}; pub use frame_support::{ dispatch::{ DispatchError, DispatchInfo, DispatchResultWithPostInfo, Dispatchable, Parameter, Weight, @@ -325,6 +326,27 @@ impl VersionChangeNotifier for TestSubscriptionService { } } +pub struct TestPalletsInfo; +impl PalletsInfoAccess for TestPalletsInfo { + fn count() -> usize { + 2 + } + fn accumulate(acc: &mut Vec) { + acc.push(PalletInfoData { + index: 0, + name: "System", + module_name: "pallet_system", + crate_version: CrateVersion { major: 1, minor: 10, patch: 1 }, + }); + acc.push(PalletInfoData { + index: 1, + name: "Balances", + module_name: "pallet_balances", + crate_version: CrateVersion { major: 1, minor: 42, patch: 69 }, + }); + } +} + pub struct TestConfig; impl Config for TestConfig { type Call = TestCall; @@ -341,6 +363,6 @@ impl Config for TestConfig { type AssetTrap = TestAssetTrap; type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; - type PalletInstancesInfo = (); // TODO: TestAllPallets, for testing new instructions. + type PalletInstancesInfo = TestPalletsInfo; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index 5b866f0dd287..6fdbc3c954b3 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -707,3 +707,11 @@ fn weight_trader_tuple_should_work() { // and no refund assert_eq!(traders.refund_weight(2), None); } + +// TODO: Tests for: +// - `QueryPallet` +// - `ExpectPallet` +// - `ReportTransactStatus` +// - `ClearTransactStatus` +// - `BurnAsset` +// - `MaxAssetsIntoHolding` diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index 91be85517409..67d358f6fec3 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -35,7 +35,7 @@ fn buy_execution() -> Instruction { } /// Scenario: -/// A parachain transfers funds on the relaychain to another parachain's account. +/// A parachain transfers funds on the relay-chain to another parachain's account. /// /// Asserts that the parachain accounts are updated as expected. #[test] @@ -74,7 +74,7 @@ fn withdraw_and_deposit_works() { /// /// Asserts that the balances are updated correctly and the expected XCM is sent. #[test] -fn query_holding_works() { +fn report_holding_works() { use xcm::opaque::latest::prelude::*; let para_acc: AccountId = ParaId::from(PARA_ID).into_account(); let balances = vec![(ALICE, INITIAL_BALANCE), (para_acc.clone(), INITIAL_BALANCE)]; diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index 50b029d0d191..b73fd1bc5011 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -593,14 +593,7 @@ mod tests { assert_eq!(non_fungible, vec![ANF(2, 20), ANF(2, 30)]); let all = assets.min(&all); let all = all.assets_iter().collect::>(); - assert_eq!(all, vec![ - CF(3000), - AF(1, 100), - AF(10, 50), - CNF(40), - CNF(80), - ANF(2, 20), - ]); + assert_eq!(all, vec![CF(3000), AF(1, 100), AF(10, 50), CNF(40), CNF(80), ANF(2, 20),]); } #[test] @@ -734,19 +727,11 @@ mod tests { assets.subsume(CNF(80)); assets.subsume(ANF(3, 10)); let all = assets.try_take(WildMultiAsset::AllCounted(6).into()).unwrap(); - assert_eq!(MultiAssets::from(all).inner(), &vec![ - CF(3000), - AF(1, 100), - AF(10, 50), - CNF(40), - CNF(80), - ANF(2, 20), - ]); - assert_eq!(MultiAssets::from(assets).inner(), &vec![ - ANF(2, 30), - ANF(2, 40), - ANF(3, 10), - ]); + assert_eq!( + MultiAssets::from(all).inner(), + &vec![CF(3000), AF(1, 100), AF(10, 50), CNF(40), CNF(80), ANF(2, 20),] + ); + assert_eq!(MultiAssets::from(assets).inner(), &vec![ANF(2, 30), ANF(2, 40), ANF(3, 10),]); } #[test] @@ -763,17 +748,20 @@ mod tests { assets.subsume(ANF(3, 10)); let mask = WildMultiAsset::from((vec![1], WildFungible)).counted(2).into(); let taken = assets.try_take(mask).unwrap(); - assert_eq!(MultiAssets::from(taken).inner(), &vec![ AF(1, 100) ]); - assert_eq!(MultiAssets::from(assets).inner(), &vec![ - CF(3000), - AF(10, 50), - CNF(40), - CNF(80), - ANF(2, 20), - ANF(2, 30), - ANF(2, 40), - ANF(3, 10), - ]); + assert_eq!(MultiAssets::from(taken).inner(), &vec![AF(1, 100)]); + assert_eq!( + MultiAssets::from(assets).inner(), + &vec![ + CF(3000), + AF(10, 50), + CNF(40), + CNF(80), + ANF(2, 20), + ANF(2, 30), + ANF(2, 40), + ANF(3, 10), + ] + ); } #[test] @@ -790,18 +778,10 @@ mod tests { assets.subsume(ANF(3, 10)); let mask = WildMultiAsset::from((vec![2], WildNonFungible)).counted(2).into(); let taken = assets.try_take(mask).unwrap(); - assert_eq!(MultiAssets::from(taken).inner(), &vec![ - ANF(2, 20), - ANF(2, 30), - ]); - assert_eq!(MultiAssets::from(assets).inner(), &vec![ - CF(3000), - AF(1, 100), - AF(10, 50), - CNF(40), - CNF(80), - ANF(2, 40), - ANF(3, 10), - ]); + assert_eq!(MultiAssets::from(taken).inner(), &vec![ANF(2, 20), ANF(2, 30),]); + assert_eq!( + MultiAssets::from(assets).inner(), + &vec![CF(3000), AF(1, 100), AF(10, 50), CNF(40), CNF(80), ANF(2, 40), ANF(3, 10),] + ); } } From d866acf95084f622f49e6bfbd4bb0e76d35c27bf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 23 Oct 2021 00:13:17 +0200 Subject: [PATCH 039/231] Spellimg --- node/core/pvf/src/host.rs | 2 +- node/network/protocol/src/request_response/mod.rs | 2 +- runtime/parachains/src/disputes.rs | 4 ++-- runtime/parachains/src/hrmp.rs | 2 +- xcm/pallet-xcm/src/tests.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/node/core/pvf/src/host.rs b/node/core/pvf/src/host.rs index 40c30ca65c21..17ab31b7e769 100644 --- a/node/core/pvf/src/host.rs +++ b/node/core/pvf/src/host.rs @@ -319,7 +319,7 @@ async fn run( }, () = cleanup_pulse.select_next_some() => { // `select_next_some` because we don't expect this to fail, but if it does, we - // still don't fail. The tradeoff is that the compiled cache will start growing + // still don't fail. The trade-off is that the compiled cache will start growing // in size. That is, however, rather a slow process and hopefully the operator // will notice it. diff --git a/node/network/protocol/src/request_response/mod.rs b/node/network/protocol/src/request_response/mod.rs index 3d5e445e26ae..48932c406212 100644 --- a/node/network/protocol/src/request_response/mod.rs +++ b/node/network/protocol/src/request_response/mod.rs @@ -104,7 +104,7 @@ const STATEMENTS_TIMEOUT: Duration = Duration::from_secs(1); /// We don't want a slow peer to slow down all the others, at the same time we want to get out the /// data quickly in full to at least some peers (as this will reduce load on us as they then can -/// start serving the data). So this value is a tradeoff. 3 seems to be sensible. So we would need +/// start serving the data). So this value is a trade-off. 3 seems to be sensible. So we would need /// to have 3 slow nodes connected, to delay transfer for others by `STATEMENTS_TIMEOUT`. pub const MAX_PARALLEL_STATEMENT_REQUESTS: u32 = 3; diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 4059ed637868..e4037880140b 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -708,7 +708,7 @@ impl Pallet { /// /// This functions modifies the state when failing. It is expected to be called in inherent, /// and to fail the extrinsic on error. As invalid inherents are not allowed, the dirty state - /// is not commited. + /// is not committed. pub(crate) fn provide_multi_dispute_data( statement_sets: MultiDisputeStatementSet, ) -> Result, DispatchError> { @@ -925,7 +925,7 @@ impl Pallet { /// Handle a set of dispute statements corresponding to a single candidate. /// - /// Fails if the dispute data is invalid. Returns a boolean indicating whether the + /// Fails if the dispute data is invalid. Returns a Boolean indicating whether the /// dispute is fresh. fn provide_dispute_data( config: &HostConfiguration, diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index 7e489ba73cf0..ff71ea89f621 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -480,7 +480,7 @@ pub mod pallet { /// This cancels a pending open channel request. It can be canceled be either of the sender /// or the recipient for that request. The origin must be either of those. /// - /// The cancelling happens immediately. It is not possible to cancel the request if it is + /// The canceling happens immediately. It is not possible to cancel the request if it is /// already accepted. #[pallet::weight(0)] pub fn hrmp_cancel_open_request( diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index a12c396f245a..3972a90c99f4 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -687,7 +687,7 @@ fn subscriber_side_subscription_works() { }); } -/// We should autosubscribe when we don't know the remote's version. +/// We should auto-subscribe when we don't know the remote's version. #[test] fn auto_subscription_works() { new_test_ext_with_balances(vec![]).execute_with(|| { From 73c8fd9b98d7dcbdc62fc7527df1635c98457c3b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 24 Oct 2021 14:55:21 +0200 Subject: [PATCH 040/231] Tests for ExpectPallet and QueryPallet --- xcm/xcm-builder/src/tests.rs | 240 ++++++++++++++++++++++++++++++++++- 1 file changed, 239 insertions(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index 6fdbc3c954b3..89a3e85952ef 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -16,7 +16,7 @@ use super::{mock::*, *}; use frame_support::{assert_err, weights::constants::WEIGHT_PER_SECOND}; -use xcm::latest::prelude::*; +use xcm::latest::{PalletInfo, QueryResponseInfo, prelude::*}; use xcm_executor::{traits::*, Config, XcmExecutor}; #[test] @@ -708,6 +708,244 @@ fn weight_trader_tuple_should_work() { assert_eq!(traders.refund_weight(2), None); } +#[test] +fn pallet_query_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 + // and let them know to hand it to account #3. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + QueryPallet { + module_name: "Error".into(), + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: 1, + max_weight: 50, + }, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + + assert_eq!( + sent_xcm(), + vec![( + Parachain(1).into(), + Xcm::<()>(vec![ + QueryResponse { + query_id: 1, + max_weight: 50, + response: Response::PalletsInfo(vec![]), + } + ]), + )] + ); +} + +#[test] +fn pallet_query_with_results_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 + // and let them know to hand it to account #3. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + QueryPallet { + module_name: "pallet_balances".into(), + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: 1, + max_weight: 50, + }, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + + assert_eq!( + sent_xcm(), + vec![( + Parachain(1).into(), + Xcm::<()>(vec![ + QueryResponse { + query_id: 1, + max_weight: 50, + response: Response::PalletsInfo(vec![ + PalletInfo { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + major: 1, + minor: 42, + patch: 69, + }, + ]), + } + ]), + )] + ); +} + + +#[test] +fn expect_pallet_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 + // and let them know to hand it to account #3. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 41, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 60, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 1, + name: b"System".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_system".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 0, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 2, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::PalletNotFound)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 2, + min_crate_minor: 42, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 0, + min_crate_minor: 42, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 43, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); +} + // TODO: Tests for: // - `QueryPallet` // - `ExpectPallet` From 50ac5b20f08c36d1b28a5fc822a75176bf4f9f16 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 25 Oct 2021 15:55:39 +0200 Subject: [PATCH 041/231] Docs --- xcm/xcm-builder/src/tests.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index 89a3e85952ef..f3a19cf490f2 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -947,8 +947,6 @@ fn expect_pallet_should_work() { } // TODO: Tests for: -// - `QueryPallet` -// - `ExpectPallet` // - `ReportTransactStatus` // - `ClearTransactStatus` // - `BurnAsset` From f58f6038c318f179d7da912b7012e844ee4d9b6d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 25 Oct 2021 18:12:40 +0200 Subject: [PATCH 042/231] Tests --- xcm/xcm-builder/src/tests.rs | 244 ++++++++++++++++++++++++++++++++++- 1 file changed, 237 insertions(+), 7 deletions(-) diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index f3a19cf490f2..267eaa8a7900 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -16,7 +16,7 @@ use super::{mock::*, *}; use frame_support::{assert_err, weights::constants::WEIGHT_PER_SECOND}; -use xcm::latest::{PalletInfo, QueryResponseInfo, prelude::*}; +use xcm::latest::{MaybeErrorCode, PalletInfo, QueryResponseInfo, prelude::*}; use xcm_executor::{traits::*, Config, XcmExecutor}; #[test] @@ -789,6 +789,238 @@ fn pallet_query_with_results_should_work() { ); } +#[test] +fn report_successful_transact_status_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![ + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + call: TestCall::Any(50, None).encode().into(), + }, + ReportTransactStatus(QueryResponseInfo { + destination: Parent.into(), + query_id: 42, + max_weight: 5000, + }), + ]); + let weight_limit = 70; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(70)); + assert_eq!(sent_xcm(), vec![ + (Parent.into(), Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Success), + query_id: 42, + max_weight: 5000, + }])) + ]); +} + +#[test] +fn report_failed_transact_status_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![ + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + call: TestCall::OnlyRoot(50, None).encode().into(), + }, + ReportTransactStatus(QueryResponseInfo { + destination: Parent.into(), + query_id: 42, + max_weight: 5000, + }), + ]); + let weight_limit = 70; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(70)); + assert_eq!(sent_xcm(), vec![ + (Parent.into(), Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), + query_id: 42, + max_weight: 5000, + }])) + ]); +} + +#[test] +fn clear_transact_status_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![ + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + call: TestCall::OnlyRoot(50, None).encode().into(), + }, + ClearTransactStatus, + ReportTransactStatus(QueryResponseInfo { + destination: Parent.into(), + query_id: 42, + max_weight: 5000, + }), + ]); + let weight_limit = 80; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(80)); + assert_eq!(sent_xcm(), vec![ + (Parent.into(), Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Success), + query_id: 42, + max_weight: 5000, + }])) + ]); +} + +#[test] +fn max_assets_limit_should_work() { + // we'll let them have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Child parachain #1 owns 1000 tokens held by us in reserve. + add_asset(1001, (vec![1], 1000)); + add_asset(1001, (vec![2], 1000)); + add_asset(1001, (vec![3], 1000)); + add_asset(1001, (vec![4], 1000)); + add_asset(1001, (vec![5], 1000)); + add_asset(1001, (vec![6], 1000)); + add_asset(1001, (vec![7], 1000)); + add_asset(1001, (vec![8], 1000)); + add_asset(1001, (vec![9], 1000)); + + // Attempt to withdraw 8 (=2x4)different assets. This will succeed. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((vec![1], 100).into()), + WithdrawAsset((vec![2], 100).into()), + WithdrawAsset((vec![3], 100).into()), + WithdrawAsset((vec![4], 100).into()), + WithdrawAsset((vec![5], 100).into()), + WithdrawAsset((vec![6], 100).into()), + WithdrawAsset((vec![7], 100).into()), + WithdrawAsset((vec![8], 100).into()), + ]), + 100, + ); + assert_eq!(r, Outcome::Complete(85)); + + // Attempt to withdraw 9 different assets will fail. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((vec![1], 100).into()), + WithdrawAsset((vec![2], 100).into()), + WithdrawAsset((vec![3], 100).into()), + WithdrawAsset((vec![4], 100).into()), + WithdrawAsset((vec![5], 100).into()), + WithdrawAsset((vec![6], 100).into()), + WithdrawAsset((vec![7], 100).into()), + WithdrawAsset((vec![8], 100).into()), + WithdrawAsset((vec![9], 100).into()), + ]), + 100, + ); + assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); + + // Attempt to withdraw 4 different assets and then the same 4 and then a different 4 will succeed. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((vec![1], 100).into()), + WithdrawAsset((vec![2], 100).into()), + WithdrawAsset((vec![3], 100).into()), + WithdrawAsset((vec![4], 100).into()), + WithdrawAsset((vec![1], 100).into()), + WithdrawAsset((vec![2], 100).into()), + WithdrawAsset((vec![3], 100).into()), + WithdrawAsset((vec![4], 100).into()), + WithdrawAsset((vec![5], 100).into()), + WithdrawAsset((vec![6], 100).into()), + WithdrawAsset((vec![7], 100).into()), + WithdrawAsset((vec![8], 100).into()), + ]), + 200, + ); + assert_eq!(r, Outcome::Complete(125)); + + // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((vec![1], 100).into()), + WithdrawAsset((vec![2], 100).into()), + WithdrawAsset((vec![3], 100).into()), + WithdrawAsset((vec![4], 100).into()), + WithdrawAsset((vec![5], 100).into()), + WithdrawAsset((vec![6], 100).into()), + WithdrawAsset((vec![7], 100).into()), + WithdrawAsset((vec![8], 100).into()), + WithdrawAsset((vec![1], 100).into()), + WithdrawAsset((vec![2], 100).into()), + WithdrawAsset((vec![3], 100).into()), + WithdrawAsset((vec![4], 100).into()), + ]), + 200, + ); + assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); + + // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset(MultiAssets::from(vec![ + (vec![1], 100).into(), + (vec![2], 100).into(), + (vec![3], 100).into(), + (vec![4], 100).into(), + (vec![5], 100).into(), + (vec![6], 100).into(), + (vec![7], 100).into(), + (vec![8], 100).into(), + ])), + WithdrawAsset((vec![1], 100).into()), + ]), + 200, + ); + assert_eq!(r, Outcome::Incomplete(25, XcmError::HoldingWouldOverflow)); +} + +#[test] +fn burn_should_work() { + // we'll let them have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Child parachain #1 owns 1000 tokens held by us in reserve. + add_asset(1001, (Here, 1000)); + // They want to burn 100 of them + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((Here, 1000).into()), + BurnAsset((Here, 100).into()), + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(30)); + assert_eq!(assets(1001), vec![(Here, 900).into()]); + assert_eq!(sent_xcm(), vec![]); + + // Now they want to burn 1000 of them, which will actually only burn 900. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((Here, 900).into()), + BurnAsset((Here, 1000).into()), + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(30)); + assert_eq!(assets(1001), vec![]); + assert_eq!(sent_xcm(), vec![]); +} #[test] fn expect_pallet_should_work() { @@ -824,7 +1056,11 @@ fn expect_pallet_should_work() { 50, ); assert_eq!(r, Outcome::Complete(10)); +} +#[test] +fn expect_pallet_should_fail_correctly() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ @@ -945,9 +1181,3 @@ fn expect_pallet_should_work() { ); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); } - -// TODO: Tests for: -// - `ReportTransactStatus` -// - `ClearTransactStatus` -// - `BurnAsset` -// - `MaxAssetsIntoHolding` From 49220a92ea3d8649b0ac51a2e1cf6c7ec06a7986 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 25 Oct 2021 18:17:17 +0200 Subject: [PATCH 043/231] Formatting --- xcm/xcm-builder/src/tests.rs | 288 ++++++++++++++++------------------- 1 file changed, 135 insertions(+), 153 deletions(-) diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index 267eaa8a7900..4b3c52f8ac3a 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -16,7 +16,7 @@ use super::{mock::*, *}; use frame_support::{assert_err, weights::constants::WEIGHT_PER_SECOND}; -use xcm::latest::{MaybeErrorCode, PalletInfo, QueryResponseInfo, prelude::*}; +use xcm::latest::{prelude::*, MaybeErrorCode, PalletInfo, QueryResponseInfo}; use xcm_executor::{traits::*, Config, XcmExecutor}; #[test] @@ -715,16 +715,14 @@ fn pallet_query_should_work() { // and let them know to hand it to account #3. let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - QueryPallet { - module_name: "Error".into(), - response_info: QueryResponseInfo { - destination: Parachain(1).into(), - query_id: 1, - max_weight: 50, - }, + Xcm(vec![QueryPallet { + module_name: "Error".into(), + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: 1, + max_weight: 50, }, - ]), + }]), 50, ); assert_eq!(r, Outcome::Complete(10)); @@ -733,13 +731,11 @@ fn pallet_query_should_work() { sent_xcm(), vec![( Parachain(1).into(), - Xcm::<()>(vec![ - QueryResponse { - query_id: 1, - max_weight: 50, - response: Response::PalletsInfo(vec![]), - } - ]), + Xcm::<()>(vec![QueryResponse { + query_id: 1, + max_weight: 50, + response: Response::PalletsInfo(vec![]), + }]), )] ); } @@ -751,16 +747,14 @@ fn pallet_query_with_results_should_work() { // and let them know to hand it to account #3. let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - QueryPallet { - module_name: "pallet_balances".into(), - response_info: QueryResponseInfo { - destination: Parachain(1).into(), - query_id: 1, - max_weight: 50, - }, + Xcm(vec![QueryPallet { + module_name: "pallet_balances".into(), + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: 1, + max_weight: 50, }, - ]), + }]), 50, ); assert_eq!(r, Outcome::Complete(10)); @@ -769,22 +763,18 @@ fn pallet_query_with_results_should_work() { sent_xcm(), vec![( Parachain(1).into(), - Xcm::<()>(vec![ - QueryResponse { - query_id: 1, - max_weight: 50, - response: Response::PalletsInfo(vec![ - PalletInfo { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - major: 1, - minor: 42, - patch: 69, - }, - ]), - } - ]), + Xcm::<()>(vec![QueryResponse { + query_id: 1, + max_weight: 50, + response: Response::PalletsInfo(vec![PalletInfo { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + major: 1, + minor: 42, + patch: 69, + },]), + }]), )] ); } @@ -808,13 +798,17 @@ fn report_successful_transact_status_should_work() { let weight_limit = 70; let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); assert_eq!(r, Outcome::Complete(70)); - assert_eq!(sent_xcm(), vec![ - (Parent.into(), Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Success), - query_id: 42, - max_weight: 5000, - }])) - ]); + assert_eq!( + sent_xcm(), + vec![( + Parent.into(), + Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Success), + query_id: 42, + max_weight: 5000, + }]) + )] + ); } #[test] @@ -836,13 +830,17 @@ fn report_failed_transact_status_should_work() { let weight_limit = 70; let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); assert_eq!(r, Outcome::Complete(70)); - assert_eq!(sent_xcm(), vec![ - (Parent.into(), Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), - query_id: 42, - max_weight: 5000, - }])) - ]); + assert_eq!( + sent_xcm(), + vec![( + Parent.into(), + Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), + query_id: 42, + max_weight: 5000, + }]) + )] + ); } #[test] @@ -865,13 +863,17 @@ fn clear_transact_status_should_work() { let weight_limit = 80; let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); assert_eq!(r, Outcome::Complete(80)); - assert_eq!(sent_xcm(), vec![ - (Parent.into(), Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Success), - query_id: 42, - max_weight: 5000, - }])) - ]); + assert_eq!( + sent_xcm(), + vec![( + Parent.into(), + Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Success), + query_id: 42, + max_weight: 5000, + }]) + )] + ); } #[test] @@ -1029,30 +1031,26 @@ fn expect_pallet_should_work() { // and let them know to hand it to account #3. let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }, - ]), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), 50, ); assert_eq!(r, Outcome::Complete(10)); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 41, - }, - ]), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 41, + }]), 50, ); assert_eq!(r, Outcome::Complete(10)); @@ -1063,120 +1061,104 @@ fn expect_pallet_should_fail_correctly() { AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 60, - }, - ]), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 60, + }]), 50, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 1, - name: b"System".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }, - ]), + Xcm(vec![ExpectPallet { + index: 1, + name: b"System".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), 50, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_system".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }, - ]), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_system".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), 50, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 0, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }, - ]), + Xcm(vec![ExpectPallet { + index: 0, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), 50, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 2, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }, - ]), + Xcm(vec![ExpectPallet { + index: 2, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), 50, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::PalletNotFound)); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 2, - min_crate_minor: 42, - }, - ]), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 2, + min_crate_minor: 42, + }]), 50, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 0, - min_crate_minor: 42, - }, - ]), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 0, + min_crate_minor: 42, + }]), 50, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); let r = XcmExecutor::::execute_xcm( Parachain(1), - Xcm(vec![ - ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 43, - }, - ]), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 43, + }]), 50, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); From 3b6dcbb9502026954585ea02ef0e45b09acf41f9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Oct 2021 16:12:40 +0200 Subject: [PATCH 044/231] Fixes --- xcm/pallet-xcm/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index c953f56b97c5..b7cb9a40589d 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -811,7 +811,7 @@ pub mod pallet { }; let xcm = Xcm(vec![ BuyExecution { fees, weight_limit }, - DepositAsset { assets: Wild(All), max_assets, beneficiary }, + DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, ]); let mut message = Xcm(vec![TransferReserveAsset { assets, dest, xcm }]); let weight = @@ -869,7 +869,7 @@ pub mod pallet { }; let xcm = Xcm(vec![ BuyExecution { fees, weight_limit }, - DepositAsset { assets: Wild(All), max_assets, beneficiary }, + DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, ]); let mut message = Xcm(vec![WithdrawAsset(assets), InitiateTeleport { assets: Wild(All), dest, xcm }]); From 03a1678944334d8bad37e92260488cd9e0408acf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Oct 2021 16:26:11 +0200 Subject: [PATCH 045/231] Fixes --- xcm/pallet-xcm/src/tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index f22bf6002e7f..7b9b6ce864c6 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -277,7 +277,7 @@ fn limmited_teleport_assets_works() { ReceiveTeleportedAsset((Here, SEND_AMOUNT).into()), ClearOrigin, buy_limited_execution((Here, SEND_AMOUNT), 5000), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] ); @@ -319,7 +319,7 @@ fn unlimmited_teleport_assets_works() { ReceiveTeleportedAsset((Here, SEND_AMOUNT).into()), ClearOrigin, buy_execution((Here, SEND_AMOUNT)), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] ); @@ -457,7 +457,7 @@ fn unlimited_reserve_transfer_assets_works() { ReserveAssetDeposited((Parent, SEND_AMOUNT).into()), ClearOrigin, buy_execution((Parent, SEND_AMOUNT)), - DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] ); From 94c1b36db522491690df6426b0f98b8740b1f840 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 27 Oct 2021 17:32:18 +0200 Subject: [PATCH 046/231] Fixes --- node/overseer/overseer-gen/proc-macro/src/impl_builder.rs | 2 +- runtime/parachains/src/paras.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/overseer/overseer-gen/proc-macro/src/impl_builder.rs b/node/overseer/overseer-gen/proc-macro/src/impl_builder.rs index 94074ceb93f8..f5c6223d22cd 100644 --- a/node/overseer/overseer-gen/proc-macro/src/impl_builder.rs +++ b/node/overseer/overseer-gen/proc-macro/src/impl_builder.rs @@ -262,7 +262,7 @@ pub(crate) fn impl_builder(info: &OverseerInfo) -> proc_macro2::TokenStream { self } - /// Specify the particular subsystem by giving a init function. + /// Specify the particular subsystem by giving a initialization function. pub fn #subsystem_name_init_with <'a, F> (mut self, subsystem_init_fn: F ) -> Self where F: 'static + FnOnce(#handle) -> ::std::result::Result<#builder_generic_ty, #error_ty>, diff --git a/runtime/parachains/src/paras.rs b/runtime/parachains/src/paras.rs index d7bc9e7a7619..7f3673d51e0c 100644 --- a/runtime/parachains/src/paras.rs +++ b/runtime/parachains/src/paras.rs @@ -66,7 +66,7 @@ pub struct ReplacementTimes { #[cfg_attr(test, derive(Debug, Clone, PartialEq))] pub struct ParaPastCodeMeta { /// Block numbers where the code was expected to be replaced and where the code - /// was actually replaced, respectively. The first is used to do accurate lookups + /// was actually replaced, respectively. The first is used to do accurate look-ups /// of historic code in historic contexts, whereas the second is used to do /// pruning on an accurate timeframe. These can be used as indices /// into the `PastCodeHash` map along with the `ParaId` to fetch the code itself. From a213a64a41be05da85b0a4a4d6ff53184b42047e Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 24 Nov 2021 20:07:51 -0800 Subject: [PATCH 047/231] Add missing associated types for XCM executor config in polkadot runtime --- runtime/polkadot/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index f0fc60c2dac9..654495461c3e 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1360,6 +1360,7 @@ pub type XcmRouter = ( parameter_types! { pub const Polkadot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(DotLocation::get()) }); pub const PolkadotForStatemint: (MultiAssetFilter, MultiLocation) = (Polkadot::get(), Parachain(1000).into()); + pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = (xcm_builder::Case,); @@ -1399,6 +1400,8 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; + type PalletInstancesInfo = AllPallets; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } parameter_types! { From 2e49223d8a3ab0e4363ba3d9cfeb51b97393ea4e Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 14 Dec 2021 22:10:19 -0800 Subject: [PATCH 048/231] cargo fmt --- xcm/src/v3/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 8187e0133048..29429a6ceb03 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -130,8 +130,8 @@ pub mod prelude { MultiAssetFilter::{self, *}, MultiAssets, MultiLocation, NetworkId::{self, *}, - OriginKind, Outcome, Parent, ParentThen, QueryId, QueryResponseInfo, - Response, Result as XcmResult, SendError, SendResult, SendXcm, + OriginKind, Outcome, Parent, ParentThen, QueryId, QueryResponseInfo, Response, + Result as XcmResult, SendError, SendResult, SendXcm, WeightLimit::{self, *}, WildFungibility::{self, Fungible as WildFungible, NonFungible as WildNonFungible}, WildMultiAsset::{self, *}, From b5b89e13b92ce3eb2a092646aed49f4c326d1aba Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 14 Dec 2021 23:00:27 -0800 Subject: [PATCH 049/231] Fix compilation errors --- runtime/westend/src/lib.rs | 2 +- xcm/src/v3/traits.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 068a90c5b48a..295af0fd457e 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1633,7 +1633,7 @@ sp_api::impl_runtime_apis! { fn valid_destination() -> Result { Ok(Westmint::get()) } - fn worst_case_holding() -> MultiAssets { + fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Westend only knows about WND. vec![MultiAsset{ id: Concrete(WndLocation::get()), diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 81c943d9529d..cd9bed5fa489 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -392,7 +392,6 @@ pub trait XcmWeightInfo { fn clear_origin() -> Weight; fn descend_origin(who: &InteriorMultiLocation) -> Weight; fn report_error(response_info: &QueryResponseInfo) -> Weight; - fn relayed_from(who: &Junctions, message: &alloc::boxed::Box>) -> Weight; fn deposit_asset(assets: &MultiAssetFilter, beneficiary: &MultiLocation) -> Weight; fn deposit_reserve_asset( assets: &MultiAssetFilter, From eed4d6e3910b434a3cf1438ac0e6b7e5f75966a6 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 14 Dec 2021 23:36:12 -0800 Subject: [PATCH 050/231] Resolve warnings --- xcm/pallet-xcm/src/mock.rs | 2 +- xcm/xcm-builder/tests/mock/mod.rs | 2 +- xcm/xcm-builder/tests/scenarios.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 3b5fef6d4187..af9ef8f98548 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -266,7 +266,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = AllPallets; + type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 94a3df1a457a..d2b2152aedb7 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -174,7 +174,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = AllPallets; + type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index 67d358f6fec3..b45b9b96c6cf 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -21,7 +21,7 @@ use mock::{ }; use polkadot_parachain::primitives::Id as ParaId; use sp_runtime::traits::AccountIdConversion; -use xcm::latest::{prelude::*, QueryResponseInfo}; +use xcm::latest::prelude::*; use xcm_executor::XcmExecutor; pub const ALICE: AccountId = AccountId::new([0u8; 32]); From 258f47320e5a125c757d0ac6a72f43fa6b846bbe Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 15 Dec 2021 18:17:51 -0800 Subject: [PATCH 051/231] Use AllPalletsWithSystem --- runtime/rococo/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 5495ab172fe5..4cdd53ed7b6c 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -725,7 +725,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = AllPallets; + type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } From d9030ea16bf67ee91d200ee54a73d9c7b55ae757 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 15 Dec 2021 18:56:58 -0800 Subject: [PATCH 052/231] Use AllPalletsWithSystem --- runtime/westend/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index debe5a27e701..c1fc6ad993f3 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1049,7 +1049,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = AllPallets; + type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } From d0037cda27ac7e6ebd7dfd3d46bfe319b1749473 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 15 Dec 2021 19:11:06 -0800 Subject: [PATCH 053/231] Use AllPalletsWithSystem --- runtime/kusama/src/lib.rs | 2 +- runtime/polkadot/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 8ac2e0066d99..2f849f9d7dbe 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1419,7 +1419,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = AllPallets; + type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 28c2d8b4077e..44f4e961ee11 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1408,7 +1408,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; - type PalletInstancesInfo = AllPallets; + type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } From cd5df6d6a4672eaeeb012c2926d87009d1f30d94 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 12 Jan 2022 20:49:23 -0800 Subject: [PATCH 054/231] cargo fmt --- runtime/kusama/src/xcm_config.rs | 2 +- runtime/polkadot/src/xcm_config.rs | 2 +- runtime/rococo/src/xcm_config.rs | 2 +- runtime/westend/src/xcm_config.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 01b19767bc74..1c16693ce18d 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -17,7 +17,7 @@ //! XCM configurations for the Kusama runtime. use super::{ - parachains_origin, AllPalletsWithSystem, AccountId, Balances, Call, CouncilCollective, Event, + parachains_origin, AccountId, AllPalletsWithSystem, Balances, Call, CouncilCollective, Event, Origin, ParaId, Runtime, WeightToFee, XcmPallet, }; use frame_support::{ diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 11b48d645ee7..9afd41c52ead 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -17,7 +17,7 @@ //! XCM configuration for Polkadot. use super::{ - parachains_origin, AllPalletsWithSystem, AccountId, Balances, Call, CouncilCollective, Event, + parachains_origin, AccountId, AllPalletsWithSystem, Balances, Call, CouncilCollective, Event, Origin, ParaId, Runtime, WeightToFee, XcmPallet, }; use frame_support::{ diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index d49f4c16c090..bb0489f6656f 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -17,7 +17,7 @@ //! XCM configuration for Rococo. use super::{ - parachains_origin, AllPalletsWithSystem, AccountId, Balances, Call, Event, Origin, ParaId, + parachains_origin, AccountId, AllPalletsWithSystem, Balances, Call, Event, Origin, ParaId, Runtime, WeightToFee, XcmPallet, }; use frame_support::{ diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 9b8047503a3a..b57e54593e86 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -17,7 +17,7 @@ //! XCM configurations for Westend. use super::{ - parachains_origin, weights, AllPalletsWithSystem, AccountId, Balances, Call, Event, Origin, + parachains_origin, weights, AccountId, AllPalletsWithSystem, Balances, Call, Event, Origin, ParaId, Runtime, WeightToFee, XcmPallet, }; use frame_support::{ From 22b4332fcb92584b222336f15fbc1a34eab61507 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 19 Jan 2022 19:40:25 -0800 Subject: [PATCH 055/231] Create benchmarks for XCM instructions introduced in v3 (#4564) * Create benchmarks for BurnAsset and ExpectAsset * Add benchmarks for ExpectOrigin and ExpectError * Add benchmarks for QueryPallet and ExpectPallet * Add benchmarks for ReportTransactStatus and ClearTransactStatus * cargo fmt * Use AllPalletsWithSystem in mocks * Update XCM generic benchmarks for westend * Remove default impls for some XCM weight functions * Fix compilation error * Add weight_args helper attribute * Remove manually written XcmWeightInfo * Parse trailing comma * Revert "Add weight_args helper attribute" This reverts commit 3b7c47a6182e1b9227036c38b406d494c3fcf6fd. * Fixes * Fixes --- runtime/westend/src/weights/xcm/mod.rs | 30 ++++ .../xcm/pallet_xcm_benchmarks_generic.rs | 83 +++++++--- .../src/fungible/mock.rs | 2 +- .../src/generic/benchmarking.rs | 143 +++++++++++++++++- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 2 +- xcm/src/v3/mod.rs | 16 +- xcm/src/v3/traits.rs | 73 --------- 7 files changed, 239 insertions(+), 110 deletions(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index b8cafea6a598..0116b0a04d54 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -182,4 +182,34 @@ impl XcmWeightInfo for WestendXcmWeight { fn unsubscribe_version() -> Weight { XcmGeneric::::unsubscribe_version() } + fn burn_asset(assets: &MultiAssets) -> Weight { + assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + } + fn expect_asset(assets: &MultiAssets) -> Weight { + assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + } + fn expect_origin(_origin: &Option) -> Weight { + XcmGeneric::::expect_origin() + } + fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight { + XcmGeneric::::expect_error() + } + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::query_pallet() + } + fn expect_pallet( + _index: &u32, + _name: &Vec, + _module_name: &Vec, + _crate_major: &u32, + _min_crate_minor: &u32, + ) -> Weight { + XcmGeneric::::expect_pallet() + } + fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_transact_status() + } + fn clear_transact_status() -> Weight { + XcmGeneric::::clear_transact_status() + } } diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index e801911063c5..bd881fd41a81 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// Copyright 2021 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-12-01, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-12-20, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 // Executed Command: @@ -45,37 +45,44 @@ use sp_std::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); impl WeightInfo { - pub fn report_holding() -> Weight { - 1_000_000_000 + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn report_holding() -> Weight { + (35_446_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn buy_execution() -> Weight { - (5_922_000 as Weight) + (5_228_000 as Weight) } // Storage: XcmPallet Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (20_625_000 as Weight) + (18_708_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } pub(crate) fn transact() -> Weight { - (22_198_000 as Weight) + (20_401_000 as Weight) } pub(crate) fn refund_surplus() -> Weight { - (6_122_000 as Weight) + (5_238_000 as Weight) } pub(crate) fn set_error_handler() -> Weight { - (5_758_000 as Weight) + (5_104_000 as Weight) } pub(crate) fn set_appendix() -> Weight { - (5_764_000 as Weight) + (5_095_000 as Weight) } pub(crate) fn clear_error() -> Weight { - (5_679_000 as Weight) + (5_010_000 as Weight) } pub(crate) fn descend_origin() -> Weight { - (7_206_000 as Weight) + (6_368_000 as Weight) } pub(crate) fn clear_origin() -> Weight { - (5_738_000 as Weight) + (5_011_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -83,18 +90,18 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_error() -> Weight { - (31_512_000 as Weight) + (27_823_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: XcmPallet AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (13_594_000 as Weight) + (12_402_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } pub(crate) fn trap() -> Weight { - (5_745_000 as Weight) + (5_022_000 as Weight) } // Storage: XcmPallet VersionNotifyTargets (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -103,13 +110,13 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (38_138_000 as Weight) + (32_492_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: XcmPallet VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (9_127_000 as Weight) + (7_777_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -118,8 +125,46 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (41_443_000 as Weight) + (37_066_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + pub(crate) fn burn_asset() -> Weight { + (7_935_000 as Weight) + } + pub(crate) fn expect_asset() -> Weight { + (5_237_000 as Weight) + } + pub(crate) fn expect_origin() -> Weight { + (5_245_000 as Weight) + } + pub(crate) fn expect_error() -> Weight { + (5_062_000 as Weight) + } + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn query_pallet() -> Weight { + (28_876_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + pub(crate) fn expect_pallet() -> Weight { + (5_526_000 as Weight) + } + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn report_transact_status() -> Weight { + (27_889_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + pub(crate) fn clear_transact_status() -> Weight { + (5_100_000 as Weight) + } } diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 6647ff967999..6418e82f148c 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -143,7 +143,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = (); type AssetClaims = (); type SubscriptionService = (); - type PalletInstancesInfo = (); + type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index aee21000afde..eb568e18a12e 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -21,9 +21,10 @@ use frame_benchmarking::{benchmarks, BenchmarkError}; use frame_support::dispatch::GetDispatchInfo; use sp_std::vec; use xcm::{ - latest::{prelude::*, MultiAssets}, + latest::{prelude::*, MaybeErrorCode, MultiAssets}, DoubleEncoded, }; +use xcm_executor::ExecutorError; benchmarks! { report_holding { @@ -254,12 +255,10 @@ benchmarks! { } : { _result = executor.execute(xcm); } verify { - match _result { - Err(error) if error.xcm_error == XcmError::Trap(10) => { - // This is the success condition - }, - _ => Err("xcm trap did not return the expected error")? - }; + assert!(matches!(_result, Err(ExecutorError { + xcm_error: XcmError::Trap(10), + .. + }))); } subscribe_version { @@ -306,13 +305,141 @@ benchmarks! { executor.holding = holding.into(); let instruction = Instruction::InitiateReserveWithdraw { assets: assets_filter, reserve, xcm: Xcm(vec![]) }; let xcm = Xcm(vec![instruction]); - }:{ + }: { executor.execute(xcm)?; } verify { // The execute completing successfully is as good as we can check. // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 } + burn_asset { + let holding = T::worst_case_holding(0); + let assets = holding.clone(); + + let mut executor = new_executor::(Default::default()); + executor.holding = holding.into(); + + let instruction = Instruction::BurnAsset(assets.into()); + let xcm = Xcm(vec![instruction]); + }: { + executor.execute(xcm)?; + } verify { + assert!(executor.holding.is_empty()); + } + + expect_asset { + let holding = T::worst_case_holding(0); + let assets = holding.clone(); + + let mut executor = new_executor::(Default::default()); + executor.holding = holding.into(); + + let instruction = Instruction::ExpectAsset(assets.into()); + let xcm = Xcm(vec![instruction]); + }: { + executor.execute(xcm)?; + } verify { + // `execute` completing successfully is as good as we can check. + } + + expect_origin { + let expected_origin = Parent.into(); + let mut executor = new_executor::(Default::default()); + + let instruction = Instruction::ExpectOrigin(Some(expected_origin)); + let xcm = Xcm(vec![instruction]); + let mut _result = Ok(()); + }: { + _result = executor.execute(xcm); + } verify { + assert!(matches!(_result, Err(ExecutorError { + xcm_error: XcmError::ExpectationFalse, + .. + }))); + } + + expect_error { + let mut executor = new_executor::(Default::default()); + executor.error = Some((3u32, XcmError::Overflow)); + + let instruction = Instruction::ExpectError(None); + let xcm = Xcm(vec![instruction]); + let mut _result = Ok(()); + }: { + _result = executor.execute(xcm); + } verify { + assert!(matches!(_result, Err(ExecutorError { + xcm_error: XcmError::ExpectationFalse, + .. + }))); + } + + query_pallet { + let query_id = Default::default(); + let destination = T::valid_destination().map_err(|_| BenchmarkError::Skip)?; + let max_weight = Default::default(); + let mut executor = new_executor::(Default::default()); + + let instruction = Instruction::QueryPallet { + module_name: b"frame_system".to_vec(), + response_info: QueryResponseInfo { destination, query_id, max_weight }, + }; + let xcm = Xcm(vec![instruction]); + }: { + executor.execute(xcm)?; + } verify { + // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 + } + + expect_pallet { + let mut executor = new_executor::(Default::default()); + + let instruction = Instruction::ExpectPallet { + index: 0, + name: b"System".to_vec(), + module_name: b"frame_system".to_vec(), + crate_major: 4, + min_crate_minor: 0, + }; + let xcm = Xcm(vec![instruction]); + }: { + executor.execute(xcm)?; + } verify { + // the execution succeeding is all we need to verify this xcm was successful + } + + report_transact_status { + let query_id = Default::default(); + let destination = T::valid_destination().map_err(|_| BenchmarkError::Skip)?; + let max_weight = Default::default(); + + let mut executor = new_executor::(Default::default()); + executor.transact_status = MaybeErrorCode::Error(b"MyError".to_vec()); + + let instruction = Instruction::ReportTransactStatus(QueryResponseInfo { + query_id, + destination, + max_weight, + }); + let xcm = Xcm(vec![instruction]); + }: { + executor.execute(xcm)?; + } verify { + // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 + } + + clear_transact_status { + let mut executor = new_executor::(Default::default()); + executor.transact_status = MaybeErrorCode::Error(b"MyError".to_vec()); + + let instruction = Instruction::ClearTransactStatus; + let xcm = Xcm(vec![instruction]); + }: { + executor.execute(xcm)?; + } verify { + assert_eq!(executor.transact_status, MaybeErrorCode::Success); + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 7f93c4c93a20..c78a69956a7f 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -113,7 +113,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = TestAssetTrap; type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; - type PalletInstancesInfo = (); + type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; } diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 29429a6ceb03..959847aebee5 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -35,13 +35,11 @@ pub use multiasset::{ AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssetFilter, MultiAssets, WildFungibility, WildMultiAsset, }; -pub use traits::{ - Error, ExecuteXcm, Outcome, Result, SendError, SendResult, SendXcm, Weight, XcmWeightInfo, -}; +pub use traits::{Error, ExecuteXcm, Outcome, Result, SendError, SendResult, SendXcm}; // These parts of XCM v2 are unchanged in XCM v3, and are re-imported here. pub use super::v2::{ Ancestor, AncestorThen, BodyId, BodyPart, InteriorMultiLocation, Junction, Junctions, - MultiLocation, NetworkId, OriginKind, Parent, ParentThen, WeightLimit, + MultiLocation, NetworkId, OriginKind, Parent, ParentThen, Weight, WeightLimit, }; /// This module's XCM version. @@ -218,7 +216,7 @@ pub struct QueryResponseInfo { /// /// This is the inner XCM format and is version-sensitive. Messages are typically passed using the outer /// XCM format, known as `VersionedXcm`. -#[derive(Derivative, Encode, Decode, TypeInfo)] +#[derive(Derivative, Encode, Decode, TypeInfo, xcm_procedural::XcmWeightInfoTrait)] #[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] #[codec(encode_bound())] #[codec(decode_bound())] @@ -771,7 +769,7 @@ impl Instruction { QueryPallet { module_name, response_info }, ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => ExpectPallet { index, name, module_name, crate_major, min_crate_minor }, - ReportTransactStatus(repsonse_info) => ReportTransactStatus(repsonse_info), + ReportTransactStatus(response_info) => ReportTransactStatus(response_info), ClearTransactStatus => ClearTransactStatus, } } @@ -822,8 +820,10 @@ impl> GetWeight for Instruction { ExpectAsset(assets) => W::expect_asset(assets), ExpectOrigin(origin) => W::expect_origin(origin), ExpectError(error) => W::expect_error(error), - QueryPallet { .. } => W::query_pallet(), - ExpectPallet { index, .. } => W::expect_pallet(index), + QueryPallet { module_name, response_info } => + W::query_pallet(module_name, response_info), + ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => + W::expect_pallet(index, name, module_name, crate_major, min_crate_minor), ReportTransactStatus(response_info) => W::report_transact_status(response_info), ClearTransactStatus => W::clear_transact_status(), } diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index cd9bed5fa489..2d4e8ff2325f 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -367,76 +367,3 @@ impl SendXcm for Tuple { Err(SendError::CannotReachDestination(destination.into(), message)) } } - -/// The info needed to weigh an XCM. -// TODO: Automate Generation -pub trait XcmWeightInfo { - fn withdraw_asset(assets: &MultiAssets) -> Weight; - fn reserve_asset_deposited(assets: &MultiAssets) -> Weight; - fn receive_teleported_asset(assets: &MultiAssets) -> Weight; - fn query_response(query_id: &u64, response: &Response, max_weight: &u64) -> Weight; - fn transfer_asset(assets: &MultiAssets, beneficiary: &MultiLocation) -> Weight; - fn transfer_reserve_asset(assets: &MultiAssets, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight; - fn transact( - origin_kind: &OriginKind, - require_weight_at_most: &u64, - call: &DoubleEncoded, - ) -> Weight; - fn hrmp_new_channel_open_request( - sender: &u32, - max_message_size: &u32, - max_capacity: &u32, - ) -> Weight; - fn hrmp_channel_accepted(recipient: &u32) -> Weight; - fn hrmp_channel_closing(initiator: &u32, sender: &u32, recipient: &u32) -> Weight; - fn clear_origin() -> Weight; - fn descend_origin(who: &InteriorMultiLocation) -> Weight; - fn report_error(response_info: &QueryResponseInfo) -> Weight; - fn deposit_asset(assets: &MultiAssetFilter, beneficiary: &MultiLocation) -> Weight; - fn deposit_reserve_asset( - assets: &MultiAssetFilter, - dest: &MultiLocation, - xcm: &Xcm<()>, - ) -> Weight; - fn exchange_asset(give: &MultiAssetFilter, receive: &MultiAssets) -> Weight; - fn initiate_reserve_withdraw( - assets: &MultiAssetFilter, - reserve: &MultiLocation, - xcm: &Xcm<()>, - ) -> Weight; - fn initiate_teleport(assets: &MultiAssetFilter, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight; - fn report_holding(response_info: &QueryResponseInfo, assets: &MultiAssetFilter) -> Weight; - fn buy_execution(fees: &MultiAsset, weight_limit: &WeightLimit) -> Weight; - fn refund_surplus() -> Weight; - fn set_error_handler(xcm: &Xcm) -> Weight; - fn set_appendix(xcm: &Xcm) -> Weight; - fn clear_error() -> Weight; - fn claim_asset(assets: &MultiAssets, ticket: &MultiLocation) -> Weight; - fn trap(code: &u64) -> Weight; - fn subscribe_version(query_id: &QueryId, max_response_weight: &u64) -> Weight; - fn unsubscribe_version() -> Weight; - fn burn_asset(_assets: &MultiAssets) -> Weight { - 0 - } - fn expect_asset(_assets: &MultiAssets) -> Weight { - 0 - } - fn expect_origin(_origin: &Option) -> Weight { - 0 - } - fn expect_error(_error: &Option<(u32, Error)>) -> Weight { - 0 - } - fn query_pallet() -> Weight { - 0 - } - fn expect_pallet(_pallet_index: &u32) -> Weight { - 0 - } - fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { - 0 - } - fn clear_transact_status() -> Weight { - 0 - } -} From c0d4800ab5ceff89fe490a6daf6c8f4bb0f41ce5 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Fri, 21 Jan 2022 14:19:53 +0100 Subject: [PATCH 056/231] XCM v3: Introduce querier field into `QueryReponse` (#4732) * Introduce querier field into QueryReponse * Convert &Option to Option<&MultiLocation> &Option is almost always never quite useful, most of the time it still gets converted to an Option<&T> via `as_ref`, so we should simply make functions that accept Option<&T> instead. * Fix tests * cargo fmt * Fix benchmarks * Appease spellchecker * Fix test * Fix tests * Fix test * Fix mock * Fixes * Fix tests * Add test for response queriers * Update xcm/pallet-xcm/src/lib.rs * Test for non-existence of querier Co-authored-by: Keith Yeung --- runtime/test-runtime/src/lib.rs | 2 + scripts/gitlab/lingua.dic | 1 + .../src/generic/benchmarking.rs | 3 +- xcm/pallet-xcm-benchmarks/src/mock.rs | 10 +- xcm/pallet-xcm/src/lib.rs | 171 ++++++++++++++-- xcm/pallet-xcm/src/mock.rs | 9 +- xcm/pallet-xcm/src/tests.rs | 187 ++++++++++++++++-- xcm/src/v1/multilocation.rs | 15 ++ xcm/src/v2/mod.rs | 2 +- xcm/src/v3/mod.rs | 24 ++- xcm/src/v3/traits.rs | 3 + xcm/xcm-builder/src/barriers.rs | 4 +- xcm/xcm-builder/src/mock.rs | 7 +- xcm/xcm-builder/src/tests.rs | 6 + xcm/xcm-builder/tests/scenarios.rs | 1 + xcm/xcm-executor/integration-tests/src/lib.rs | 6 +- xcm/xcm-executor/src/lib.rs | 53 ++++- xcm/xcm-executor/src/traits/on_response.rs | 20 +- xcm/xcm-simulator/example/src/lib.rs | 1 + 19 files changed, 469 insertions(+), 56 deletions(-) diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 2980e45e529e..ad1315716715 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -608,6 +608,7 @@ pub mod pallet_test_notifier { let qid = pallet_xcm::Pallet::::new_query( Junction::AccountId32 { network: Any, id }.into(), 100u32.into(), + Here, ); Self::deposit_event(Event::::QueryPrepared(qid)); Ok(()) @@ -625,6 +626,7 @@ pub mod pallet_test_notifier { Junction::AccountId32 { network: Any, id }.into(), ::Call::from(call), 100u32.into(), + Here, ); Self::deposit_event(Event::::NotifyQueryPrepared(qid)); Ok(()) diff --git a/scripts/gitlab/lingua.dic b/scripts/gitlab/lingua.dic index bf70b0512e40..b4621cec88a3 100644 --- a/scripts/gitlab/lingua.dic +++ b/scripts/gitlab/lingua.dic @@ -215,6 +215,7 @@ proxy/G proxying PRs PVF/S +querier README/MS redhat/M register/CD diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index eb568e18a12e..a55cd27b9113 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -97,7 +97,8 @@ benchmarks! { let mut executor = new_executor::(Default::default()); let (query_id, response) = T::worst_case_response(); let max_weight = u64::MAX; - let instruction = Instruction::QueryResponse { query_id, response, max_weight }; + let querier: Option = Some(Here.into()); + let instruction = Instruction::QueryResponse { query_id, response, max_weight, querier }; let xcm = Xcm(vec![instruction]); }: { executor.execute(xcm)?; diff --git a/xcm/pallet-xcm-benchmarks/src/mock.rs b/xcm/pallet-xcm-benchmarks/src/mock.rs index d59cf3387268..6390d251010e 100644 --- a/xcm/pallet-xcm-benchmarks/src/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/mock.rs @@ -27,10 +27,16 @@ impl xcm::opaque::latest::SendXcm for DevNull { } impl xcm_executor::traits::OnResponse for DevNull { - fn expecting_response(_: &MultiLocation, _: u64) -> bool { + fn expecting_response(_: &MultiLocation, _: u64, _: Option<&MultiLocation>) -> bool { false } - fn on_response(_: &MultiLocation, _: u64, _: Response, _: Weight) -> Weight { + fn on_response( + _: &MultiLocation, + _: u64, + _: Option<&MultiLocation>, + _: Response, + _: Weight, + ) -> Weight { 0 } } diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 5df4aade835a..9275e4ea9999 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -215,6 +215,22 @@ pub mod pallet { /// /// \[ location, query ID \] NotifyTargetMigrationFail(VersionedMultiLocation, QueryId), + /// Expected query response has been received but the expected querier location placed in + /// storage by this runtime previously cannot be decoded. The query remains registered. + /// + /// This is unexpected (since a location placed in storage in a previously executing + /// runtime should be readable prior to query timeout) and dangerous since the possibly + /// valid response will be dropped. Manual governance intervention is probably going to be + /// needed. + /// + /// \[ origin location, id \] + InvalidQuerierVersion(MultiLocation, QueryId), + /// Expected query response has been received but the querier location of the response does + /// not match the expected. The query remains registered for a later, valid, response to + /// be received and acted upon. + /// + /// \[ origin location, id, expected querier, maybe actual querier \] + InvalidQuerier(MultiLocation, QueryId, MultiLocation, Option), } #[pallet::origin] @@ -269,7 +285,12 @@ pub mod pallet { pub enum QueryStatus { /// The query was sent but no response has yet been received. Pending { + /// The `QueryResponse` XCM must have this origin to be considered a reply for this + /// query. responder: VersionedMultiLocation, + /// The `QueryResponse` XCM must have this value as the `querier` field to be + /// considered a reply for this query. If `None` then the querier is ignored. + maybe_match_querier: Option, maybe_notify: Option<(u8, u8)>, timeout: BlockNumber, }, @@ -449,6 +470,77 @@ pub mod pallet { } } + pub mod migrations { + use super::*; + use frame_support::traits::{PalletInfoAccess, StorageVersion}; + + #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + enum QueryStatusV0 { + Pending { + responder: VersionedMultiLocation, + maybe_notify: Option<(u8, u8)>, + timeout: BlockNumber, + }, + VersionNotifier { + origin: VersionedMultiLocation, + is_active: bool, + }, + Ready { + response: VersionedResponse, + at: BlockNumber, + }, + } + impl From> for QueryStatus { + fn from(old: QueryStatusV0) -> Self { + use QueryStatusV0::*; + match old { + Pending { responder, maybe_notify, timeout } => QueryStatus::Pending { + responder, + maybe_notify, + timeout, + maybe_match_querier: Some(MultiLocation::here().into()), + }, + VersionNotifier { origin, is_active } => + QueryStatus::VersionNotifier { origin, is_active }, + Ready { response, at } => QueryStatus::Ready { response, at }, + } + } + } + + pub fn migrate_to_v1( + ) -> frame_support::weights::Weight { + let on_chain_storage_version =

::on_chain_storage_version(); + log::info!( + target: "runtime::xcm", + "Running migration storage v1 for xcm with storage version {:?}", + on_chain_storage_version, + ); + + if on_chain_storage_version < 1 { + let mut count = 0; + Queries::::translate::, _>(|_key, value| { + count += 1; + Some(value.into()) + }); + StorageVersion::new(1).put::

(); + log::info!( + target: "runtime::xcm", + "Running migration storage v1 for xcm with storage version {:?} was complete", + on_chain_storage_version, + ); + // calculate and return migration weights + T::DbWeight::get().reads_writes(count as Weight + 1, count as Weight + 1) + } else { + log::warn!( + target: "runtime::xcm", + "Attempted to apply migration to v1 but failed because storage version is {:?}", + on_chain_storage_version, + ); + T::DbWeight::get().reads(1) + } + } + } + #[pallet::call] impl Pallet { #[pallet::weight(100_000_000)] @@ -952,7 +1044,8 @@ pub mod pallet { }, }; let response = Response::Version(xcm_version); - let message = Xcm(vec![QueryResponse { query_id, response, max_weight }]); + let message = + Xcm(vec![QueryResponse { query_id, response, max_weight, querier: None }]); let event = match T::XcmRouter::send_xcm(new_key.clone(), message) { Ok(()) => { let value = (query_id, max_weight, xcm_version); @@ -998,8 +1091,12 @@ pub mod pallet { } else { // Need to notify target. let response = Response::Version(xcm_version); - let message = - Xcm(vec![QueryResponse { query_id, response, max_weight }]); + let message = Xcm(vec![QueryResponse { + query_id, + response, + max_weight, + querier: None, + }]); let event = match T::XcmRouter::send_xcm(new_key.clone(), message) { Ok(()) => { VersionNotifyTargets::::insert( @@ -1076,10 +1173,12 @@ pub mod pallet { AccountIdConversion::::into_account(&ID) } + /// Create a new expectation of a query response with the querier being here. fn do_new_query( responder: impl Into, maybe_notify: Option<(u8, u8)>, timeout: T::BlockNumber, + match_querier: impl Into, ) -> u64 { QueryCounter::::mutate(|q| { let r = *q; @@ -1088,6 +1187,7 @@ pub mod pallet { r, QueryStatus::Pending { responder: responder.into().into(), + maybe_match_querier: Some(match_querier.into().into()), maybe_notify, timeout, }, @@ -1106,6 +1206,8 @@ pub mod pallet { /// /// `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( @@ -1116,7 +1218,7 @@ pub mod pallet { let responder = responder.into(); let destination = T::LocationInverter::invert_location(&responder) .map_err(|()| XcmError::MultiLocationNotInvertible)?; - let query_id = Self::new_query(responder, timeout); + let query_id = Self::new_query(responder, timeout, Here); let response_info = QueryResponseInfo { destination, query_id, max_weight: 0 }; let report_error = Xcm(vec![ReportError(response_info)]); message.0.insert(0, SetAppendix(report_error)); @@ -1138,6 +1240,8 @@ pub mod pallet { /// /// `report_outcome_notify` may return an error if the `responder` is not invertible. /// + /// It is assumed that the querier of the response will be `Here`. + /// /// NOTE: `notify` gets called as part of handling an incoming message, so it should be /// lightweight. Its weight is estimated during this function and stored ready for /// weighing `ReportOutcome` on the way back. If it turns out to be heavier once it returns @@ -1154,7 +1258,7 @@ pub mod pallet { .map_err(|()| XcmError::MultiLocationNotInvertible)?; let notify: ::Call = notify.into(); let max_weight = notify.get_dispatch_info().weight; - let query_id = Self::new_notify_query(responder, notify, timeout); + let query_id = Self::new_notify_query(responder, notify, timeout, Here); let response_info = QueryResponseInfo { destination, query_id, max_weight }; let report_error = Xcm(vec![ReportError(response_info)]); message.0.insert(0, SetAppendix(report_error)); @@ -1162,8 +1266,12 @@ pub mod pallet { } /// 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) -> u64 { - Self::do_new_query(responder, None, timeout) + 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 @@ -1172,12 +1280,13 @@ pub mod pallet { responder: impl Into, notify: impl Into<::Call>, timeout: T::BlockNumber, + match_querier: impl Into, ) -> u64 { let notify = notify.into().using_encoded(|mut bytes| Decode::decode(&mut bytes)).expect( "decode input is output of Call encode; Call guaranteed to have two enums; qed", ); - Self::do_new_query(responder, Some(notify), timeout) + Self::do_new_query(responder, Some(notify), timeout, match_querier) } /// Attempt to remove and return the response of query with ID `query_id`. @@ -1252,7 +1361,7 @@ pub mod pallet { let xcm_version = T::AdvertisedXcmVersion::get(); let response = Response::Version(xcm_version); - let instruction = QueryResponse { query_id, response, max_weight }; + let instruction = QueryResponse { query_id, response, max_weight, querier: None }; T::XcmRouter::send_xcm(dest.clone(), Xcm(vec![instruction]))?; let value = (query_id, max_weight, xcm_version); @@ -1315,10 +1424,19 @@ pub mod pallet { } impl OnResponse for Pallet { - fn expecting_response(origin: &MultiLocation, query_id: QueryId) -> bool { + fn expecting_response( + origin: &MultiLocation, + query_id: QueryId, + querier: Option<&MultiLocation>, + ) -> bool { match Queries::::get(query_id) { - Some(QueryStatus::Pending { responder, .. }) => - MultiLocation::try_from(responder).map_or(false, |r| origin == &r), + Some(QueryStatus::Pending { responder, maybe_match_querier, .. }) => + MultiLocation::try_from(responder).map_or(false, |r| origin == &r) && + maybe_match_querier.map_or(true, |match_querier| { + MultiLocation::try_from(match_querier).map_or(false, |match_querier| { + querier.map_or(false, |q| q == &match_querier) + }) + }), Some(QueryStatus::VersionNotifier { origin: r, .. }) => MultiLocation::try_from(r).map_or(false, |r| origin == &r), _ => false, @@ -1328,6 +1446,7 @@ pub mod pallet { fn on_response( origin: &MultiLocation, query_id: QueryId, + querier: Option<&MultiLocation>, response: Response, max_weight: Weight, ) -> Weight { @@ -1375,7 +1494,33 @@ pub mod pallet { Self::deposit_event(Event::SupportedVersionChanged(origin, v)); 0 }, - (response, Some(QueryStatus::Pending { responder, maybe_notify, .. })) => { + ( + response, + Some(QueryStatus::Pending { + responder, maybe_notify, maybe_match_querier, .. + }), + ) => { + if let Some(match_querier) = maybe_match_querier { + let match_querier = match MultiLocation::try_from(match_querier) { + Ok(mq) => mq, + Err(_) => { + Self::deposit_event(Event::InvalidQuerierVersion( + origin.clone(), + query_id, + )); + return 0 + }, + }; + if querier.map_or(true, |q| q != &match_querier) { + Self::deposit_event(Event::InvalidQuerier( + origin.clone(), + query_id, + match_querier, + querier.cloned(), + )); + return 0 + } + } let responder = match MultiLocation::try_from(responder) { Ok(r) => r, Err(_) => { diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index af9ef8f98548..584dc651a906 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -74,7 +74,7 @@ pub mod pallet_test_notifier { #[pallet::call] impl Pallet { #[pallet::weight(1_000_000)] - pub fn prepare_new_query(origin: OriginFor) -> DispatchResult { + pub fn prepare_new_query(origin: OriginFor, querier: MultiLocation) -> DispatchResult { let who = ensure_signed(origin)?; let id = who .using_encoded(|mut d| <[u8; 32]>::decode(&mut d)) @@ -82,13 +82,17 @@ pub mod pallet_test_notifier { let qid = crate::Pallet::::new_query( Junction::AccountId32 { network: Any, id }.into(), 100u32.into(), + querier, ); Self::deposit_event(Event::::QueryPrepared(qid)); Ok(()) } #[pallet::weight(1_000_000)] - pub fn prepare_new_notify_query(origin: OriginFor) -> DispatchResult { + pub fn prepare_new_notify_query( + origin: OriginFor, + querier: MultiLocation, + ) -> DispatchResult { let who = ensure_signed(origin)?; let id = who .using_encoded(|mut d| <[u8; 32]>::decode(&mut d)) @@ -99,6 +103,7 @@ pub mod pallet_test_notifier { Junction::AccountId32 { network: Any, id }.into(), ::Call::from(call), 100u32.into(), + querier, ); Self::deposit_event(Event::::NotifyQueryPrepared(qid)); Ok(()) diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index 7b9b6ce864c6..c346026d17cf 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -63,10 +63,12 @@ fn report_outcome_notify_works() { TransferAsset { assets: (Here, SEND_AMOUNT).into(), beneficiary: sender.clone() }, ]) ); + let querier: MultiLocation = Here.into(); let status = QueryStatus::Pending { responder: MultiLocation::from(Parachain(PARA_ID)).into(), maybe_notify: Some((4, 2)), timeout: 100, + maybe_match_querier: Some(querier.clone().into()), }; assert_eq!(crate::Queries::::iter().collect::>(), vec![(0, status)]); @@ -76,6 +78,7 @@ fn report_outcome_notify_works() { query_id: 0, response: Response::ExecutionResult(None), max_weight: 1_000_000, + querier: Some(querier), }]), 1_000_000_000, ); @@ -117,10 +120,12 @@ fn report_outcome_works() { TransferAsset { assets: (Here, SEND_AMOUNT).into(), beneficiary: sender.clone() }, ]) ); + let querier: MultiLocation = Here.into(); let status = QueryStatus::Pending { responder: MultiLocation::from(Parachain(PARA_ID)).into(), maybe_notify: None, timeout: 100, + maybe_match_querier: Some(querier.clone().into()), }; assert_eq!(crate::Queries::::iter().collect::>(), vec![(0, status)]); @@ -130,6 +135,97 @@ fn report_outcome_works() { query_id: 0, response: Response::ExecutionResult(None), max_weight: 0, + querier: Some(querier), + }]), + 1_000_000_000, + ); + assert_eq!(r, Outcome::Complete(1_000)); + assert_eq!( + last_event(), + Event::XcmPallet(crate::Event::ResponseReady(0, Response::ExecutionResult(None),)) + ); + + let response = Some((Response::ExecutionResult(None), 1)); + assert_eq!(XcmPallet::take_response(0), response); + }); +} + +#[test] +fn custom_querier_works() { + let balances = + vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; + new_test_ext_with_balances(balances).execute_with(|| { + let querier: MultiLocation = + (Parent, AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }).into(); + + let r = TestNotifier::prepare_new_query(Origin::signed(ALICE), querier.clone()); + assert_eq!(r, Ok(())); + let status = QueryStatus::Pending { + responder: MultiLocation::from(AccountId32 { + network: AnyNetwork::get(), + id: ALICE.into(), + }) + .into(), + maybe_notify: None, + timeout: 100, + maybe_match_querier: Some(querier.clone().into()), + }; + assert_eq!(crate::Queries::::iter().collect::>(), vec![(0, status)]); + + // Supplying no querier when one is expected will fail + let r = XcmExecutor::::execute_xcm_in_credit( + AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: 0, + querier: None, + }]), + 1_000_000_000, + 1_000, + ); + assert_eq!(r, Outcome::Complete(1_000)); + assert_eq!( + last_event(), + Event::XcmPallet(crate::Event::InvalidQuerier( + AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + 0, + querier.clone(), + None, + )), + ); + + // Supplying the wrong querier will also fail + let r = XcmExecutor::::execute_xcm_in_credit( + AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: 0, + querier: Some(MultiLocation::here()), + }]), + 1_000_000_000, + 1_000, + ); + assert_eq!(r, Outcome::Complete(1_000)); + assert_eq!( + last_event(), + Event::XcmPallet(crate::Event::InvalidQuerier( + AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + 0, + querier.clone(), + Some(MultiLocation::here()), + )), + ); + + // Multiple failures should not have changed the query state + let r = XcmExecutor::::execute_xcm( + AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: 0, + querier: Some(querier), }]), 1_000_000_000, ); @@ -617,7 +713,12 @@ fn basic_subscription_works() { let weight = BaseXcmWeight::get(); let mut message = Xcm::<()>(vec![ // Remote supports XCM v1 - QueryResponse { query_id: 0, max_weight: 0, response: Response::Version(1) }, + QueryResponse { + query_id: 0, + max_weight: 0, + response: Response::Version(1), + querier: None, + }, ]); assert_ok!(AllowKnownQueryResponses::::should_execute( &remote, @@ -722,7 +823,12 @@ fn subscription_side_works() { let r = XcmExecutor::::execute_xcm(remote.clone(), message, weight); assert_eq!(r, Outcome::Complete(weight)); - let instr = QueryResponse { query_id: 0, max_weight: 0, response: Response::Version(1) }; + let instr = QueryResponse { + query_id: 0, + max_weight: 0, + response: Response::Version(1), + querier: None, + }; assert_eq!(take_sent_xcm(), vec![(remote.clone(), Xcm(vec![instr]))]); // A runtime upgrade which doesn't alter the version sends no notifications. @@ -736,7 +842,12 @@ fn subscription_side_works() { // A runtime upgrade which alters the version does send notifications. XcmPallet::on_runtime_upgrade(); XcmPallet::on_initialize(2); - let instr = QueryResponse { query_id: 0, max_weight: 0, response: Response::Version(2) }; + let instr = QueryResponse { + query_id: 0, + max_weight: 0, + response: Response::Version(2), + querier: None, + }; assert_eq!(take_sent_xcm(), vec![(remote.clone(), Xcm(vec![instr]))]); }); } @@ -762,9 +873,24 @@ fn subscription_side_upgrades_work_with_notify() { XcmPallet::on_runtime_upgrade(); XcmPallet::on_initialize(1); - let instr0 = QueryResponse { query_id: 69, max_weight: 0, response: Response::Version(2) }; - let instr1 = QueryResponse { query_id: 70, max_weight: 0, response: Response::Version(2) }; - let instr2 = QueryResponse { query_id: 71, max_weight: 0, response: Response::Version(2) }; + let instr0 = QueryResponse { + query_id: 69, + max_weight: 0, + response: Response::Version(2), + querier: None, + }; + let instr1 = QueryResponse { + query_id: 70, + max_weight: 0, + response: Response::Version(2), + querier: None, + }; + let instr2 = QueryResponse { + query_id: 71, + max_weight: 0, + response: Response::Version(2), + querier: None, + }; let mut sent = take_sent_xcm(); sent.sort_by_key(|k| match (k.1).0[0] { QueryResponse { query_id: q, .. } => q, @@ -836,7 +962,12 @@ fn subscriber_side_subscription_works() { let weight = BaseXcmWeight::get(); let message = Xcm(vec![ // Remote supports XCM v1 - QueryResponse { query_id: 0, max_weight: 0, response: Response::Version(1) }, + QueryResponse { + query_id: 0, + max_weight: 0, + response: Response::Version(1), + querier: None, + }, ]); let r = XcmExecutor::::execute_xcm(remote.clone(), message, weight); assert_eq!(r, Outcome::Complete(weight)); @@ -848,7 +979,12 @@ fn subscriber_side_subscription_works() { let message = Xcm(vec![ // Remote upgraded to XCM v2 - QueryResponse { query_id: 0, max_weight: 0, response: Response::Version(2) }, + QueryResponse { + query_id: 0, + max_weight: 0, + response: Response::Version(2), + querier: None, + }, ]); let r = XcmExecutor::::execute_xcm(remote.clone(), message, weight); assert_eq!(r, Outcome::Complete(weight)); @@ -903,7 +1039,12 @@ fn auto_subscription_works() { let weight = BaseXcmWeight::get(); let message = Xcm(vec![ // Remote supports XCM v2 - QueryResponse { query_id: 0, max_weight: 0, response: Response::Version(2) }, + QueryResponse { + query_id: 0, + max_weight: 0, + response: Response::Version(2), + querier: None, + }, ]); let r = XcmExecutor::::execute_xcm(remote0.clone(), message, weight); assert_eq!(r, Outcome::Complete(weight)); @@ -928,7 +1069,12 @@ fn auto_subscription_works() { let weight = BaseXcmWeight::get(); let message = Xcm(vec![ // Remote supports XCM v1 - QueryResponse { query_id: 1, max_weight: 0, response: Response::Version(1) }, + QueryResponse { + query_id: 1, + max_weight: 0, + response: Response::Version(1), + querier: None, + }, ]); let r = XcmExecutor::::execute_xcm(remote1.clone(), message, weight); assert_eq!(r, Outcome::Complete(weight)); @@ -967,9 +1113,24 @@ fn subscription_side_upgrades_work_with_multistage_notify() { } assert_eq!(counter, 4); - let instr0 = QueryResponse { query_id: 69, max_weight: 0, response: Response::Version(2) }; - let instr1 = QueryResponse { query_id: 70, max_weight: 0, response: Response::Version(2) }; - let instr2 = QueryResponse { query_id: 71, max_weight: 0, response: Response::Version(2) }; + let instr0 = QueryResponse { + query_id: 69, + max_weight: 0, + response: Response::Version(2), + querier: None, + }; + let instr1 = QueryResponse { + query_id: 70, + max_weight: 0, + response: Response::Version(2), + querier: None, + }; + let instr2 = QueryResponse { + query_id: 71, + max_weight: 0, + response: Response::Version(2), + querier: None, + }; let mut sent = take_sent_xcm(); sent.sort_by_key(|k| match (k.1).0[0] { QueryResponse { query_id: q, .. } => q, diff --git a/xcm/src/v1/multilocation.rs b/xcm/src/v1/multilocation.rs index 12b507329215..6c8c648a9c77 100644 --- a/xcm/src/v1/multilocation.rs +++ b/xcm/src/v1/multilocation.rs @@ -324,6 +324,21 @@ impl MultiLocation { Ok(()) } + /// Consume `self` and return the value representing the same location from the point of view + /// of `target`. The context of `self` is provided as `ancestry`. + /// + /// Returns an `Err` with the unmodified `self` in the case of error. + pub fn reanchored( + mut self, + target: &MultiLocation, + ancestry: &MultiLocation, + ) -> Result { + match self.reanchor(target, ancestry) { + Ok(()) => Ok(self), + Err(()) => Err(self), + } + } + /// Mutate `self` so that it represents the same location from the point of view of `target`. /// The context of `self` is provided as `ancestry`. /// diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index 22b3f81af697..c76cd10c513a 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -932,7 +932,7 @@ impl TryFrom> for Instruction { WithdrawAsset(assets) => Self::WithdrawAsset(assets), ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets), ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets), - QueryResponse { query_id, response, max_weight } => + QueryResponse { query_id, response, max_weight, .. } => Self::QueryResponse { query_id, response: response.try_into()?, max_weight }, TransferAsset { assets, beneficiary } => Self::TransferAsset { assets, beneficiary }, TransferReserveAsset { assets, dest, xcm } => diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 959847aebee5..ca057e15e42c 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -263,8 +263,15 @@ pub enum Instruction { /// - `query_id`: The identifier of the query that resulted in this message being sent. /// - `response`: The message content. /// - `max_weight`: The maximum weight that handling this response should take. + /// - `querier`: The location responsible for the initiation of the response, if there is one. + /// In general this will tend to be the same location as the receiver of this message. + /// NOTE: As usual, this is interpreted from the perspective of the receiving consensus + /// system. /// - /// Safety: No concerns. + /// Safety: Since this is information only, there are no immediate concerns. However, it should + /// be remembered that even if the Origin behaves reasonably, it can always be asked to make + /// a response to a third-party chain who may or may not be expecting the response. Therefore + /// the `querier` should be checked to match the expected value. /// /// Kind: *Information*. /// @@ -275,6 +282,7 @@ pub enum Instruction { response: Response, #[codec(compact)] max_weight: Weight, + querier: Option, }, /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets @@ -729,8 +737,8 @@ impl Instruction { WithdrawAsset(assets) => WithdrawAsset(assets), ReserveAssetDeposited(assets) => ReserveAssetDeposited(assets), ReceiveTeleportedAsset(assets) => ReceiveTeleportedAsset(assets), - QueryResponse { query_id, response, max_weight } => - QueryResponse { query_id, response, max_weight }, + QueryResponse { query_id, response, max_weight, querier } => + QueryResponse { query_id, response, max_weight, querier }, TransferAsset { assets, beneficiary } => TransferAsset { assets, beneficiary }, TransferReserveAsset { assets, dest, xcm } => TransferReserveAsset { assets, dest, xcm }, @@ -783,7 +791,7 @@ impl> GetWeight for Instruction { WithdrawAsset(assets) => W::withdraw_asset(assets), ReserveAssetDeposited(assets) => W::reserve_asset_deposited(assets), ReceiveTeleportedAsset(assets) => W::receive_teleported_asset(assets), - QueryResponse { query_id, response, max_weight } => + QueryResponse { query_id, response, max_weight, .. } => W::query_response(query_id, response, max_weight), TransferAsset { assets, beneficiary } => W::transfer_asset(assets, beneficiary), TransferReserveAsset { assets, dest, xcm } => @@ -873,8 +881,12 @@ impl TryFrom> for Instruction { WithdrawAsset(assets) => Self::WithdrawAsset(assets), ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets), ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets), - QueryResponse { query_id, response, max_weight } => - Self::QueryResponse { query_id, response: response.try_into()?, max_weight }, + QueryResponse { query_id, response, max_weight } => Self::QueryResponse { + query_id, + response: response.try_into()?, + max_weight, + querier: None, + }, TransferAsset { assets, beneficiary } => Self::TransferAsset { assets, beneficiary }, TransferReserveAsset { assets, dest, xcm } => Self::TransferReserveAsset { assets, dest, xcm: xcm.try_into()? }, diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 2d4e8ff2325f..b28e7a730784 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -108,6 +108,9 @@ pub enum Error { /// The given operation would lead to an overflow of the Holding Register. #[codec(index = 26)] HoldingWouldOverflow, + /// `MultiLocation` value failed to be reanchored. + #[codec(index = 27)] + ReanchorFailed, // Errors that happen prior to instructions being executed. These fall outside of the XCM spec. /// XCM version not able to be handled. diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index ef7333e6d140..be4a6291c61d 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -138,8 +138,8 @@ impl ShouldExecute for AllowKnownQueryResponses + Some(QueryResponse { query_id, querier, .. }) + if ResponseHandler::expecting_response(origin, *query_id, querier.as_ref()) => Ok(()), _ => Err(()), } diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index d88df21050b6..74ba7f1fbd74 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -216,7 +216,11 @@ thread_local! { } pub struct TestResponseHandler; impl OnResponse for TestResponseHandler { - fn expecting_response(origin: &MultiLocation, query_id: u64) -> bool { + fn expecting_response( + origin: &MultiLocation, + query_id: u64, + _querier: Option<&MultiLocation>, + ) -> bool { QUERIES.with(|q| match q.borrow().get(&query_id) { Some(ResponseSlot::Expecting(ref l)) => l == origin, _ => false, @@ -225,6 +229,7 @@ impl OnResponse for TestResponseHandler { fn on_response( _origin: &MultiLocation, query_id: u64, + _querier: Option<&MultiLocation>, response: xcm::latest::Response, _max_weight: Weight, ) -> Weight { diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index bbcc4fe14bbe..81513e267511 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -646,6 +646,7 @@ fn prepaid_result_of_query_should_get_free_execution() { query_id, response: the_response.clone(), max_weight: 10, + querier: Some(Here.into().into()), }]); let weight_limit = 10; @@ -735,6 +736,7 @@ fn pallet_query_should_work() { query_id: 1, max_weight: 50, response: Response::PalletsInfo(vec![]), + querier: Some(Here.into()), }]), )] ); @@ -774,6 +776,7 @@ fn pallet_query_with_results_should_work() { minor: 42, patch: 69, },]), + querier: Some(Here.into()), }]), )] ); @@ -806,6 +809,7 @@ fn report_successful_transact_status_should_work() { response: Response::DispatchResult(MaybeErrorCode::Success), query_id: 42, max_weight: 5000, + querier: Some(Here.into()), }]) )] ); @@ -838,6 +842,7 @@ fn report_failed_transact_status_should_work() { response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), query_id: 42, max_weight: 5000, + querier: Some(Here.into()), }]) )] ); @@ -871,6 +876,7 @@ fn clear_transact_status_should_work() { response: Response::DispatchResult(MaybeErrorCode::Success), query_id: 42, max_weight: 5000, + querier: Some(Here.into()), }]) )] ); diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index b45b9b96c6cf..e3c0469df55c 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -142,6 +142,7 @@ fn report_holding_works() { query_id: response_info.query_id, response: Response::Assets(vec![].into()), max_weight: response_info.max_weight, + querier: Some(Here.into().into()), }]), )] ); diff --git a/xcm/xcm-executor/integration-tests/src/lib.rs b/xcm/xcm-executor/integration-tests/src/lib.rs index 5f49aa2384f0..3da4867515a8 100644 --- a/xcm/xcm-executor/integration-tests/src/lib.rs +++ b/xcm/xcm-executor/integration-tests/src/lib.rs @@ -119,7 +119,8 @@ fn query_response_fires() { let response = Response::ExecutionResult(None); let max_weight = 1_000_000; - let msg = Xcm(vec![QueryResponse { query_id, response, max_weight }]); + let querier = Some(Here.into()); + let msg = Xcm(vec![QueryResponse { query_id, response, max_weight, querier }]); let msg = Box::new(VersionedXcm::from(msg)); let execute = construct_extrinsic( @@ -208,7 +209,8 @@ fn query_response_elicits_handler() { let response = Response::ExecutionResult(None); let max_weight = 1_000_000; - let msg = Xcm(vec![QueryResponse { query_id, response, max_weight }]); + let querier = Some(Here.into()); + let msg = Xcm(vec![QueryResponse { query_id, response, max_weight, querier }]); let execute = construct_extrinsic( &client, diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 33fc376e39c2..af5d585750ce 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -392,9 +392,15 @@ impl XcmExecutor { self.total_surplus.saturating_accrue(surplus); Ok(()) }, - QueryResponse { query_id, response, max_weight } => { + QueryResponse { query_id, response, max_weight, querier } => { let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; - Config::ResponseHandler::on_response(origin, query_id, response, max_weight); + Config::ResponseHandler::on_response( + origin, + query_id, + querier.as_ref(), + response, + max_weight, + ); Ok(()) }, DescendOrigin(who) => self @@ -410,7 +416,11 @@ impl XcmExecutor { ReportError(response_info) => { // Report the given result by sending a QueryResponse XCM to a previously given outcome // destination if one was registered. - Self::respond(Response::ExecutionResult(self.error), response_info) + Self::respond( + self.origin.clone(), + Response::ExecutionResult(self.error), + response_info, + ) }, DepositAsset { assets, beneficiary } => { let deposited = self.holding.saturating_take(assets); @@ -461,7 +471,7 @@ impl XcmExecutor { // from Holding. let assets = Self::reanchored(self.holding.min(&assets), &response_info.destination, None); - Self::respond(Response::Assets(assets), response_info) + Self::respond(self.origin.clone(), Response::Assets(assets), response_info) }, BuyExecution { fees, weight_limit } => { // There is no need to buy any weight is `weight_limit` is `Unlimited` since it @@ -549,7 +559,8 @@ impl XcmExecutor { .collect::>(); let QueryResponseInfo { destination, query_id, max_weight } = response_info; let response = Response::PalletsInfo(pallets); - let instruction = QueryResponse { query_id, response, max_weight }; + let querier = Self::to_querier(self.origin.clone(), &destination)?; + let instruction = QueryResponse { query_id, response, max_weight, querier }; let message = Xcm(vec![instruction]); Config::XcmSender::send_xcm(destination, message).map_err(Into::into) }, @@ -566,8 +577,11 @@ impl XcmExecutor { ensure!(minor >= min_crate_minor, XcmError::VersionIncompatible); Ok(()) }, - ReportTransactStatus(response_info) => - Self::respond(Response::DispatchResult(self.transact_status.clone()), response_info), + ReportTransactStatus(response_info) => Self::respond( + self.origin.clone(), + Response::DispatchResult(self.transact_status.clone()), + response_info, + ), ClearTransactStatus => { self.transact_status = Default::default(); Ok(()) @@ -579,10 +593,31 @@ impl XcmExecutor { } } + /// Calculates what `local_querier` would be from the perspective of `destination`. + fn to_querier( + local_querier: Option, + destination: &MultiLocation, + ) -> Result, XcmError> { + Ok(match local_querier { + None => None, + Some(q) => Some( + q.reanchored(&destination, &Config::LocationInverter::ancestry()) + .map_err(|_| XcmError::ReanchorFailed)?, + ), + }) + } + /// Send a bare `QueryResponse` message containing `response` informed by the given `info`. - fn respond(response: Response, info: QueryResponseInfo) -> Result<(), XcmError> { + /// + /// The `local_querier` argument is the querier (if any) specified from the *local* perspective. + fn respond( + local_querier: Option, + response: Response, + info: QueryResponseInfo, + ) -> Result<(), XcmError> { + let querier = Self::to_querier(local_querier, &info.destination)?; let QueryResponseInfo { destination, query_id, max_weight } = info; - let instruction = QueryResponse { query_id, response, max_weight }; + let instruction = QueryResponse { query_id, response, max_weight, querier }; let message = Xcm(vec![instruction]); Config::XcmSender::send_xcm(destination, message).map_err(Into::into) } diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index 2c5ef4f0c3ad..016976453511 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -19,23 +19,35 @@ use xcm::latest::{Error as XcmError, MultiLocation, QueryId, Response, Result as /// Define what needs to be done upon receiving a query response. pub trait OnResponse { - /// Returns `true` if we are expecting a response from `origin` for query `query_id`. - fn expecting_response(origin: &MultiLocation, query_id: u64) -> bool; - /// Handler for receiving a `response` from `origin` relating to `query_id`. + /// Returns `true` if we are expecting a response from `origin` for query `query_id` that was + /// queried by `querier`. + fn expecting_response( + origin: &MultiLocation, + query_id: u64, + querier: Option<&MultiLocation>, + ) -> bool; + /// Handler for receiving a `response` from `origin` relating to `query_id` initiated by + /// `querier`. fn on_response( origin: &MultiLocation, query_id: u64, + querier: Option<&MultiLocation>, response: Response, max_weight: Weight, ) -> Weight; } impl OnResponse for () { - fn expecting_response(_origin: &MultiLocation, _query_id: u64) -> bool { + fn expecting_response( + _origin: &MultiLocation, + _query_id: u64, + _querier: Option<&MultiLocation>, + ) -> bool { false } fn on_response( _origin: &MultiLocation, _query_id: u64, + _querier: Option<&MultiLocation>, _response: Response, _max_weight: Weight, ) -> Weight { diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index e0e87899da99..0deb3a7f2227 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -305,6 +305,7 @@ mod tests { query_id: query_id_set, response: Response::Assets(MultiAssets::new()), max_weight: 1_000_000_000, + querier: Some(Here.into()), }])], ); }); From 79c6d554874d3ba69f4b91bdfa00c9b6881fe11e Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 21 Jan 2022 05:45:59 -0800 Subject: [PATCH 057/231] Fixes --- xcm/src/v3/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index ca057e15e42c..85535badc66d 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -791,8 +791,8 @@ impl> GetWeight for Instruction { WithdrawAsset(assets) => W::withdraw_asset(assets), ReserveAssetDeposited(assets) => W::reserve_asset_deposited(assets), ReceiveTeleportedAsset(assets) => W::receive_teleported_asset(assets), - QueryResponse { query_id, response, max_weight, .. } => - W::query_response(query_id, response, max_weight), + QueryResponse { query_id, response, max_weight, querier } => + W::query_response(query_id, response, max_weight, querier), TransferAsset { assets, beneficiary } => W::transfer_asset(assets, beneficiary), TransferReserveAsset { assets, dest, xcm } => W::transfer_reserve_asset(&assets, dest, xcm), From 87e581562b92ed45d6f711c46b07ec301c90289f Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sun, 23 Jan 2022 09:58:51 -0800 Subject: [PATCH 058/231] Fixes --- runtime/westend/src/weights/xcm/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 0116b0a04d54..e801c79e5e96 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -79,7 +79,12 @@ impl XcmWeightInfo for WestendXcmWeight { fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) } - fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> Weight { + fn query_response( + _query_id: &u64, + _response: &Response, + _max_weight: &u64, + _querier: &Option, + ) -> Weight { XcmGeneric::::query_response() } fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { From e640d826513c45a0452138c8908a699e19ac0143 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 10 Feb 2022 15:16:02 +0100 Subject: [PATCH 059/231] Add `starts_with` function to `MultiLocation` and `Junctions` (#4835) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add matches_prefix function to MultiLocation and Junctions * rename matches_prefix to starts_with * remove unnecessary main in doc comment Co-authored-by: Bastian Köcher * Make use of starts_with in match_and_split Co-authored-by: Bastian Köcher Co-authored-by: Keith Yeung --- xcm/src/v0/multi_location.rs | 25 +++++++++++++++----- xcm/src/v1/multilocation.rs | 44 +++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/xcm/src/v0/multi_location.rs b/xcm/src/v0/multi_location.rs index 6b7438b93fa0..0df525f06577 100644 --- a/xcm/src/v0/multi_location.rs +++ b/xcm/src/v0/multi_location.rs @@ -356,17 +356,30 @@ impl MultiLocation { /// # } /// ``` pub fn match_and_split(&self, prefix: &MultiLocation) -> Option<&Junction> { - if prefix.len() + 1 != self.len() { + if prefix.len() + 1 != self.len() || !self.starts_with(prefix) { return None } - for i in 0..prefix.len() { - if prefix.at(i) != self.at(i) { - return None - } - } return self.at(prefix.len()) } + /// Returns whether `self` begins with or is equal to `prefix`. + /// + /// # Example + /// ```rust + /// # use xcm::v0::{Junction::*, MultiLocation::*}; + /// let m = X4(Parent, PalletInstance(3), OnlyChild, OnlyChild); + /// assert!(m.starts_with(&X2(Parent, PalletInstance(3)))); + /// assert!(m.starts_with(&m)); + /// assert!(!m.starts_with(&X2(Parent, GeneralIndex(99)))); + /// assert!(!m.starts_with(&X1(PalletInstance(3)))); + /// ``` + pub fn starts_with(&self, prefix: &MultiLocation) -> bool { + if self.len() < prefix.len() { + return false + } + prefix.iter().zip(self.iter()).all(|(l, r)| l == r) + } + /// Mutates `self`, suffixing it with `new`. Returns `Err` in case of overflow. pub fn push(&mut self, new: Junction) -> result::Result<(), ()> { let mut n = MultiLocation::Null; diff --git a/xcm/src/v1/multilocation.rs b/xcm/src/v1/multilocation.rs index 6c8c648a9c77..b02bf9d3b07a 100644 --- a/xcm/src/v1/multilocation.rs +++ b/xcm/src/v1/multilocation.rs @@ -253,6 +253,24 @@ impl MultiLocation { self.interior.match_and_split(&prefix.interior) } + /// Returns whether `self` has the same number of parents as `prefix` and its junctions begins + /// with the junctions of `prefix`. + /// + /// # Example + /// ```rust + /// # use xcm::v1::{Junctions::*, Junction::*, MultiLocation}; + /// let m = MultiLocation::new(1, X3(PalletInstance(3), OnlyChild, OnlyChild)); + /// assert!(m.starts_with(&MultiLocation::new(1, X1(PalletInstance(3))))); + /// assert!(!m.starts_with(&MultiLocation::new(1, X1(GeneralIndex(99))))); + /// assert!(!m.starts_with(&MultiLocation::new(0, X1(PalletInstance(3))))); + /// ``` + pub fn starts_with(&self, prefix: &MultiLocation) -> bool { + if self.parents != prefix.parents { + return false + } + self.interior.starts_with(&prefix.interior) + } + /// Mutate `self` so that it is suffixed with `suffix`. /// /// Does not modify `self` and returns `Err` with `suffix` in case of overflow. @@ -816,15 +834,29 @@ impl Junctions { /// # } /// ``` pub fn match_and_split(&self, prefix: &Junctions) -> Option<&Junction> { - if prefix.len() + 1 != self.len() { + if prefix.len() + 1 != self.len() || !self.starts_with(prefix) { return None } - for i in 0..prefix.len() { - if prefix.at(i) != self.at(i) { - return None - } + self.at(prefix.len()) + } + + /// Returns whether `self` begins with or is equal to `prefix`. + /// + /// # Example + /// ```rust + /// # use xcm::v1::{Junctions::*, Junction::*}; + /// let mut j = X3(Parachain(2), PalletInstance(3), OnlyChild); + /// assert!(j.starts_with(&X2(Parachain(2), PalletInstance(3)))); + /// assert!(j.starts_with(&j)); + /// assert!(j.starts_with(&X1(Parachain(2)))); + /// assert!(!j.starts_with(&X1(Parachain(999)))); + /// assert!(!j.starts_with(&X4(Parachain(2), PalletInstance(3), OnlyChild, OnlyChild))); + /// ``` + pub fn starts_with(&self, prefix: &Junctions) -> bool { + if self.len() < prefix.len() { + return false } - return self.at(prefix.len()) + prefix.iter().zip(self.iter()).all(|(l, r)| l == r) } } From 6185cf32dc1c55759fc9481691a8409554aa0754 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 14 Feb 2022 23:51:43 +0100 Subject: [PATCH 060/231] XCM v3: Bridge infrastructure (#4681) * XCM bridge infrastructure * Missing bit of cherry-pick * Revamped XCM proc macros; new NetworkIds * Fixes * Formatting * ExportMessage instruction and config type * Add MessageExporter definitions * Formatting * Missing files * Fixes * Initial bridging config API * Allow for two-stage XCM execution * Update xcm/src/v3/mod.rs Co-authored-by: Keith Yeung * XCM crate building again * Initial bridging primitive * Docs * Docs * More work * More work * Merge branch 'gav-xcm-v3' into gav-xcm-v3-bridging * Make build * WithComputedOrigin and SovereignPaidRemoteExporter * Remove TODOs * Slim bridge API and tests. * Fixes * More work * First bridge test passing * Formatting * Another test * Next round of bridging tests * Repot tests * Cleanups * Paid bridging * Formatting * Tests * Spelling * Formatting * Fees and refactoring * Fixes * Formatting * Refactor SendXcm to become two-phase * Fix tests * Refactoring of SendXcm and ExportXcm complete * Formatting * Rename CannotReachDestination -> NotApplicable * Remove XCM v0 * Minor grumbles * Formatting * Formatting * Fixes * Fixes * Cleanup XCM config * Fee handling * Fixes * Formatting * Fixes * Bump Co-authored-by: Keith Yeung --- Cargo.lock | 2 + bridges/primitives/messages/Cargo.toml | 2 +- runtime/common/src/xcm_sender.rs | 59 +- runtime/kusama/src/xcm_config.rs | 46 +- runtime/parachains/src/dmp.rs | 15 + runtime/polkadot/src/xcm_config.rs | 43 +- runtime/rococo/src/xcm_config.rs | 49 +- runtime/test-runtime/src/lib.rs | 6 +- runtime/test-runtime/src/xcm_config.rs | 24 +- runtime/westend/src/lib.rs | 10 +- runtime/westend/src/tests.rs | 8 +- runtime/westend/src/weights/xcm/mod.rs | 6 + runtime/westend/src/xcm_config.rs | 36 +- scripts/gitlab/lingua.dic | 3 + .../src/fungible/mock.rs | 16 +- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 8 +- xcm/pallet-xcm-benchmarks/src/lib.rs | 2 +- xcm/pallet-xcm-benchmarks/src/mock.rs | 8 +- xcm/pallet-xcm/src/lib.rs | 33 +- xcm/pallet-xcm/src/mock.rs | 48 +- xcm/pallet-xcm/src/tests.rs | 187 ++--- xcm/procedural/src/lib.rs | 23 +- xcm/procedural/src/v0.rs | 17 - xcm/procedural/src/v0/multilocation.rs | 115 --- xcm/procedural/src/v1/multilocation.rs | 47 +- xcm/procedural/src/v3.rs | 186 +++++ xcm/src/lib.rs | 222 +++--- xcm/src/v0/junction.rs | 205 ----- xcm/src/v0/mod.rs | 388 ---------- xcm/src/v0/multi_asset.rs | 410 ---------- xcm/src/v0/multi_location.rs | 728 ------------------ xcm/src/v0/order.rs | 207 ----- xcm/src/v0/traits.rs | 263 ------- xcm/src/v1/junction.rs | 36 +- xcm/src/v1/mod.rs | 187 +++-- xcm/src/v1/multiasset.rs | 135 +--- xcm/src/v1/multilocation.rs | 47 +- xcm/src/v1/order.rs | 57 +- xcm/src/v1/traits.rs | 14 +- xcm/src/v2/mod.rs | 85 +- xcm/src/v2/traits.rs | 16 +- xcm/src/v3/junction.rs | 205 +++++ xcm/src/v3/junctions.rs | 579 ++++++++++++++ xcm/src/v3/mod.rs | 205 +++-- xcm/src/v3/multiasset.rs | 404 +++++++++- xcm/src/v3/multilocation.rs | 727 +++++++++++++++++ xcm/src/v3/traits.rs | 217 ++++-- xcm/xcm-builder/Cargo.toml | 3 + xcm/xcm-builder/src/barriers.rs | 149 +++- .../src/bridging_tests/local_para_para.rs | 110 +++ .../src/bridging_tests/local_relay_relay.rs | 66 ++ xcm/xcm-builder/src/bridging_tests/mod.rs | 181 +++++ .../bridging_tests/paid_remote_relay_relay.rs | 123 +++ .../src/bridging_tests/remote_para_para.rs | 120 +++ .../remote_para_para_via_relay.rs | 102 +++ .../src/bridging_tests/remote_relay_relay.rs | 94 +++ xcm/xcm-builder/src/lib.rs | 10 +- xcm/xcm-builder/src/location_conversion.rs | 71 +- xcm/xcm-builder/src/mock.rs | 130 +++- xcm/xcm-builder/src/origin_conversion.rs | 12 +- xcm/xcm-builder/src/test_utils.rs | 2 +- xcm/xcm-builder/src/tests.rs | 237 ++++-- xcm/xcm-builder/src/universal_exports.rs | 390 ++++++++++ xcm/xcm-builder/tests/mock/mod.rs | 21 +- xcm/xcm-builder/tests/scenarios.rs | 18 +- xcm/xcm-executor/src/assets.rs | 8 +- xcm/xcm-executor/src/config.rs | 21 +- xcm/xcm-executor/src/lib.rs | 170 ++-- xcm/xcm-executor/src/traits/conversion.rs | 28 +- xcm/xcm-executor/src/traits/export.rs | 117 +++ xcm/xcm-executor/src/traits/fee_manager.rs | 52 ++ xcm/xcm-executor/src/traits/mod.rs | 8 +- xcm/xcm-executor/src/traits/should_execute.rs | 14 +- xcm/xcm-simulator/example/src/lib.rs | 4 +- xcm/xcm-simulator/example/src/parachain.rs | 7 +- xcm/xcm-simulator/example/src/relay_chain.rs | 21 +- xcm/xcm-simulator/fuzzer/src/parachain.rs | 5 +- xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 23 +- xcm/xcm-simulator/src/lib.rs | 64 +- 79 files changed, 5242 insertions(+), 3475 deletions(-) delete mode 100644 xcm/procedural/src/v0.rs delete mode 100644 xcm/procedural/src/v0/multilocation.rs create mode 100644 xcm/procedural/src/v3.rs delete mode 100644 xcm/src/v0/junction.rs delete mode 100644 xcm/src/v0/mod.rs delete mode 100644 xcm/src/v0/multi_asset.rs delete mode 100644 xcm/src/v0/multi_location.rs delete mode 100644 xcm/src/v0/order.rs delete mode 100644 xcm/src/v0/traits.rs create mode 100644 xcm/src/v3/junction.rs create mode 100644 xcm/src/v3/junctions.rs create mode 100644 xcm/src/v3/multilocation.rs create mode 100644 xcm/xcm-builder/src/bridging_tests/local_para_para.rs create mode 100644 xcm/xcm-builder/src/bridging_tests/local_relay_relay.rs create mode 100644 xcm/xcm-builder/src/bridging_tests/mod.rs create mode 100644 xcm/xcm-builder/src/bridging_tests/paid_remote_relay_relay.rs create mode 100644 xcm/xcm-builder/src/bridging_tests/remote_para_para.rs create mode 100644 xcm/xcm-builder/src/bridging_tests/remote_para_para_via_relay.rs create mode 100644 xcm/xcm-builder/src/bridging_tests/remote_relay_relay.rs create mode 100644 xcm/xcm-builder/src/universal_exports.rs create mode 100644 xcm/xcm-executor/src/traits/export.rs create mode 100644 xcm/xcm-executor/src/traits/fee_manager.rs diff --git a/Cargo.lock b/Cargo.lock index bd1a7a08340b..7420a29f3a74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12051,8 +12051,10 @@ dependencies = [ name = "xcm-builder" version = "0.9.17" dependencies = [ + "assert_matches", "frame-support", "frame-system", + "impl-trait-for-tuples", "log", "pallet-balances", "pallet-transaction-payment", diff --git a/bridges/primitives/messages/Cargo.toml b/bridges/primitives/messages/Cargo.toml index 31ec46222cd8..c80a4b7776f0 100644 --- a/bridges/primitives/messages/Cargo.toml +++ b/bridges/primitives/messages/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] bitvec = { version = "0.20", default-features = false, features = ["alloc"] } codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive", "bit-vec"] } -impl-trait-for-tuples = "0.2" +impl-trait-for-tuples = "0.2.2" scale-info = { version = "1.0", default-features = false, features = ["bit-vec", "derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index 2d75edfd4571..f93fa4944dfa 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -17,9 +17,14 @@ //! XCM sender for relay chain. use parity_scale_codec::Encode; -use runtime_parachains::{configuration, dmp}; -use sp_std::marker::PhantomData; -use xcm::latest::prelude::*; +use primitives::v1::Id as ParaId; +use runtime_parachains::{ + configuration::{self, HostConfiguration}, + dmp, +}; +use sp_std::{marker::PhantomData, prelude::*}; +use xcm::prelude::*; +use SendError::*; /// XCM sender for relay chain. It only sends downward message. pub struct ChildParachainRouter(PhantomData<(T, W)>); @@ -27,23 +32,35 @@ pub struct ChildParachainRouter(PhantomData<(T, W)>); impl SendXcm for ChildParachainRouter { - fn send_xcm(dest: impl Into, msg: Xcm<()>) -> SendResult { - let dest = dest.into(); - match dest { - MultiLocation { parents: 0, interior: X1(Parachain(id)) } => { - // Downward message passing. - let versioned_xcm = - W::wrap_version(&dest, msg).map_err(|()| SendError::DestinationUnsupported)?; - let config = >::config(); - >::queue_downward_message( - &config, - id.into(), - versioned_xcm.encode(), - ) - .map_err(Into::::into)?; - Ok(()) - }, - dest => Err(SendError::CannotReachDestination(dest, msg)), - } + type Ticket = (HostConfiguration, ParaId, Vec); + + fn validate( + dest: &mut Option, + msg: &mut Option>, + ) -> SendResult<(HostConfiguration, ParaId, Vec)> { + let d = dest.take().ok_or(MissingArgument)?; + let id = if let MultiLocation { parents: 0, interior: X1(Parachain(id)) } = &d { + *id + } else { + *dest = Some(d); + return Err(NotApplicable) + }; + + // Downward message passing. + let xcm = msg.take().ok_or(MissingArgument)?; + let config = >::config(); + let para = id.into(); + let blob = W::wrap_version(&d, xcm).map_err(|()| DestinationUnsupported)?.encode(); + >::can_queue_downward_message(&config, ¶, &blob) + .map_err(Into::::into)?; + + Ok(((config, para, blob), MultiAssets::new())) + } + + fn deliver( + (config, para, blob): (HostConfiguration, ParaId, Vec), + ) -> Result<(), SendError> { + >::queue_downward_message(&config, para, blob) + .map_err(|_| SendError::Transport(&"Error placing into DMP queue")) } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 1c16693ce18d..b7bd88054501 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -35,17 +35,19 @@ use xcm_builder::{ LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; +use xcm_executor::XcmExecutor; parameter_types! { /// The location of the KSM token, from the context of this chain. Since this token is native to this /// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to /// the context". - pub const KsmLocation: MultiLocation = Here.into(); + pub const TokenLocation: MultiLocation = Here.into_location(); /// The Kusama network ID. This is named. - pub const KusamaNetwork: NetworkId = NetworkId::Kusama; - /// Our XCM location ancestry - i.e. what, if anything, `Parent` means evaluated in our context. Since - /// Kusama is a top-level relay-chain, there is no ancestry. - pub const Ancestry: MultiLocation = Here.into(); + pub const ThisNetwork: NetworkId = Kusama; + /// Our XCM location ancestry - i.e. our location within the Consensus Universe. + /// + /// Since Kusama is a top-level relay-chain with its own consensus, it's just our network ID. + pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); /// The check account, which holds any native assets that have been teleported out and not back in (yet). pub CheckAccount: AccountId = XcmPallet::check_account(); } @@ -56,18 +58,18 @@ pub type SovereignAccountOf = ( // We can convert a child parachain using the standard `AccountId` conversion. ChildParachainConvertsVia, // We can directly alias an `AccountId32` into a local account. - AccountId32Aliases, + AccountId32Aliases, ); /// Our asset transactor. This is what allows us to interest with the runtime facilities from the point of /// view of XCM-only concepts like `MultiLocation` and `MultiAsset`. /// -/// Ours is only aware of the Balances pallet, which is mapped to `KsmLocation`. +/// Ours is only aware of the Balances pallet, which is mapped to `TokenLocation`. pub type LocalAssetTransactor = XcmCurrencyAdapter< // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + IsConcrete, // We can convert the MultiLocations with our converter above: SovereignAccountOf, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -76,14 +78,14 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< CheckAccount, >; -/// The means that we convert an the XCM message origin location into a local dispatch origin. +/// The means that we convert the XCM message origin location into a local dispatch origin. type LocalOriginConverter = ( // A `Signed` origin of the sovereign account that the original location controls. SovereignSignedViaLocation, // A child parachain, natively expressed, has the `Parachain` origin. ChildParachainAsNative, // The AccountId32 location type can be expressed natively as a `Signed` origin. - SignedAccountId32AsNative, + SignedAccountId32AsNative, // A system child parachain, expressed as a Superuser, converts to the `Root` origin. ChildSystemParachainAsSuperuser, ); @@ -104,13 +106,13 @@ pub type XcmRouter = ( ); parameter_types! { - pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) }); - pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1000).into()); - pub const KusamaForEncointer: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1001).into()); + pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); + pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Parachain(1000).into_location()); + pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Parachain(1001).into_location()); pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = - (xcm_builder::Case, xcm_builder::Case); + (xcm_builder::Case, xcm_builder::Case); match_type! { pub type OnlyParachains: impl Contains = { @@ -140,17 +142,22 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; // The weight trader piggybacks on the existing transaction-fee conversion logic. - type Trader = UsingComponents>; + type Trader = + UsingComponents>; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + // No bridges yet... + type MessageExporter = (); + type UniversalAliases = Nothing; } parameter_types! { @@ -168,8 +175,9 @@ pub type LocalOriginToLocation = ( CouncilBodyId, >, // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); + impl pallet_xcm::Config for Runtime { type Event = Event; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; @@ -178,11 +186,11 @@ impl pallet_xcm::Config for Runtime { type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; // ...but they must match our filter, which rejects all. type XcmExecuteFilter = Nothing; - type XcmExecutor = xcm_executor::XcmExecutor; + type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/parachains/src/dmp.rs b/runtime/parachains/src/dmp.rs index 4a11796af0ce..90b753e04c83 100644 --- a/runtime/parachains/src/dmp.rs +++ b/runtime/parachains/src/dmp.rs @@ -137,6 +137,21 @@ impl Pallet { ::DownwardMessageQueueHeads::remove(outgoing_para); } + /// Determine whether enqueuing a downward message to a specific recipient para would result + /// in an error. If this returns `Ok(())` the caller can be certain that a call to + /// `queue_downward_message` with the same parameters will be successful. + pub fn can_queue_downward_message( + config: &HostConfiguration, + _para: &ParaId, + msg: &DownwardMessage, + ) -> Result<(), QueueDownwardMessageError> { + let serialized_len = msg.len() as u32; + if serialized_len > config.max_downward_message_size { + return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) + } + Ok(()) + } + /// Enqueue a downward message to a specific recipient para. /// /// When encoded, the message should not exceed the `config.max_downward_message_size`. diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 9afd41c52ead..772c949fcea5 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -34,17 +34,17 @@ use xcm_builder::{ IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; +use xcm_executor::XcmExecutor; parameter_types! { /// The location of the DOT token, from the context of this chain. Since this token is native to this /// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to /// the context". - pub const DotLocation: MultiLocation = Here.into(); + pub const TokenLocation: MultiLocation = Here.into_location(); /// The Polkadot network ID. This is named. - pub const PolkadotNetwork: NetworkId = NetworkId::Polkadot; - /// Our XCM location ancestry - i.e. what, if anything, `Parent` means evaluated in our context. Since - /// Polkadot is a top-level relay-chain, there is no ancestry. - pub const Ancestry: MultiLocation = Here.into(); + pub const ThisNetwork: NetworkId = NetworkId::Polkadot; + /// Our location in the universe of consensus systems. + pub const UniversalLocation: InteriorMultiLocation = X1(GlobalConsensus(ThisNetwork::get())); /// The check account, which holds any native assets that have been teleported out and not back in (yet). pub CheckAccount: AccountId = XcmPallet::check_account(); } @@ -55,18 +55,18 @@ pub type SovereignAccountOf = ( // We can convert a child parachain using the standard `AccountId` conversion. ChildParachainConvertsVia, // We can directly alias an `AccountId32` into a local account. - AccountId32Aliases, + AccountId32Aliases, ); /// Our asset transactor. This is what allows us to interest with the runtime facilities from the point of /// view of XCM-only concepts like `MultiLocation` and `MultiAsset`. /// -/// Ours is only aware of the Balances pallet, which is mapped to `DotLocation`. +/// Ours is only aware of the Balances pallet, which is mapped to `TokenLocation`. pub type LocalAssetTransactor = XcmCurrencyAdapter< // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + IsConcrete, // We can convert the MultiLocations with our converter above: SovereignAccountOf, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -82,7 +82,7 @@ type LocalOriginConverter = ( // A child parachain, natively expressed, has the `Parachain` origin. ChildParachainAsNative, // The AccountId32 location type can be expressed natively as a `Signed` origin. - SignedAccountId32AsNative, + SignedAccountId32AsNative, ); parameter_types! { @@ -101,12 +101,12 @@ pub type XcmRouter = ( ); parameter_types! { - pub const Polkadot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(DotLocation::get()) }); - pub const PolkadotForStatemint: (MultiAssetFilter, MultiLocation) = (Polkadot::get(), Parachain(1000).into()); + pub const Dot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); + pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(1000).into_location()); pub const MaxAssetsIntoHolding: u32 = 64; } -pub type TrustedTeleporters = (xcm_builder::Case,); +pub type TrustedTeleporters = (xcm_builder::Case,); match_type! { pub type OnlyParachains: impl Contains = { @@ -134,23 +134,26 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; // The weight trader piggybacks on the existing transaction-fee conversion logic. - type Trader = UsingComponents>; + type Trader = + UsingComponents>; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + // No bridges yet... + type MessageExporter = (); + type UniversalAliases = Nothing; } parameter_types! { pub const CouncilBodyId: BodyId = BodyId::Executive; - // We are conservative with the XCM version we advertize. - pub const AdvertisedXcmVersion: u32 = 2; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location @@ -164,7 +167,7 @@ pub type LocalOriginToLocation = ( CouncilBodyId, >, // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); impl pallet_xcm::Config for Runtime { @@ -175,13 +178,13 @@ impl pallet_xcm::Config for Runtime { type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; // ...but they must match our filter, which rejects all. type XcmExecuteFilter = Nothing; - type XcmExecutor = xcm_executor::XcmExecutor; + type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = AdvertisedXcmVersion; + type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index bb0489f6656f..c7de71c778d9 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -34,22 +34,23 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents, }; +use xcm_executor::XcmExecutor; parameter_types! { - pub const RocLocation: MultiLocation = Here.into(); - pub const RococoNetwork: NetworkId = NetworkId::Polkadot; - pub const Ancestry: MultiLocation = Here.into(); + pub const TokenLocation: MultiLocation = Here.into_location(); + pub const ThisNetwork: NetworkId = NetworkId::Rococo; + pub Ancestry: InteriorMultiLocation = ThisNetwork::get().into(); pub CheckAccount: AccountId = XcmPallet::check_account(); } pub type SovereignAccountOf = - (ChildParachainConvertsVia, AccountId32Aliases); + (ChildParachainConvertsVia, AccountId32Aliases); pub type LocalAssetTransactor = XcmCurrencyAdapter< // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + IsConcrete, // We can convert the MultiLocations with our converter above: SovereignAccountOf, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -61,7 +62,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< type LocalOriginConverter = ( SovereignSignedViaLocation, ChildParachainAsNative, - SignedAccountId32AsNative, + SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, ); @@ -77,23 +78,23 @@ pub type XcmRouter = ( ); parameter_types! { - pub const Rococo: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) }); - pub const RococoForTick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(100).into()); - pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(110).into()); - pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(120).into()); - pub const RococoForStatemine: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1000).into()); - pub const RococoForCanvas: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1002).into()); - pub const RococoForEncointer: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1003).into()); + pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); + pub const RocForTick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(100).into_location()); + pub const RocForTrick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(110).into_location()); + pub const RocForTrack: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(120).into_location()); + pub const RocForRockmine: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(1000).into_location()); + pub const RocForCanvas: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(1002).into_location()); + pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(1003).into_location()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = ( - xcm_builder::Case, - xcm_builder::Case, - xcm_builder::Case, - xcm_builder::Case, - xcm_builder::Case, - xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, ); parameter_types! { @@ -130,13 +131,17 @@ impl xcm_executor::Config for XcmConfig { type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = UsingComponents>; + type Trader = + UsingComponents>; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; } parameter_types! { @@ -150,7 +155,7 @@ pub type LocalOriginToLocation = ( // `Unit` body. BackingToPlurality, CollectiveBodyId>, // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); impl pallet_xcm::Config for Runtime { @@ -161,7 +166,7 @@ impl pallet_xcm::Config for Runtime { type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; // ...but they must match our filter, which right now rejects everything. type XcmExecuteFilter = Nothing; - type XcmExecutor = xcm_executor::XcmExecutor; + type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 52e7d2722067..7227b0758c89 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -520,7 +520,7 @@ impl parachains_ump::Config for Runtime { parameter_types! { pub const BaseXcmWeight: frame_support::weights::Weight = 1_000; - pub const AnyNetwork: xcm::latest::NetworkId = xcm::latest::NetworkId::Any; + pub const AnyNetwork: Option = None; pub const MaxInstructions: u32 = 100; } @@ -607,7 +607,7 @@ pub mod pallet_test_notifier { .using_encoded(|mut d| <[u8; 32]>::decode(&mut d)) .map_err(|_| Error::::BadAccountFormat)?; let qid = pallet_xcm::Pallet::::new_query( - Junction::AccountId32 { network: Any, id }.into(), + Junction::AccountId32 { network: None, id }, 100u32.into(), Here, ); @@ -624,7 +624,7 @@ pub mod pallet_test_notifier { let call = Call::::notification_received { query_id: 0, response: Default::default() }; let qid = pallet_xcm::Pallet::::new_notify_query( - Junction::AccountId32 { network: Any, id }.into(), + Junction::AccountId32 { network: None, id }, ::Call::from(call), 100u32.into(), Here, diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 77dded583479..a68f3f9a5159 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -14,11 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use frame_support::{parameter_types, traits::Everything, weights::Weight}; +use frame_support::{ + parameter_types, + traits::{Everything, Nothing}, + weights::Weight, +}; use xcm::latest::prelude::*; use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32}; use xcm_executor::{ - traits::{InvertLocation, TransactAsset, WeightTrader}, + traits::{TransactAsset, UniversalLocation, WeightTrader}, Assets, }; @@ -37,7 +41,11 @@ pub type LocalOriginToLocation = ( pub struct DoNothingRouter; impl SendXcm for DoNothingRouter { - fn send_xcm(_dest: impl Into, _msg: Xcm<()>) -> SendResult { + type Ticket = (); + fn validate(_dest: &mut Option, _msg: &mut Option>) -> SendResult<()> { + Ok(((), MultiAssets::new())) + } + fn deliver(_: ()) -> Result<(), SendError> { Ok(()) } } @@ -68,12 +76,13 @@ impl WeightTrader for DummyWeightTrader { } pub struct InvertNothing; -impl InvertLocation for InvertNothing { +impl UniversalLocation for InvertNothing { fn invert_location(_: &MultiLocation) -> sp_std::result::Result { Ok(Here.into()) } - fn ancestry() -> MultiLocation { - Here.into() + + fn universal_location() -> InteriorMultiLocation { + Here } } @@ -95,4 +104,7 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = super::Xcm; type PalletInstancesInfo = (); type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index e4668d47166e..f6d3c3dc27fe 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1522,7 +1522,7 @@ sp_api::impl_runtime_apis! { AssetId::*, Fungibility::*, Junctions::*, MultiAsset, MultiAssets, MultiLocation, Response, }; - use xcm_config::{Westmint, WndLocation}; + use xcm_config::{Westmint, TokenLocation}; impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = xcm_config::XcmConfig; @@ -1533,7 +1533,7 @@ sp_api::impl_runtime_apis! { fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Westend only knows about WND. vec![MultiAsset{ - id: Concrete(WndLocation::get()), + id: Concrete(TokenLocation::get()), fun: Fungible(1_000_000 * UNITS), }].into() } @@ -1542,7 +1542,7 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( Westmint::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); } @@ -1554,7 +1554,7 @@ sp_api::impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { - id: Concrete(WndLocation::get()), + id: Concrete(TokenLocation::get()), fun: Fungible(1 * UNITS), } } @@ -1577,7 +1577,7 @@ sp_api::impl_runtime_apis! { fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { let origin = Westmint::get(); - let assets: MultiAssets = (Concrete(WndLocation::get()), 1_000 * UNITS).into(); + let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } diff --git a/runtime/westend/src/tests.rs b/runtime/westend/src/tests.rs index f0ab4f44e6d8..758d64851ecf 100644 --- a/runtime/westend/src/tests.rs +++ b/runtime/westend/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for the Westend Runtime Configuration use crate::*; -use xcm::latest::{AssetId::*, Fungibility::*, MultiLocation}; +use xcm::latest::prelude::*; #[test] fn remove_keys_weight_is_sensible() { @@ -58,9 +58,9 @@ fn sanity_check_teleport_assets_weight() { // so this test will certainly ensure that this problem does not occur. use frame_support::dispatch::GetDispatchInfo; let weight = pallet_xcm::Call::::teleport_assets { - dest: Box::new(xcm::VersionedMultiLocation::V1(MultiLocation::here())), - beneficiary: Box::new(xcm::VersionedMultiLocation::V1(MultiLocation::here())), - assets: Box::new((Concrete(MultiLocation::here()), Fungible(200_000)).into()), + dest: Box::new(Here.into()), + beneficiary: Box::new(Here.into()), + assets: Box::new((Here, 200_000).into()), fee_asset_item: 0, } .get_dispatch_info() diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index e801c79e5e96..6be429bfd7cf 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -217,4 +217,10 @@ impl XcmWeightInfo for WestendXcmWeight { fn clear_transact_status() -> Weight { XcmGeneric::::clear_transact_status() } + fn universal_origin(_: &Junction) -> Weight { + 10_000_000_000 + } + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { + 10_000_000_000 + } } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index b57e54593e86..2bb915f90100 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -34,22 +34,23 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; +use xcm_executor::XcmExecutor; parameter_types! { - pub const WndLocation: MultiLocation = Here.into(); - pub const Ancestry: MultiLocation = Here.into(); - pub WestendNetwork: NetworkId = NetworkId::Named(b"Westend".to_vec()); + pub const TokenLocation: MultiLocation = Here.into_location(); + pub const ThisNetwork: NetworkId = Westend; + pub Ancestry: InteriorMultiLocation = ThisNetwork::get().into(); pub CheckAccount: AccountId = XcmPallet::check_account(); } pub type LocationConverter = - (ChildParachainConvertsVia, AccountId32Aliases); + (ChildParachainConvertsVia, AccountId32Aliases); pub type LocalAssetTransactor = XcmCurrencyAdapter< // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + IsConcrete, // We can convert the MultiLocations with our converter above: LocationConverter, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -61,7 +62,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< type LocalOriginConverter = ( SovereignSignedViaLocation, ChildParachainAsNative, - SignedAccountId32AsNative, + SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, ); @@ -73,17 +74,16 @@ pub type XcmRouter = ( ); parameter_types! { - pub const Westmint: MultiLocation = Parachain(1000).into(); - pub const Encointer: MultiLocation = Parachain(1001).into(); - pub const WestendForWestmint: (MultiAssetFilter, MultiLocation) = - (Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Westmint::get()); - pub const WestendForEncointer: (MultiAssetFilter, MultiLocation) = - (Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Encointer::get()); + pub const Westmint: MultiLocation = Parachain(1000).into_location(); + pub const Encointer: MultiLocation = Parachain(1001).into_location(); + pub const Wnd: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); + pub const WndForWestmint: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Westmint::get()); + pub const WndForEncointer: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Encointer::get()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = - (xcm_builder::Case, xcm_builder::Case); + (xcm_builder::Case, xcm_builder::Case); /// The barriers one of which must be passed for an XCM message to be executed. pub type Barrier = ( @@ -110,20 +110,24 @@ impl xcm_executor::Config for XcmConfig { type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = WeightInfoBounds, Call, MaxInstructions>; - type Trader = UsingComponents>; + type Trader = + UsingComponents>; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location /// of this chain. pub type LocalOriginToLocation = ( // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); impl pallet_xcm::Config for Runtime { @@ -134,7 +138,7 @@ impl pallet_xcm::Config for Runtime { type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; // ...but they must match our filter, which rejects everything. type XcmExecuteFilter = Nothing; - type XcmExecutor = xcm_executor::XcmExecutor; + type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = WeightInfoBounds, Call, MaxInstructions>; diff --git a/scripts/gitlab/lingua.dic b/scripts/gitlab/lingua.dic index b4621cec88a3..031018e952a6 100644 --- a/scripts/gitlab/lingua.dic +++ b/scripts/gitlab/lingua.dic @@ -160,6 +160,7 @@ MQC/SM msg multisig/S multivalidator/SM +mutators mutex natively NFA @@ -248,6 +249,7 @@ SS58 SSL startup/MS stateful +Statemine str struct/MS subcommand/SM @@ -283,6 +285,7 @@ UDP UI unassign unconcluded +unexpectable unfinalize/B unfinalized union/MSG diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 6418e82f148c..f139e3c0f779 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -18,7 +18,10 @@ use crate::{fungible as xcm_balances_benchmark, mock::*}; use frame_benchmarking::BenchmarkError; -use frame_support::{parameter_types, traits::Everything}; +use frame_support::{ + parameter_types, + traits::{Everything, Nothing}, +}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -145,6 +148,9 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = (); type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; } impl crate::Config for Test { @@ -152,7 +158,7 @@ impl crate::Config for Test { type AccountIdConverter = AccountIdConverter; fn valid_destination() -> Result { let valid_destination: MultiLocation = - X1(AccountId32 { network: NetworkId::Any, id: [0u8; 32] }).into(); + X1(AccountId32 { network: None, id: [0u8; 32] }).into(); Ok(valid_destination) } @@ -168,13 +174,13 @@ pub type TrustedTeleporters = (xcm_builder::Case,); parameter_types! { pub const CheckedAccount: Option = Some(100); - pub const ChildTeleporter: MultiLocation = Parachain(1000).into(); + pub const ChildTeleporter: MultiLocation = Parachain(1000).into_location(); pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( ChildTeleporter::get(), - MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) }, + MultiAsset { id: Concrete(Here.into_location()), fun: Fungible(100) }, )); pub const TeleConcreteFung: (MultiAssetFilter, MultiLocation) = - (Wild(AllOf { fun: WildFungible, id: Concrete(Here.into()) }), ChildTeleporter::get()); + (Wild(AllOf { fun: WildFungible, id: Concrete(Here.into_location()) }), ChildTeleporter::get()); } impl xcm_balances_benchmark::Config for Test { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 07283deee74c..12b40dce0a29 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -20,7 +20,7 @@ use crate::{generic, mock::*, *}; use codec::Decode; use frame_support::{ parameter_types, - traits::{Everything, OriginTrait}, + traits::{Everything, Nothing, OriginTrait}, }; use sp_core::H256; use sp_runtime::{ @@ -116,6 +116,10 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = TestSubscriptionService; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + // No bridges yet... + type MessageExporter = (); + type UniversalAliases = Nothing; } impl crate::Config for Test { @@ -123,7 +127,7 @@ impl crate::Config for Test { type AccountIdConverter = AccountIdConverter; fn valid_destination() -> Result { let valid_destination: MultiLocation = - Junction::AccountId32 { network: NetworkId::Any, id: [0u8; 32] }.into(); + Junction::AccountId32 { network: None, id: [0u8; 32] }.into(); Ok(valid_destination) } diff --git a/xcm/pallet-xcm-benchmarks/src/lib.rs b/xcm/pallet-xcm-benchmarks/src/lib.rs index a7a4e715db39..8db2496e0b7d 100644 --- a/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -99,7 +99,7 @@ fn account_id_junction(index: u32) -> Junction { encoded.resize(32, 0u8); let mut id = [0u8; 32]; id.copy_from_slice(&encoded); - Junction::AccountId32 { network: NetworkId::Any, id } + Junction::AccountId32 { network: None, id } } pub fn account_and_location(index: u32) -> (T::AccountId, MultiLocation) { diff --git a/xcm/pallet-xcm-benchmarks/src/mock.rs b/xcm/pallet-xcm-benchmarks/src/mock.rs index 6390d251010e..85bbea99d775 100644 --- a/xcm/pallet-xcm-benchmarks/src/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/mock.rs @@ -21,7 +21,11 @@ use xcm_executor::traits::FilterAssetLocation; // An xcm sender/receiver akin to > /dev/null pub struct DevNull; impl xcm::opaque::latest::SendXcm for DevNull { - fn send_xcm(_: impl Into, _: Xcm<()>) -> SendResult { + type Ticket = (); + fn validate(_: &mut Option, _: &mut Option>) -> SendResult<()> { + Ok(((), MultiAssets::new())) + } + fn deliver(_: ()) -> Result<(), SendError> { Ok(()) } } @@ -57,7 +61,7 @@ impl xcm_executor::traits::Convert for AccountIdConverter { } parameter_types! { - pub Ancestry: MultiLocation = Junction::Parachain(101).into(); + pub Ancestry: InteriorMultiLocation = Junction::Parachain(101).into(); pub UnitWeightCost: Weight = 10; pub WeightPrice: (AssetId, u128) = (Concrete(Here.into()), 1_000_000); } diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index fcb79e90c6e1..171320203e27 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -57,7 +57,7 @@ pub mod pallet { use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash}; use xcm_executor::{ traits::{ - ClaimAssets, DropAssets, InvertLocation, OnResponse, VersionChangeNotifier, + ClaimAssets, DropAssets, OnResponse, UniversalLocation, VersionChangeNotifier, WeightBounds, }, Assets, @@ -108,7 +108,7 @@ pub mod pallet { type Weigher: WeightBounds<::Call>; /// Means of inverting a location. - type LocationInverter: InvertLocation; + type LocationInverter: UniversalLocation; /// The outer `Origin` type. type Origin: From + From<::Origin>; @@ -557,7 +557,7 @@ pub mod pallet { let message: Xcm<()> = (*message).try_into().map_err(|()| Error::::BadVersion)?; Self::send_xcm(interior, dest.clone(), message.clone()).map_err(|e| match e { - SendError::CannotReachDestination(..) => Error::::Unreachable, + SendError::NotApplicable => Error::::Unreachable, _ => Error::::SendFailure, })?; Self::deposit_event(Event::Sent(origin_location, dest, message)); @@ -881,7 +881,7 @@ pub mod pallet { let value = (origin_location, assets.drain()); ensure!(T::XcmReserveTransferFilter::contains(&value), Error::::Filtered); let (origin_location, assets) = value; - let ancestry = T::LocationInverter::ancestry(); + let ancestry = T::LocationInverter::universal_location().into(); let fees = assets .get(fee_asset_item as usize) .ok_or(Error::::Empty)? @@ -938,7 +938,7 @@ pub mod pallet { let value = (origin_location, assets.drain()); ensure!(T::XcmTeleportFilter::contains(&value), Error::::Filtered); let (origin_location, assets) = value; - let ancestry = T::LocationInverter::ancestry(); + let ancestry = T::LocationInverter::universal_location().into(); let fees = assets .get(fee_asset_item as usize) .ok_or(Error::::Empty)? @@ -1053,8 +1053,9 @@ pub mod pallet { let response = Response::Version(xcm_version); let message = Xcm(vec![QueryResponse { query_id, response, max_weight, querier: None }]); - let event = match T::XcmRouter::send_xcm(new_key.clone(), message) { - Ok(()) => { + let event = match send_xcm::(new_key.clone(), message) { + Ok(_cost) => { + // TODO: consider charging for cost. let value = (query_id, max_weight, xcm_version); VersionNotifyTargets::::insert(XCM_VERSION, key, value); Event::VersionChangeNotified(new_key, xcm_version) @@ -1104,8 +1105,9 @@ pub mod pallet { max_weight, querier: None, }]); - let event = match T::XcmRouter::send_xcm(new_key.clone(), message) { - Ok(()) => { + let event = match send_xcm::(new_key.clone(), message) { + Ok(_cost) => { + // TODO: consider accounting for cost. VersionNotifyTargets::::insert( XCM_VERSION, versioned_key, @@ -1140,7 +1142,7 @@ pub mod pallet { }); // TODO #3735: Correct weight. let instruction = SubscribeVersion { query_id, max_response_weight: 0 }; - T::XcmRouter::send_xcm(dest, Xcm(vec![instruction]))?; + send_xcm::(dest, Xcm(vec![instruction]))?; VersionNotifiers::::insert(XCM_VERSION, &versioned_dest, query_id); let query_status = QueryStatus::VersionNotifier { origin: versioned_dest, is_active: false }; @@ -1154,25 +1156,26 @@ pub mod pallet { let versioned_dest = LatestVersionedMultiLocation(&dest); let query_id = VersionNotifiers::::take(XCM_VERSION, versioned_dest) .ok_or(XcmError::InvalidLocation)?; - T::XcmRouter::send_xcm(dest.clone(), Xcm(vec![UnsubscribeVersion]))?; + send_xcm::(dest.clone(), Xcm(vec![UnsubscribeVersion]))?; Queries::::remove(query_id); Ok(()) } /// Relay an XCM `message` from a given `interior` location in this context to a given `dest` - /// location. A null `dest` is not handled. + /// location. A `dest` of `Here` is not handled. The overall price of the delivery is + /// returned. pub fn send_xcm( interior: impl Into, dest: impl Into, mut message: Xcm<()>, - ) -> Result<(), SendError> { + ) -> Result { let interior = interior.into(); let dest = dest.into(); if interior != Junctions::Here { message.0.insert(0, DescendOrigin(interior)) }; log::trace!(target: "xcm::send_xcm", "dest: {:?}, message: {:?}", &dest, &message); - T::XcmRouter::send_xcm(dest, message) + send_xcm::(dest, message) } pub fn check_account() -> T::AccountId { @@ -1369,7 +1372,7 @@ pub mod pallet { let xcm_version = T::AdvertisedXcmVersion::get(); let response = Response::Version(xcm_version); let instruction = QueryResponse { query_id, response, max_weight, querier: None }; - T::XcmRouter::send_xcm(dest.clone(), Xcm(vec![instruction]))?; + send_xcm::(dest.clone(), Xcm(vec![instruction]))?; let value = (query_id, max_weight, xcm_version); VersionNotifyTargets::::insert(XCM_VERSION, versioned_dest, value); diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 584dc651a906..7d91f50380b2 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -14,7 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use frame_support::{construct_runtime, parameter_types, traits::Everything, weights::Weight}; +use frame_support::{ + construct_runtime, parameter_types, + traits::{Everything, Nothing}, + weights::Weight, +}; use polkadot_parachain::primitives::Id as ParaId; use polkadot_runtime_parachains::origin; use sp_core::H256; @@ -80,7 +84,7 @@ pub mod pallet_test_notifier { .using_encoded(|mut d| <[u8; 32]>::decode(&mut d)) .map_err(|_| Error::::BadAccountFormat)?; let qid = crate::Pallet::::new_query( - Junction::AccountId32 { network: Any, id }.into(), + Junction::AccountId32 { network: None, id }, 100u32.into(), querier, ); @@ -100,7 +104,7 @@ pub mod pallet_test_notifier { let call = Call::::notification_received { query_id: 0, response: Default::default() }; let qid = crate::Pallet::::new_notify_query( - Junction::AccountId32 { network: Any, id }.into(), + Junction::AccountId32 { network: None, id }, ::Call::from(call), 100u32.into(), querier, @@ -152,23 +156,38 @@ pub(crate) fn take_sent_xcm() -> Vec<(MultiLocation, Xcm<()>)> { /// Sender that never returns error, always sends pub struct TestSendXcm; impl SendXcm for TestSendXcm { - fn send_xcm(dest: impl Into, msg: Xcm<()>) -> SendResult { - SENT_XCM.with(|q| q.borrow_mut().push((dest.into(), msg))); + type Ticket = (MultiLocation, Xcm<()>); + fn validate( + dest: &mut Option, + msg: &mut Option>, + ) -> SendResult<(MultiLocation, Xcm<()>)> { + let pair = (dest.take().unwrap(), msg.take().unwrap()); + Ok((pair, MultiAssets::new())) + } + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { + SENT_XCM.with(|q| q.borrow_mut().push(pair)); Ok(()) } } /// Sender that returns error if `X8` junction and stops routing pub struct TestSendXcmErrX8; impl SendXcm for TestSendXcmErrX8 { - fn send_xcm(dest: impl Into, msg: Xcm<()>) -> SendResult { - let dest = dest.into(); + type Ticket = (MultiLocation, Xcm<()>); + fn validate( + dest: &mut Option, + msg: &mut Option>, + ) -> SendResult<(MultiLocation, Xcm<()>)> { + let (dest, msg) = (dest.take().unwrap(), msg.take().unwrap()); if dest.len() == 8 { Err(SendError::Transport("Destination location full")) } else { - SENT_XCM.with(|q| q.borrow_mut().push((dest, msg))); - Ok(()) + Ok(((dest, msg), MultiAssets::new())) } } + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { + SENT_XCM.with(|q| q.borrow_mut().push(pair)); + Ok(()) + } } parameter_types! { @@ -221,9 +240,9 @@ impl pallet_balances::Config for Test { } parameter_types! { - pub const RelayLocation: MultiLocation = Here.into(); - pub const AnyNetwork: NetworkId = NetworkId::Any; - pub Ancestry: MultiLocation = Here.into(); + pub const RelayLocation: MultiLocation = Here.into_location(); + pub const AnyNetwork: Option = None; + pub Ancestry: InteriorMultiLocation = Here; pub UnitWeightCost: Weight = 1_000; } @@ -273,12 +292,15 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; } pub type LocalOriginToLocation = SignedToAccountId32; parameter_types! { - pub static AdvertisedXcmVersion: pallet_xcm::XcmVersion = 2; + pub static AdvertisedXcmVersion: pallet_xcm::XcmVersion = 3; } impl pallet_xcm::Config for Test { diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index c346026d17cf..5739f57f0a97 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -39,7 +39,7 @@ const SEND_AMOUNT: u128 = 10; fn report_outcome_notify_works() { let balances = vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; - let sender = AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(); + let sender: MultiLocation = AccountId32 { network: None, id: ALICE.into() }.into(); let mut message = Xcm(vec![TransferAsset { assets: (Here, SEND_AMOUNT).into(), beneficiary: sender.clone(), @@ -50,8 +50,13 @@ fn report_outcome_notify_works() { }; let notify = Call::TestNotifier(call); new_test_ext_with_balances(balances).execute_with(|| { - XcmPallet::report_outcome_notify(&mut message, Parachain(PARA_ID).into(), notify, 100) - .unwrap(); + XcmPallet::report_outcome_notify( + &mut message, + Parachain(PARA_ID).into_location(), + notify, + 100, + ) + .unwrap(); assert_eq!( message, Xcm(vec![ @@ -73,7 +78,7 @@ fn report_outcome_notify_works() { assert_eq!(crate::Queries::::iter().collect::>(), vec![(0, status)]); let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID).into(), + Parachain(PARA_ID), Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), @@ -102,13 +107,13 @@ fn report_outcome_notify_works() { fn report_outcome_works() { let balances = vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; - let sender = AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(); + let sender: MultiLocation = AccountId32 { network: None, id: ALICE.into() }.into(); let mut message = Xcm(vec![TransferAsset { assets: (Here, SEND_AMOUNT).into(), beneficiary: sender.clone(), }]); new_test_ext_with_balances(balances).execute_with(|| { - XcmPallet::report_outcome(&mut message, Parachain(PARA_ID).into(), 100).unwrap(); + XcmPallet::report_outcome(&mut message, Parachain(PARA_ID).into_location(), 100).unwrap(); assert_eq!( message, Xcm(vec![ @@ -130,7 +135,7 @@ fn report_outcome_works() { assert_eq!(crate::Queries::::iter().collect::>(), vec![(0, status)]); let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID).into(), + Parachain(PARA_ID), Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), @@ -156,16 +161,12 @@ fn custom_querier_works() { vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { let querier: MultiLocation = - (Parent, AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }).into(); + (Parent, AccountId32 { network: None, id: ALICE.into() }).into(); let r = TestNotifier::prepare_new_query(Origin::signed(ALICE), querier.clone()); assert_eq!(r, Ok(())); let status = QueryStatus::Pending { - responder: MultiLocation::from(AccountId32 { - network: AnyNetwork::get(), - id: ALICE.into(), - }) - .into(), + responder: MultiLocation::from(AccountId32 { network: None, id: ALICE.into() }).into(), maybe_notify: None, timeout: 100, maybe_match_querier: Some(querier.clone().into()), @@ -174,7 +175,7 @@ fn custom_querier_works() { // Supplying no querier when one is expected will fail let r = XcmExecutor::::execute_xcm_in_credit( - AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + AccountId32 { network: None, id: ALICE.into() }, Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), @@ -188,7 +189,7 @@ fn custom_querier_works() { assert_eq!( last_event(), Event::XcmPallet(crate::Event::InvalidQuerier( - AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + AccountId32 { network: None, id: ALICE.into() }.into(), 0, querier.clone(), None, @@ -197,7 +198,7 @@ fn custom_querier_works() { // Supplying the wrong querier will also fail let r = XcmExecutor::::execute_xcm_in_credit( - AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + AccountId32 { network: None, id: ALICE.into() }, Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), @@ -211,7 +212,7 @@ fn custom_querier_works() { assert_eq!( last_event(), Event::XcmPallet(crate::Event::InvalidQuerier( - AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + AccountId32 { network: None, id: ALICE.into() }.into(), 0, querier.clone(), Some(MultiLocation::here()), @@ -220,7 +221,7 @@ fn custom_querier_works() { // Multiple failures should not have changed the query state let r = XcmExecutor::::execute_xcm( - AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(), + AccountId32 { network: None, id: ALICE.into() }, Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), @@ -248,8 +249,7 @@ fn send_works() { let balances = vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { - let sender: MultiLocation = - AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(); + let sender: MultiLocation = AccountId32 { network: None, id: ALICE.into() }.into(); let message = Xcm(vec![ ReserveAssetDeposited((Parent, SEND_AMOUNT).into()), ClearOrigin, @@ -286,7 +286,7 @@ fn send_fails_when_xcm_router_blocks() { vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { let sender: MultiLocation = - Junction::AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into(); + Junction::AccountId32 { network: None, id: ALICE.into() }.into(); let message = Xcm(vec![ ReserveAssetDeposited((Parent, SEND_AMOUNT).into()), buy_execution((Parent, SEND_AMOUNT)), @@ -314,7 +314,7 @@ fn teleport_assets_works() { new_test_ext_with_balances(balances).execute_with(|| { let weight = 2 * BaseXcmWeight::get(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); - let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into(); + let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::teleport_assets( Origin::signed(ALICE), Box::new(RelayLocation::get().into()), @@ -336,7 +336,7 @@ fn teleport_assets_works() { )] ); let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1); - let _check_v0_ok: xcm::v0::Xcm<()> = versioned_sent.try_into().unwrap(); + let _check_v1_ok: xcm::v1::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) @@ -355,7 +355,7 @@ fn limmited_teleport_assets_works() { new_test_ext_with_balances(balances).execute_with(|| { let weight = 2 * BaseXcmWeight::get(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); - let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into(); + let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::limited_teleport_assets( Origin::signed(ALICE), Box::new(RelayLocation::get().into()), @@ -378,7 +378,7 @@ fn limmited_teleport_assets_works() { )] ); let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1); - let _check_v0_ok: xcm::v0::Xcm<()> = versioned_sent.try_into().unwrap(); + let _check_v1_ok: xcm::v1::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) @@ -397,7 +397,7 @@ fn unlimmited_teleport_assets_works() { new_test_ext_with_balances(balances).execute_with(|| { let weight = 2 * BaseXcmWeight::get(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); - let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into(); + let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::limited_teleport_assets( Origin::signed(ALICE), Box::new(RelayLocation::get().into()), @@ -436,12 +436,11 @@ fn reserve_transfer_assets_works() { vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { let weight = BaseXcmWeight::get(); - let dest: MultiLocation = - Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into(); + let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::reserve_transfer_assets( Origin::signed(ALICE), - Box::new(Parachain(PARA_ID).into().into()), + Box::new(Parachain(PARA_ID).into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), 0, @@ -464,7 +463,7 @@ fn reserve_transfer_assets_works() { )] ); let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1); - let _check_v0_ok: xcm::v0::Xcm<()> = versioned_sent.try_into().unwrap(); + let _check_v1_ok: xcm::v1::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) @@ -482,12 +481,11 @@ fn limited_reserve_transfer_assets_works() { vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { let weight = BaseXcmWeight::get(); - let dest: MultiLocation = - Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into(); + let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::limited_reserve_transfer_assets( Origin::signed(ALICE), - Box::new(Parachain(PARA_ID).into().into()), + Box::new(Parachain(PARA_ID).into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), 0, @@ -511,7 +509,7 @@ fn limited_reserve_transfer_assets_works() { )] ); let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1); - let _check_v0_ok: xcm::v0::Xcm<()> = versioned_sent.try_into().unwrap(); + let _check_v1_ok: xcm::v1::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) @@ -529,12 +527,11 @@ fn unlimited_reserve_transfer_assets_works() { vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { let weight = BaseXcmWeight::get(); - let dest: MultiLocation = - Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into(); + let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::limited_reserve_transfer_assets( Origin::signed(ALICE), - Box::new(Parachain(PARA_ID).into().into()), + Box::new(Parachain(PARA_ID).into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), 0, @@ -574,8 +571,7 @@ fn execute_withdraw_to_deposit_works() { vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { let weight = 3 * BaseXcmWeight::get(); - let dest: MultiLocation = - Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into(); + let dest: MultiLocation = Junction::AccountId32 { network: None, id: BOB.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::execute( Origin::signed(ALICE), @@ -601,8 +597,7 @@ fn trapped_assets_can_be_claimed() { let balances = vec![(ALICE, INITIAL_BALANCE), (BOB, INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { let weight = 6 * BaseXcmWeight::get(); - let dest: MultiLocation = - Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into(); + let dest: MultiLocation = Junction::AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::execute( Origin::signed(ALICE), @@ -619,7 +614,7 @@ fn trapped_assets_can_be_claimed() { weight )); let source: MultiLocation = - Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into(); + Junction::AccountId32 { network: None, id: ALICE.into() }.into(); let trapped = AssetTraps::::iter().collect::>(); let vma = VersionedMultiAssets::from(MultiAssets::from((Here, SEND_AMOUNT))); let hash = BlakeTwo256::hash_of(&(source.clone(), vma.clone())); @@ -676,15 +671,15 @@ fn trapped_assets_can_be_claimed() { #[test] fn fake_latest_versioned_multilocation_works() { use codec::Encode; - let remote = Parachain(1000).into(); + let remote: MultiLocation = Parachain(1000).into(); let versioned_remote = LatestVersionedMultiLocation(&remote); - assert_eq!(versioned_remote.encode(), VersionedMultiLocation::from(remote.clone()).encode()); + assert_eq!(versioned_remote.encode(), remote.into_versioned().encode()); } #[test] fn basic_subscription_works() { new_test_ext_with_balances(vec![]).execute_with(|| { - let remote = Parachain(1000).into(); + let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( Origin::root(), Box::new(remote.clone().into()), @@ -722,7 +717,7 @@ fn basic_subscription_works() { ]); assert_ok!(AllowKnownQueryResponses::::should_execute( &remote, - &mut message, + message.inner_mut(), weight, &mut 0 )); @@ -732,13 +727,13 @@ fn basic_subscription_works() { #[test] fn subscriptions_increment_id() { new_test_ext_with_balances(vec![]).execute_with(|| { - let remote = Parachain(1000).into(); + let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( Origin::root(), Box::new(remote.clone().into()), )); - let remote2 = Parachain(1001).into(); + let remote2: MultiLocation = Parachain(1001).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( Origin::root(), Box::new(remote2.clone().into()), @@ -763,7 +758,7 @@ fn subscriptions_increment_id() { #[test] fn double_subscription_fails() { new_test_ext_with_balances(vec![]).execute_with(|| { - let remote = Parachain(1000).into(); + let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( Origin::root(), Box::new(remote.clone().into()), @@ -781,7 +776,7 @@ fn double_subscription_fails() { #[test] fn unsubscribe_works() { new_test_ext_with_balances(vec![]).execute_with(|| { - let remote = Parachain(1000).into(); + let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( Origin::root(), Box::new(remote.clone().into()), @@ -817,7 +812,7 @@ fn subscription_side_works() { new_test_ext_with_balances(vec![]).execute_with(|| { AdvertisedXcmVersion::set(1); - let remote = Parachain(1000).into(); + let remote: MultiLocation = Parachain(1000).into(); let weight = BaseXcmWeight::get(); let message = Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: 0 }]); let r = XcmExecutor::::execute_xcm(remote.clone(), message, weight); @@ -857,38 +852,29 @@ fn subscription_side_upgrades_work_with_notify() { new_test_ext_with_balances(vec![]).execute_with(|| { AdvertisedXcmVersion::set(1); - // An entry from a previous runtime with v0 XCM. - let v0_location = xcm::v0::MultiLocation::X1(xcm::v0::Junction::Parachain(1000)); - let v0_location = VersionedMultiLocation::from(v0_location); - VersionNotifyTargets::::insert(0, v0_location, (69, 0, 1)); - let v1_location = Parachain(1001).into().versioned(); - VersionNotifyTargets::::insert(1, v1_location, (70, 0, 1)); - let v2_location = Parachain(1002).into().versioned(); - VersionNotifyTargets::::insert(2, v2_location, (71, 0, 1)); + // An entry from a previous runtime with v1 XCM. + let v1_location = VersionedMultiLocation::V1(xcm::v1::Junction::Parachain(1001).into()); + VersionNotifyTargets::::insert(1, v1_location, (70, 0, 2)); + let v3_location = Parachain(1003).into_versioned(); + VersionNotifyTargets::::insert(3, v3_location, (72, 0, 2)); // New version. - AdvertisedXcmVersion::set(2); + AdvertisedXcmVersion::set(3); // A runtime upgrade which alters the version does send notifications. XcmPallet::on_runtime_upgrade(); XcmPallet::on_initialize(1); - let instr0 = QueryResponse { - query_id: 69, - max_weight: 0, - response: Response::Version(2), - querier: None, - }; let instr1 = QueryResponse { query_id: 70, max_weight: 0, - response: Response::Version(2), + response: Response::Version(3), querier: None, }; - let instr2 = QueryResponse { - query_id: 71, + let instr3 = QueryResponse { + query_id: 72, max_weight: 0, - response: Response::Version(2), + response: Response::Version(3), querier: None, }; let mut sent = take_sent_xcm(); @@ -899,9 +885,8 @@ fn subscription_side_upgrades_work_with_notify() { assert_eq!( sent, vec![ - (Parachain(1000).into(), Xcm(vec![instr0])), (Parachain(1001).into(), Xcm(vec![instr1])), - (Parachain(1002).into(), Xcm(vec![instr2])), + (Parachain(1003).into(), Xcm(vec![instr3])), ] ); @@ -910,9 +895,8 @@ fn subscription_side_upgrades_work_with_notify() { assert_eq!( contents, vec![ - (XCM_VERSION, Parachain(1000).into().versioned(), (69, 0, 2)), - (XCM_VERSION, Parachain(1001).into().versioned(), (70, 0, 2)), - (XCM_VERSION, Parachain(1002).into().versioned(), (71, 0, 2)), + (XCM_VERSION, Parachain(1001).into_versioned(), (70, 0, 3)), + (XCM_VERSION, Parachain(1003).into_versioned(), (72, 0, 3)), ] ); }); @@ -921,14 +905,11 @@ fn subscription_side_upgrades_work_with_notify() { #[test] fn subscription_side_upgrades_work_without_notify() { new_test_ext_with_balances(vec![]).execute_with(|| { - // An entry from a previous runtime with v0 XCM. - let v0_location = xcm::v0::MultiLocation::X1(xcm::v0::Junction::Parachain(1000)); - let v0_location = VersionedMultiLocation::from(v0_location); - VersionNotifyTargets::::insert(0, v0_location, (69, 0, 2)); - let v1_location = Parachain(1001).into().versioned(); + // An entry from a previous runtime with v1 XCM. + let v1_location = VersionedMultiLocation::V1(xcm::v1::Junction::Parachain(1001).into()); VersionNotifyTargets::::insert(1, v1_location, (70, 0, 2)); - let v2_location = Parachain(1002).into().versioned(); - VersionNotifyTargets::::insert(2, v2_location, (71, 0, 2)); + let v3_location = Parachain(1003).into_versioned(); + VersionNotifyTargets::::insert(3, v3_location, (72, 0, 2)); // A runtime upgrade which alters the version does send notifications. XcmPallet::on_runtime_upgrade(); @@ -939,9 +920,8 @@ fn subscription_side_upgrades_work_without_notify() { assert_eq!( contents, vec![ - (XCM_VERSION, Parachain(1000).into().versioned(), (69, 0, 2)), - (XCM_VERSION, Parachain(1001).into().versioned(), (70, 0, 2)), - (XCM_VERSION, Parachain(1002).into().versioned(), (71, 0, 2)), + (XCM_VERSION, Parachain(1001).into_versioned(), (70, 0, 3)), + (XCM_VERSION, Parachain(1003).into_versioned(), (72, 0, 3)), ] ); }); @@ -950,7 +930,7 @@ fn subscription_side_upgrades_work_without_notify() { #[test] fn subscriber_side_subscription_works() { new_test_ext_with_balances(vec![]).execute_with(|| { - let remote = Parachain(1000).into(); + let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( Origin::root(), Box::new(remote.clone().into()), @@ -1091,16 +1071,15 @@ fn subscription_side_upgrades_work_with_multistage_notify() { AdvertisedXcmVersion::set(1); // An entry from a previous runtime with v0 XCM. - let v0_location = xcm::v0::MultiLocation::X1(xcm::v0::Junction::Parachain(1000)); - let v0_location = VersionedMultiLocation::from(v0_location); - VersionNotifyTargets::::insert(0, v0_location, (69, 0, 1)); - let v1_location = Parachain(1001).into().versioned(); + let v1_location = VersionedMultiLocation::V1(xcm::v1::Junction::Parachain(1001).into()); VersionNotifyTargets::::insert(1, v1_location, (70, 0, 1)); - let v2_location = Parachain(1002).into().versioned(); + let v2_location = VersionedMultiLocation::V1(xcm::v2::Junction::Parachain(1002).into()); VersionNotifyTargets::::insert(2, v2_location, (71, 0, 1)); + let v3_location = Parachain(1003).into_versioned(); + VersionNotifyTargets::::insert(3, v3_location, (72, 0, 1)); // New version. - AdvertisedXcmVersion::set(2); + AdvertisedXcmVersion::set(3); // A runtime upgrade which alters the version does send notifications. XcmPallet::on_runtime_upgrade(); @@ -1113,22 +1092,22 @@ fn subscription_side_upgrades_work_with_multistage_notify() { } assert_eq!(counter, 4); - let instr0 = QueryResponse { - query_id: 69, - max_weight: 0, - response: Response::Version(2), - querier: None, - }; let instr1 = QueryResponse { query_id: 70, max_weight: 0, - response: Response::Version(2), + response: Response::Version(3), querier: None, }; let instr2 = QueryResponse { query_id: 71, max_weight: 0, - response: Response::Version(2), + response: Response::Version(3), + querier: None, + }; + let instr3 = QueryResponse { + query_id: 72, + max_weight: 0, + response: Response::Version(3), querier: None, }; let mut sent = take_sent_xcm(); @@ -1139,9 +1118,9 @@ fn subscription_side_upgrades_work_with_multistage_notify() { assert_eq!( sent, vec![ - (Parachain(1000).into(), Xcm(vec![instr0])), (Parachain(1001).into(), Xcm(vec![instr1])), (Parachain(1002).into(), Xcm(vec![instr2])), + (Parachain(1003).into(), Xcm(vec![instr3])), ] ); @@ -1150,9 +1129,9 @@ fn subscription_side_upgrades_work_with_multistage_notify() { assert_eq!( contents, vec![ - (XCM_VERSION, Parachain(1000).into().versioned(), (69, 0, 2)), - (XCM_VERSION, Parachain(1001).into().versioned(), (70, 0, 2)), - (XCM_VERSION, Parachain(1002).into().versioned(), (71, 0, 2)), + (XCM_VERSION, Parachain(1001).into_versioned(), (70, 0, 3)), + (XCM_VERSION, Parachain(1002).into_versioned(), (71, 0, 3)), + (XCM_VERSION, Parachain(1003).into_versioned(), (72, 0, 3)), ] ); }); diff --git a/xcm/procedural/src/lib.rs b/xcm/procedural/src/lib.rs index 8e43569b64d7..d16476c4f047 100644 --- a/xcm/procedural/src/lib.rs +++ b/xcm/procedural/src/lib.rs @@ -18,17 +18,10 @@ use proc_macro::TokenStream; -mod v0; mod v1; +mod v3; mod weight_info; -#[proc_macro] -pub fn impl_conversion_functions_for_multilocation_v0(input: TokenStream) -> TokenStream { - v0::multilocation::generate_conversion_functions(input) - .unwrap_or_else(syn::Error::into_compile_error) - .into() -} - #[proc_macro] pub fn impl_conversion_functions_for_multilocation_v1(input: TokenStream) -> TokenStream { v1::multilocation::generate_conversion_functions(input) @@ -40,3 +33,17 @@ pub fn impl_conversion_functions_for_multilocation_v1(input: TokenStream) -> Tok pub fn derive_xcm_weight_info(item: TokenStream) -> TokenStream { weight_info::derive(item) } + +#[proc_macro] +pub fn impl_conversion_functions_for_multilocation_v3(input: TokenStream) -> TokenStream { + v3::multilocation::generate_conversion_functions(input) + .unwrap_or_else(syn::Error::into_compile_error) + .into() +} + +#[proc_macro] +pub fn impl_conversion_functions_for_junctions_v3(input: TokenStream) -> TokenStream { + v3::junctions::generate_conversion_functions(input) + .unwrap_or_else(syn::Error::into_compile_error) + .into() +} diff --git a/xcm/procedural/src/v0.rs b/xcm/procedural/src/v0.rs deleted file mode 100644 index 7774df4e9f8f..000000000000 --- a/xcm/procedural/src/v0.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 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 . - -pub mod multilocation; diff --git a/xcm/procedural/src/v0/multilocation.rs b/xcm/procedural/src/v0/multilocation.rs deleted file mode 100644 index 247ef856b14e..000000000000 --- a/xcm/procedural/src/v0/multilocation.rs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2021 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 . - -use proc_macro2::{Span, TokenStream}; -use quote::{format_ident, quote}; - -pub fn generate_conversion_functions(input: proc_macro::TokenStream) -> syn::Result { - if !input.is_empty() { - return Err(syn::Error::new(Span::call_site(), "No arguments expected")) - } - - let from_tuples = generate_conversion_from_tuples(); - let from_v1 = generate_conversion_from_v1(); - - Ok(quote! { - #from_tuples - #from_v1 - }) -} - -fn generate_conversion_from_tuples() -> TokenStream { - let from_tuples = (0..8usize) - .map(|num_junctions| { - let junctions = - (0..=num_junctions).map(|_| format_ident!("Junction")).collect::>(); - let idents = (0..=num_junctions).map(|i| format_ident!("j{}", i)).collect::>(); - let variant = &format_ident!("X{}", num_junctions + 1); - let array_size = num_junctions + 1; - - quote! { - impl From<( #(#junctions,)* )> for MultiLocation { - fn from( ( #(#idents,)* ): ( #(#junctions,)* ) ) -> Self { - MultiLocation::#variant( #(#idents),* ) - } - } - - impl From<[Junction; #array_size]> for MultiLocation { - fn from(j: [Junction; #array_size]) -> Self { - let [#(#idents),*] = j; - MultiLocation::#variant( #(#idents),* ) - } - } - } - }) - .collect::(); - - quote! { - impl From<()> for MultiLocation { - fn from(_: ()) -> Self { - MultiLocation::Null - } - } - - impl From for MultiLocation { - fn from(x: Junction) -> Self { - MultiLocation::X1(x) - } - } - - impl From<[Junction; 0]> for MultiLocation { - fn from(_: [Junction; 0]) -> Self { - MultiLocation::Null - } - } - - #from_tuples - } -} - -fn generate_conversion_from_v1() -> TokenStream { - let match_variants = (0..8u8) - .map(|cur_num| { - let variant = format_ident!("X{}", cur_num + 1); - let idents = (1..=cur_num).map(|i| format_ident!("j{}", i)).collect::>(); - - quote! { - crate::v1::Junctions::#variant( j0 #(, #idents)* ) => res - .pushed_with(Junction::from(j0)) - #( .and_then(|res| res.pushed_with(Junction::from(#idents))) )* - .map_err(|_| ()), - } - }) - .collect::(); - - quote! { - impl core::convert::TryFrom for MultiLocation { - type Error = (); - fn try_from(v1: crate::v1::MultiLocation) -> core::result::Result { - let mut res = MultiLocation::Null; - - for _ in 0..v1.parents { - res.push(Junction::Parent)?; - } - - match v1.interior { - crate::v1::Junctions::Here => Ok(res), - #match_variants - } - } - } - } -} diff --git a/xcm/procedural/src/v1/multilocation.rs b/xcm/procedural/src/v1/multilocation.rs index eae3d677b075..15a0d322a204 100644 --- a/xcm/procedural/src/v1/multilocation.rs +++ b/xcm/procedural/src/v1/multilocation.rs @@ -25,11 +25,11 @@ pub fn generate_conversion_functions(input: proc_macro::TokenStream) -> Result TokenStream { } } -fn generate_conversion_from_v0() -> TokenStream { +fn generate_conversion_from_v3() -> TokenStream { let match_variants = (0..8u8) .map(|cur_num| { let num_ancestors = cur_num + 1; let variant = format_ident!("X{}", num_ancestors); let idents = (0..=cur_num).map(|i| format_ident!("j{}", i)).collect::>(); - let intermediate_match_arms = (1..num_ancestors) - .rev() - .map(|parent_count| { - let parent_idents = - (0..parent_count).map(|j| format_ident!("j{}", j)).collect::>(); - let junction_idents = (parent_count..num_ancestors) - .map(|j| format_ident!("j{}", j)) - .collect::>(); - let junction_variant = format_ident!("X{}", num_ancestors - parent_count); - - quote! { - crate::v0::MultiLocation::#variant( #(#idents),* ) - if #( #parent_idents.is_parent() )&&* => - Ok(MultiLocation { - parents: #parent_count, - interior: #junction_variant( #( core::convert::TryInto::try_into(#junction_idents)? ),* ), - }), - } - }) - .collect::(); - quote! { - crate::v0::MultiLocation::#variant( #(#idents),* ) - if #( #idents.is_parent() )&&* => - Ok(MultiLocation::ancestor(#num_ancestors)), - #intermediate_match_arms - crate::v0::MultiLocation::#variant( #(#idents),* ) => - Ok( #variant( #( core::convert::TryInto::try_into(#idents)? ),* ).into() ), + crate::v3::Junctions::#variant( #(#idents),* ) => + #variant( #( core::convert::TryInto::try_into(#idents)? ),* ), } }) .collect::(); quote! { - impl core::convert::TryFrom for MultiLocation { + impl core::convert::TryFrom for Junctions { type Error = (); - fn try_from(mut v0: crate::v0::MultiLocation) -> core::result::Result { + fn try_from(mut new: crate::v3::Junctions) -> core::result::Result { use Junctions::*; - - v0.canonicalize(); - match v0 { - crate::v0::MultiLocation::Null => Ok(Here.into()), + Ok(match new { + crate::v3::Junctions::Here => Here, #match_variants - } + }) } } } diff --git a/xcm/procedural/src/v3.rs b/xcm/procedural/src/v3.rs new file mode 100644 index 000000000000..eeaa76da0985 --- /dev/null +++ b/xcm/procedural/src/v3.rs @@ -0,0 +1,186 @@ +// Copyright 2021 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 . + +use proc_macro2::{Span, TokenStream}; +use quote::{format_ident, quote}; +use syn::{Result, Token}; + +const MAX_JUNCTIONS: usize = 8; + +pub mod multilocation { + use super::*; + + pub fn generate_conversion_functions(input: proc_macro::TokenStream) -> Result { + if !input.is_empty() { + return Err(syn::Error::new(Span::call_site(), "No arguments expected")) + } + + let from_tuples = generate_conversion_from_tuples(8, 8); + + Ok(quote! { + #from_tuples + }) + } + + fn generate_conversion_from_tuples(max_junctions: usize, max_parents: usize) -> TokenStream { + let mut from_tuples = (0..=max_junctions) + .map(|num_junctions| { + let types = (0..num_junctions).map(|i| format_ident!("J{}", i)).collect::>(); + let idents = + (0..num_junctions).map(|i| format_ident!("j{}", i)).collect::>(); + let array_size = num_junctions; + let interior = if num_junctions == 0 { + quote!(Junctions::Here) + } else { + let variant = format_ident!("X{}", num_junctions); + quote! { + Junctions::#variant( #(#idents .into()),* ) + } + }; + + let mut from_tuple = quote! { + impl< #(#types : Into,)* > From<( Ancestor, #( #types ),* )> for MultiLocation { + fn from( ( Ancestor(parents), #(#idents),* ): ( Ancestor, #( #types ),* ) ) -> Self { + MultiLocation { parents, interior: #interior } + } + } + + impl From<[Junction; #array_size]> for MultiLocation { + fn from(j: [Junction; #array_size]) -> Self { + let [#(#idents),*] = j; + MultiLocation { parents: 0, interior: #interior } + } + } + }; + + let from_parent_tuples = (0..=max_parents).map(|cur_parents| { + let parents = + (0..cur_parents).map(|_| format_ident!("Parent")).collect::>(); + let underscores = + (0..cur_parents).map(|_| Token![_](Span::call_site())).collect::>(); + + quote! { + impl< #(#types : Into,)* > From<( #( #parents , )* #( #types , )* )> for MultiLocation { + fn from( ( #(#underscores,)* #(#idents,)* ): ( #(#parents,)* #(#types,)* ) ) -> Self { + Self { parents: #cur_parents as u8, interior: #interior } + } + } + } + }); + + from_tuple.extend(from_parent_tuples); + from_tuple + }) + .collect::(); + + let from_parent_junctions_tuples = (0..=max_parents).map(|cur_parents| { + let parents = (0..cur_parents).map(|_| format_ident!("Parent")).collect::>(); + let underscores = + (0..cur_parents).map(|_| Token![_](Span::call_site())).collect::>(); + + quote! { + impl From<( #(#parents,)* Junctions )> for MultiLocation { + fn from( (#(#underscores,)* junctions): ( #(#parents,)* Junctions ) ) -> Self { + MultiLocation { parents: #cur_parents as u8, interior: junctions } + } + } + } + }); + from_tuples.extend(from_parent_junctions_tuples); + + quote! { + impl From<(Ancestor, Junctions)> for MultiLocation { + fn from((Ancestor(parents), interior): (Ancestor, Junctions)) -> Self { + MultiLocation { parents, interior } + } + } + + impl From for MultiLocation { + fn from(x: Junction) -> Self { + MultiLocation { parents: 0, interior: Junctions::X1(x) } + } + } + + #from_tuples + } + } +} + +pub mod junctions { + use super::*; + + pub fn generate_conversion_functions(input: proc_macro::TokenStream) -> Result { + if !input.is_empty() { + return Err(syn::Error::new(Span::call_site(), "No arguments expected")) + } + + // Support up to 8 Parents in a tuple, assuming that most use cases don't go past 8 parents. + let from_v1 = generate_conversion_from_v1(MAX_JUNCTIONS); + let from_tuples = generate_conversion_from_tuples(MAX_JUNCTIONS); + + Ok(quote! { + #from_v1 + #from_tuples + }) + } + + fn generate_conversion_from_tuples(max_junctions: usize) -> TokenStream { + (1..=max_junctions) + .map(|num_junctions| { + let idents = + (0..num_junctions).map(|i| format_ident!("j{}", i)).collect::>(); + let types = (0..num_junctions).map(|i| format_ident!("J{}", i)).collect::>(); + let variant = &format_ident!("X{}", num_junctions); + + quote! { + impl<#(#types : Into,)*> From<( #(#types,)* )> for Junctions { + fn from( ( #(#idents,)* ): ( #(#types,)* ) ) -> Self { + Self::#variant( #(#idents .into()),* ) + } + } + } + }) + .collect() + } + + fn generate_conversion_from_v1(max_junctions: usize) -> TokenStream { + let match_variants = (0..max_junctions) + .map(|cur_num| { + let num_ancestors = cur_num + 1; + let variant = format_ident!("X{}", num_ancestors); + let idents = (0..=cur_num).map(|i| format_ident!("j{}", i)).collect::>(); + + quote! { + crate::v1::Junctions::#variant( #(#idents),* ) => + #variant( #( core::convert::TryInto::try_into(#idents)? ),* ), + } + }) + .collect::(); + + quote! { + impl core::convert::TryFrom for Junctions { + type Error = (); + fn try_from(mut old: crate::v1::Junctions) -> core::result::Result { + use Junctions::*; + Ok(match old { + crate::v1::Junctions::Here => Here, + #match_variants + }) + } + } + } + } +} diff --git a/xcm/src/lib.rs b/xcm/src/lib.rs index e7e1a98b3a61..b8b5ea98c2f4 100644 --- a/xcm/src/lib.rs +++ b/xcm/src/lib.rs @@ -23,7 +23,6 @@ #![no_std] extern crate alloc; -use alloc::vec::Vec; use core::{ convert::{TryFrom, TryInto}, result::Result, @@ -32,7 +31,6 @@ use derivative::Derivative; use parity_scale_codec::{Decode, Encode, Error as CodecError, Input}; use scale_info::TypeInfo; -pub mod v0; pub mod v1; pub mod v2; pub mod v3; @@ -76,50 +74,108 @@ pub trait IntoVersion: Sized { #[codec(encode_bound())] #[codec(decode_bound())] pub enum VersionedMultiLocation { - V0(v0::MultiLocation), + #[codec(index = 1)] V1(v1::MultiLocation), + #[codec(index = 2)] + V3(v3::MultiLocation), } impl IntoVersion for VersionedMultiLocation { fn into_version(self, n: Version) -> Result { Ok(match n { - 0 => Self::V0(self.try_into()?), - 1 | 2 | 3 => Self::V1(self.try_into()?), + 1 | 2 => Self::V1(self.try_into()?), + 3 => Self::V3(self.try_into()?), _ => return Err(()), }) } } -impl From for VersionedMultiLocation { - fn from(x: v0::MultiLocation) -> Self { - VersionedMultiLocation::V0(x) +impl From for VersionedMultiLocation { + fn from(x: v1::MultiLocation) -> Self { + VersionedMultiLocation::V1(x) } } -impl> From for VersionedMultiLocation { +impl> From for VersionedMultiLocation { fn from(x: T) -> Self { - VersionedMultiLocation::V1(x.into()) + VersionedMultiLocation::V3(x.into()) } } -impl TryFrom for v0::MultiLocation { +impl TryFrom for v1::MultiLocation { type Error = (); fn try_from(x: VersionedMultiLocation) -> Result { use VersionedMultiLocation::*; match x { - V0(x) => Ok(x), - V1(x) => x.try_into(), + V1(x) => Ok(x), + V3(x) => x.try_into(), } } } -impl TryFrom for v1::MultiLocation { +impl TryFrom for v3::MultiLocation { type Error = (); fn try_from(x: VersionedMultiLocation) -> Result { use VersionedMultiLocation::*; match x { - V0(x) => x.try_into(), + V1(x) => x.try_into(), + V3(x) => Ok(x), + } + } +} + +/// A single `InteriorMultiLocation` value, together with its version code. +#[derive(Derivative, Encode, Decode, TypeInfo)] +#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] +#[codec(encode_bound())] +#[codec(decode_bound())] +pub enum VersionedInteriorMultiLocation { + #[codec(index = 0)] + V1(v1::InteriorMultiLocation), + #[codec(index = 1)] + V3(v3::InteriorMultiLocation), +} + +impl IntoVersion for VersionedInteriorMultiLocation { + fn into_version(self, n: Version) -> Result { + Ok(match n { + 1 | 2 => Self::V1(self.try_into()?), + 3 => Self::V3(self.try_into()?), + _ => return Err(()), + }) + } +} + +impl From for VersionedInteriorMultiLocation { + fn from(x: v1::InteriorMultiLocation) -> Self { + VersionedInteriorMultiLocation::V1(x) + } +} + +impl> From for VersionedInteriorMultiLocation { + fn from(x: T) -> Self { + VersionedInteriorMultiLocation::V3(x.into()) + } +} + +impl TryFrom for v1::InteriorMultiLocation { + type Error = (); + fn try_from(x: VersionedInteriorMultiLocation) -> Result { + use VersionedInteriorMultiLocation::*; + match x { V1(x) => Ok(x), + V3(x) => x.try_into(), + } + } +} + +impl TryFrom for v3::InteriorMultiLocation { + type Error = (); + fn try_from(x: VersionedInteriorMultiLocation) -> Result { + use VersionedInteriorMultiLocation::*; + match x { + V1(x) => x.try_into(), + V3(x) => Ok(x), } } } @@ -130,16 +186,17 @@ impl TryFrom for v1::MultiLocation { #[codec(encode_bound())] #[codec(decode_bound())] pub enum VersionedResponse { - V0(v0::Response), + #[codec(index = 1)] V1(v1::Response), + #[codec(index = 2)] V2(v2::Response), + #[codec(index = 3)] V3(v3::Response), } impl IntoVersion for VersionedResponse { fn into_version(self, n: Version) -> Result { Ok(match n { - 0 => Self::V0(self.try_into()?), 1 => Self::V1(self.try_into()?), 2 => Self::V2(self.try_into()?), 3 => Self::V3(self.try_into()?), @@ -148,12 +205,6 @@ impl IntoVersion for VersionedResponse { } } -impl From for VersionedResponse { - fn from(x: v0::Response) -> Self { - VersionedResponse::V0(x) - } -} - impl From for VersionedResponse { fn from(x: v1::Response) -> Self { VersionedResponse::V1(x) @@ -172,25 +223,11 @@ impl> From for VersionedResponse { } } -impl TryFrom for v0::Response { - type Error = (); - fn try_from(x: VersionedResponse) -> Result { - use VersionedResponse::*; - match x { - V0(x) => Ok(x), - V1(x) => x.try_into(), - V2(x) => V1(x.try_into()?).try_into(), - V3(x) => V2(x.try_into()?).try_into(), - } - } -} - impl TryFrom for v1::Response { type Error = (); fn try_from(x: VersionedResponse) -> Result { use VersionedResponse::*; match x { - V0(x) => x.try_into(), V1(x) => Ok(x), V2(x) => x.try_into(), V3(x) => V2(x.try_into()?).try_into(), @@ -203,7 +240,6 @@ impl TryFrom for v2::Response { fn try_from(x: VersionedResponse) -> Result { use VersionedResponse::*; match x { - V0(x) => V1(x.try_into()?).try_into(), V1(x) => x.try_into(), V2(x) => Ok(x), V3(x) => x.try_into(), @@ -216,7 +252,6 @@ impl TryFrom for v3::Response { fn try_from(x: VersionedResponse) -> Result { use VersionedResponse::*; match x { - V0(x) => V1(x.try_into()?).try_into(), V1(x) => V2(x.try_into()?).try_into(), V2(x) => x.try_into(), V3(x) => Ok(x), @@ -230,50 +265,52 @@ impl TryFrom for v3::Response { #[codec(encode_bound())] #[codec(decode_bound())] pub enum VersionedMultiAsset { - V0(v0::MultiAsset), + #[codec(index = 1)] V1(v1::MultiAsset), + #[codec(index = 2)] + V3(v3::MultiAsset), } impl IntoVersion for VersionedMultiAsset { fn into_version(self, n: Version) -> Result { Ok(match n { - 0 => Self::V0(self.try_into()?), - 1 | 2 | 3 => Self::V1(self.try_into()?), + 1 | 2 => Self::V1(self.try_into()?), + 3 => Self::V3(self.try_into()?), _ => return Err(()), }) } } -impl From for VersionedMultiAsset { - fn from(x: v0::MultiAsset) -> Self { - VersionedMultiAsset::V0(x) +impl From for VersionedMultiAsset { + fn from(x: v1::MultiAsset) -> Self { + VersionedMultiAsset::V1(x) } } -impl> From for VersionedMultiAsset { - fn from(x: T) -> Self { - VersionedMultiAsset::V1(x.into()) +impl From for VersionedMultiAsset { + fn from(x: v3::MultiAsset) -> Self { + VersionedMultiAsset::V3(x) } } -impl TryFrom for v0::MultiAsset { +impl TryFrom for v1::MultiAsset { type Error = (); fn try_from(x: VersionedMultiAsset) -> Result { use VersionedMultiAsset::*; match x { - V0(x) => Ok(x), - V1(x) => x.try_into(), + V1(x) => Ok(x), + V3(x) => x.try_into(), } } } -impl TryFrom for v1::MultiAsset { +impl TryFrom for v3::MultiAsset { type Error = (); fn try_from(x: VersionedMultiAsset) -> Result { use VersionedMultiAsset::*; match x { - V0(x) => x.try_into(), - V1(x) => Ok(x), + V1(x) => x.try_into(), + V3(x) => Ok(x), } } } @@ -284,50 +321,52 @@ impl TryFrom for v1::MultiAsset { #[codec(encode_bound())] #[codec(decode_bound())] pub enum VersionedMultiAssets { - V0(Vec), + #[codec(index = 1)] V1(v1::MultiAssets), + #[codec(index = 2)] + V3(v3::MultiAssets), } impl IntoVersion for VersionedMultiAssets { fn into_version(self, n: Version) -> Result { Ok(match n { - 0 => Self::V0(self.try_into()?), - 1 | 2 | 3 => Self::V1(self.try_into()?), + 1 | 2 => Self::V1(self.try_into()?), + 3 => Self::V3(self.try_into()?), _ => return Err(()), }) } } -impl From> for VersionedMultiAssets { - fn from(x: Vec) -> Self { - VersionedMultiAssets::V0(x) +impl From for VersionedMultiAssets { + fn from(x: v1::MultiAssets) -> Self { + VersionedMultiAssets::V1(x) } } -impl> From for VersionedMultiAssets { +impl> From for VersionedMultiAssets { fn from(x: T) -> Self { - VersionedMultiAssets::V1(x.into()) + VersionedMultiAssets::V3(x.into()) } } -impl TryFrom for Vec { +impl TryFrom for v1::MultiAssets { type Error = (); fn try_from(x: VersionedMultiAssets) -> Result { use VersionedMultiAssets::*; match x { - V0(x) => Ok(x), - V1(x) => x.try_into(), + V1(x) => Ok(x), + V3(x) => x.try_into(), } } } -impl TryFrom for v1::MultiAssets { +impl TryFrom for v3::MultiAssets { type Error = (); fn try_from(x: VersionedMultiAssets) -> Result { use VersionedMultiAssets::*; match x { - V0(x) => x.try_into(), - V1(x) => Ok(x), + V1(x) => x.try_into(), + V3(x) => Ok(x), } } } @@ -339,16 +378,17 @@ impl TryFrom for v1::MultiAssets { #[codec(decode_bound())] #[scale_info(bounds(), skip_type_params(Call))] pub enum VersionedXcm { - V0(v0::Xcm), + #[codec(index = 1)] V1(v1::Xcm), + #[codec(index = 2)] V2(v2::Xcm), + #[codec(index = 3)] V3(v3::Xcm), } impl IntoVersion for VersionedXcm { fn into_version(self, n: Version) -> Result { Ok(match n { - 0 => Self::V0(self.try_into()?), 1 => Self::V1(self.try_into()?), 2 => Self::V2(self.try_into()?), 3 => Self::V3(self.try_into()?), @@ -357,12 +397,6 @@ impl IntoVersion for VersionedXcm { } } -impl From> for VersionedXcm { - fn from(x: v0::Xcm) -> Self { - VersionedXcm::V0(x) - } -} - impl From> for VersionedXcm { fn from(x: v1::Xcm) -> Self { VersionedXcm::V1(x) @@ -381,25 +415,11 @@ impl From> for VersionedXcm { } } -impl TryFrom> for v0::Xcm { - type Error = (); - fn try_from(x: VersionedXcm) -> Result { - use VersionedXcm::*; - match x { - V0(x) => Ok(x), - V1(x) => x.try_into(), - V2(x) => V1(x.try_into()?).try_into(), - V3(x) => V2(x.try_into()?).try_into(), - } - } -} - impl TryFrom> for v1::Xcm { type Error = (); fn try_from(x: VersionedXcm) -> Result { use VersionedXcm::*; match x { - V0(x) => x.try_into(), V1(x) => Ok(x), V2(x) => x.try_into(), V3(x) => V2(x.try_into()?).try_into(), @@ -412,7 +432,6 @@ impl TryFrom> for v2::Xcm { fn try_from(x: VersionedXcm) -> Result { use VersionedXcm::*; match x { - V0(x) => V1(x.try_into()?).try_into(), V1(x) => x.try_into(), V2(x) => Ok(x), V3(x) => x.try_into(), @@ -425,7 +444,6 @@ impl TryFrom> for v3::Xcm { fn try_from(x: VersionedXcm) -> Result { use VersionedXcm::*; match x { - V0(x) => V1(x.try_into()?).try_into(), V1(x) => V2(x.try_into()?).try_into(), V2(x) => x.try_into(), V3(x) => Ok(x), @@ -482,18 +500,12 @@ pub type AlwaysRelease = AlwaysV2; pub mod prelude { pub use super::{ latest::prelude::*, AlwaysLatest, AlwaysRelease, AlwaysV2, AlwaysV3, IntoVersion, - Unsupported, Version as XcmVersion, VersionedMultiAsset, VersionedMultiAssets, - VersionedMultiLocation, VersionedResponse, VersionedXcm, WrapVersion, + Unsupported, Version as XcmVersion, VersionedInteriorMultiLocation, VersionedMultiAsset, + VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, VersionedXcm, WrapVersion, }; } pub mod opaque { - pub mod v0 { - // Everything from v0 - pub use crate::v0::*; - // Then override with the opaque types in v0 - pub use crate::v0::opaque::{Order, Xcm}; - } pub mod v1 { // Everything from v1 pub use crate::v1::*; @@ -501,13 +513,13 @@ pub mod opaque { pub use crate::v1::opaque::{Order, Xcm}; } pub mod v2 { - // Everything from v1 + // Everything from v2 pub use crate::v2::*; // Then override with the opaque types in v2 pub use crate::v2::opaque::{Instruction, Xcm}; } pub mod v3 { - // Everything from v2 + // Everything from v3 pub use crate::v3::*; // Then override with the opaque types in v3 pub use crate::v3::opaque::{Instruction, Xcm}; @@ -525,3 +537,9 @@ pub mod opaque { pub trait GetWeight { fn weight(&self) -> latest::Weight; } + +#[test] +fn conversion_works() { + use latest::prelude::*; + let _: VersionedMultiAssets = (Here, 1).into(); +} diff --git a/xcm/src/v0/junction.rs b/xcm/src/v0/junction.rs deleted file mode 100644 index 0c559ca5a136..000000000000 --- a/xcm/src/v0/junction.rs +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2020 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 . - -//! Support data structures for `MultiLocation`, primarily the `Junction` datatype. - -use alloc::vec::Vec; -use parity_scale_codec::{Decode, Encode}; -use scale_info::TypeInfo; - -/// A global identifier of an account-bearing consensus system. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] -pub enum NetworkId { - /// Unidentified/any. - Any, - /// Some named network. - Named(Vec), - /// The Polkadot Relay chain - Polkadot, - /// Kusama. - Kusama, -} - -/// An identifier of a pluralistic body. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] -pub enum BodyId { - /// The only body in its context. - Unit, - /// A named body. - Named(Vec), - /// An indexed body. - Index(#[codec(compact)] u32), - /// The unambiguous executive body (for Polkadot, this would be the Polkadot council). - Executive, - /// The unambiguous technical body (for Polkadot, this would be the Technical Committee). - Technical, - /// The unambiguous legislative body (for Polkadot, this could be considered the opinion of a majority of - /// lock-voters). - Legislative, - /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it - /// may be considered as that). - Judicial, -} - -/// A part of a pluralistic body. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] -pub enum BodyPart { - /// The body's declaration, under whatever means it decides. - Voice, - /// A given number of members of the body. - Members { - #[codec(compact)] - count: u32, - }, - /// A given number of members of the body, out of some larger caucus. - Fraction { - #[codec(compact)] - nom: u32, - #[codec(compact)] - denom: u32, - }, - /// No less than the given proportion of members of the body. - AtLeastProportion { - #[codec(compact)] - nom: u32, - #[codec(compact)] - denom: u32, - }, - /// More than than the given proportion of members of the body. - MoreThanProportion { - #[codec(compact)] - nom: u32, - #[codec(compact)] - denom: u32, - }, -} - -impl BodyPart { - /// Returns `true` if the part represents a strict majority (> 50%) of the body in question. - pub fn is_majority(&self) -> bool { - match self { - BodyPart::Fraction { nom, denom } if *nom * 2 > *denom => true, - BodyPart::AtLeastProportion { nom, denom } if *nom * 2 > *denom => true, - BodyPart::MoreThanProportion { nom, denom } if *nom * 2 >= *denom => true, - _ => false, - } - } -} - -/// A single item in a path to describe the relative location of a consensus system. -/// -/// Each item assumes a pre-existing location as its context and is defined in terms of it. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] -pub enum Junction { - /// The consensus system of which the context is a member and state-wise super-set. - /// - /// NOTE: This item is *not* a sub-consensus item: a consensus system may not identify itself trustlessly as - /// a location that includes this junction. - Parent, - /// An indexed parachain belonging to and operated by the context. - /// - /// Generally used when the context is a Polkadot Relay-chain. - Parachain(#[codec(compact)] u32), - /// A 32-byte identifier for an account of a specific network that is respected as a sovereign endpoint within - /// the context. - /// - /// Generally used when the context is a Substrate-based chain. - AccountId32 { network: NetworkId, id: [u8; 32] }, - /// An 8-byte index for an account of a specific network that is respected as a sovereign endpoint within - /// the context. - /// - /// May be used when the context is a Frame-based chain and includes e.g. an indices pallet. - AccountIndex64 { - network: NetworkId, - #[codec(compact)] - index: u64, - }, - /// A 20-byte identifier for an account of a specific network that is respected as a sovereign endpoint within - /// the context. - /// - /// May be used when the context is an Ethereum or Bitcoin chain or smart-contract. - AccountKey20 { network: NetworkId, key: [u8; 20] }, - /// An instanced, indexed pallet that forms a constituent part of the context. - /// - /// Generally used when the context is a Frame-based chain. - PalletInstance(u8), - /// A non-descript index within the context location. - /// - /// Usage will vary widely owing to its generality. - /// - /// NOTE: Try to avoid using this and instead use a more specific item. - GeneralIndex(#[codec(compact)] u128), - /// A nondescript datum acting as a key within the context location. - /// - /// Usage will vary widely owing to its generality. - /// - /// NOTE: Try to avoid using this and instead use a more specific item. - GeneralKey(Vec), - /// The unambiguous child. - /// - /// Not currently used except as a fallback when deriving ancestry. - OnlyChild, - /// A pluralistic body existing within consensus. - /// - /// Typical to be used to represent a governance origin of a chain, but could in principle be used to represent - /// things such as multisigs also. - Plurality { id: BodyId, part: BodyPart }, -} - -impl From for Junction { - fn from(v1: crate::v1::Junction) -> Junction { - use crate::v1::Junction::*; - match v1 { - Parachain(id) => Self::Parachain(id), - AccountId32 { network, id } => Self::AccountId32 { network, id }, - AccountIndex64 { network, index } => Self::AccountIndex64 { network, index }, - AccountKey20 { network, key } => Self::AccountKey20 { network, key }, - PalletInstance(index) => Self::PalletInstance(index), - GeneralIndex(index) => Self::GeneralIndex(index), - GeneralKey(key) => Self::GeneralKey(key), - OnlyChild => Self::OnlyChild, - Plurality { id, part } => Self::Plurality { id, part }, - } - } -} - -impl Junction { - /// Returns true if this junction is a `Parent` item. - pub fn is_parent(&self) -> bool { - match self { - Junction::Parent => true, - _ => false, - } - } - - /// Returns true if this junction can be considered an interior part of its context. This is generally `true`, - /// except for the `Parent` item. - pub fn is_interior(&self) -> bool { - match self { - Junction::Parent => false, - - Junction::Parachain(..) | - Junction::AccountId32 { .. } | - Junction::AccountIndex64 { .. } | - Junction::AccountKey20 { .. } | - Junction::PalletInstance { .. } | - Junction::GeneralIndex { .. } | - Junction::GeneralKey(..) | - Junction::OnlyChild | - Junction::Plurality { .. } => true, - } - } -} diff --git a/xcm/src/v0/mod.rs b/xcm/src/v0/mod.rs deleted file mode 100644 index 35889d8daab2..000000000000 --- a/xcm/src/v0/mod.rs +++ /dev/null @@ -1,388 +0,0 @@ -// Copyright 2020 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 . - -//! Version 0 of the Cross-Consensus Message format data structures. - -use crate::DoubleEncoded; -use alloc::vec::Vec; -use core::{ - convert::{TryFrom, TryInto}, - result, -}; -use derivative::Derivative; -use parity_scale_codec::{self, Decode, Encode}; -use scale_info::TypeInfo; - -mod junction; -mod multi_asset; -mod multi_location; -mod order; -mod traits; -use super::v1::{MultiLocation as MultiLocation1, Response as Response1, Xcm as Xcm1}; -pub use junction::{BodyId, BodyPart, Junction, NetworkId}; -pub use multi_asset::{AssetInstance, MultiAsset}; -pub use multi_location::MultiLocation::{self, *}; -pub use order::Order; -pub use traits::{Error, ExecuteXcm, Outcome, Result, SendXcm}; - -/// A prelude for importing all types typically used when interacting with XCM messages. -pub mod prelude { - pub use super::{ - junction::{BodyId, Junction::*}, - multi_asset::{ - AssetInstance::{self, *}, - MultiAsset::{self, *}, - }, - multi_location::MultiLocation::{self, *}, - order::Order::{self, *}, - traits::{Error as XcmError, ExecuteXcm, Outcome, Result as XcmResult, SendXcm}, - Junction::*, - OriginKind, - Xcm::{self, *}, - }; -} - -// TODO: #2841 #XCMENCODE Efficient encodings for MultiAssets, Vec, using initial byte values 128+ to encode -// the number of items in the vector. - -/// Basically just the XCM (more general) version of `ParachainDispatchOrigin`. -#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] -pub enum OriginKind { - /// Origin should just be the native dispatch origin representation for the sender in the - /// local runtime framework. For Cumulus/Frame chains this is the `Parachain` or `Relay` origin - /// if coming from a chain, though there may be others if the `MultiLocation` XCM origin has a - /// primary/native dispatch origin form. - Native, - - /// Origin should just be the standard account-based origin with the sovereign account of - /// the sender. For Cumulus/Frame chains, this is the `Signed` origin. - SovereignAccount, - - /// Origin should be the super-user. For Cumulus/Frame chains, this is the `Root` origin. - /// This will not usually be an available option. - Superuser, - - /// Origin should be interpreted as an XCM native origin and the `MultiLocation` should be - /// encoded directly in the dispatch origin unchanged. For Cumulus/Frame chains, this will be - /// the `pallet_xcm::Origin::Xcm` type. - Xcm, -} - -/// Response data to a query. -#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] -pub enum Response { - /// Some assets. - Assets(Vec), -} - -/// Cross-Consensus Message: A message from one consensus system to another. -/// -/// Consensus systems that may send and receive messages include blockchains and smart contracts. -/// -/// All messages are delivered from a known *origin*, expressed as a `MultiLocation`. -/// -/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the outer -/// XCM format, known as `VersionedXcm`. -#[derive(Derivative, Encode, Decode, TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -#[scale_info(bounds(), skip_type_params(Call))] -pub enum Xcm { - /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into `holding`. Execute the - /// orders (`effects`). - /// - /// - `assets`: The asset(s) to be withdrawn into holding. - /// - `effects`: The order(s) to execute on the holding account. - /// - /// Kind: *Instruction*. - /// - /// Errors: - #[codec(index = 0)] - WithdrawAsset { assets: Vec, effects: Vec> }, - - /// Asset(s) (`assets`) have been received into the ownership of this system on the `origin` system. - /// - /// Some orders are given (`effects`) which should be executed once the corresponding derivative assets have - /// been placed into `holding`. - /// - /// - `assets`: The asset(s) that are minted into holding. - /// - `effects`: The order(s) to execute on the holding account. - /// - /// Safety: `origin` must be trusted to have received and be storing `assets` such that they may later be - /// withdrawn should this system send a corresponding message. - /// - /// Kind: *Trusted Indication*. - /// - /// Errors: - #[codec(index = 1)] - ReserveAssetDeposit { assets: Vec, effects: Vec> }, - - /// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets should be - /// created on this system. - /// - /// Some orders are given (`effects`) which should be executed once the corresponding derivative assets have - /// been placed into `holding`. - /// - /// - `assets`: The asset(s) that are minted into holding. - /// - `effects`: The order(s) to execute on the holding account. - /// - /// Safety: `origin` must be trusted to have irrevocably destroyed the `assets` prior as a consequence of - /// sending this message. - /// - /// Kind: *Trusted Indication*. - /// - /// Errors: - #[codec(index = 2)] - TeleportAsset { assets: Vec, effects: Vec> }, - - /// Indication of the contents of the holding account corresponding to the `QueryHolding` order of `query_id`. - /// - /// - `query_id`: The identifier of the query that resulted in this message being sent. - /// - `assets`: The message content. - /// - /// Safety: No concerns. - /// - /// Kind: *Information*. - /// - /// Errors: - #[codec(index = 3)] - QueryResponse { - #[codec(compact)] - query_id: u64, - response: Response, - }, - - /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets under the - /// ownership of `dest` within this consensus system. - /// - /// - `assets`: The asset(s) to be withdrawn. - /// - `dest`: The new owner for the assets. - /// - /// Safety: No concerns. - /// - /// Kind: *Instruction*. - /// - /// Errors: - #[codec(index = 4)] - TransferAsset { assets: Vec, dest: MultiLocation }, - - /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets under the - /// ownership of `dest` within this consensus system. - /// - /// Send an onward XCM message to `dest` of `ReserveAssetDeposit` with the given `effects`. - /// - /// - `assets`: The asset(s) to be withdrawn. - /// - `dest`: The new owner for the assets. - /// - `effects`: The orders that should be contained in the `ReserveAssetDeposit` which is sent onwards to - /// `dest`. - /// - /// Safety: No concerns. - /// - /// Kind: *Instruction*. - /// - /// Errors: - #[codec(index = 5)] - TransferReserveAsset { assets: Vec, dest: MultiLocation, effects: Vec> }, - - /// Apply the encoded transaction `call`, whose dispatch-origin should be `origin` as expressed by the kind - /// of origin `origin_type`. - /// - /// - `origin_type`: The means of expressing the message origin as a dispatch origin. - /// - `max_weight`: The weight of `call`; this should be at least the chain's calculated weight and will - /// be used in the weight determination arithmetic. - /// - `call`: The encoded transaction to be applied. - /// - /// Safety: No concerns. - /// - /// Kind: *Instruction*. - /// - /// Errors: - #[codec(index = 6)] - Transact { origin_type: OriginKind, require_weight_at_most: u64, call: DoubleEncoded }, - - /// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the - /// relay-chain to a para. - /// - /// - `sender`: The sender in the to-be opened channel. Also, the initiator of the channel opening. - /// - `max_message_size`: The maximum size of a message proposed by the sender. - /// - `max_capacity`: The maximum number of messages that can be queued in the channel. - /// - /// Safety: The message should originate directly from the relay-chain. - /// - /// Kind: *System Notification* - #[codec(index = 7)] - HrmpNewChannelOpenRequest { - #[codec(compact)] - sender: u32, - #[codec(compact)] - max_message_size: u32, - #[codec(compact)] - max_capacity: u32, - }, - - /// A message to notify about that a previously sent open channel request has been accepted by - /// the recipient. That means that the channel will be opened during the next relay-chain session - /// change. This message is meant to be sent by the relay-chain to a para. - /// - /// Safety: The message should originate directly from the relay-chain. - /// - /// Kind: *System Notification* - /// - /// Errors: - #[codec(index = 8)] - HrmpChannelAccepted { - #[codec(compact)] - recipient: u32, - }, - - /// A message to notify that the other party in an open channel decided to close it. In particular, - /// `initiator` is going to close the channel opened from `sender` to the `recipient`. The close - /// will be enacted at the next relay-chain session change. This message is meant to be sent by - /// the relay-chain to a para. - /// - /// Safety: The message should originate directly from the relay-chain. - /// - /// Kind: *System Notification* - /// - /// Errors: - #[codec(index = 9)] - HrmpChannelClosing { - #[codec(compact)] - initiator: u32, - #[codec(compact)] - sender: u32, - #[codec(compact)] - recipient: u32, - }, - - /// A message to indicate that the embedded XCM is actually arriving on behalf of some consensus - /// location within the origin. - /// - /// Safety: `who` must be an interior location of the context. This basically means that no `Parent` - /// junctions are allowed in it. This should be verified at the time of XCM execution. - /// - /// Kind: *Instruction* - /// - /// Errors: - #[codec(index = 10)] - RelayedFrom { who: MultiLocation, message: alloc::boxed::Box> }, -} - -impl Xcm { - pub fn into(self) -> Xcm { - Xcm::from(self) - } - pub fn from(xcm: Xcm) -> Self { - use Xcm::*; - match xcm { - WithdrawAsset { assets, effects } => - WithdrawAsset { assets, effects: effects.into_iter().map(Order::into).collect() }, - ReserveAssetDeposit { assets, effects } => ReserveAssetDeposit { - assets, - effects: effects.into_iter().map(Order::into).collect(), - }, - TeleportAsset { assets, effects } => - TeleportAsset { assets, effects: effects.into_iter().map(Order::into).collect() }, - QueryResponse { query_id, response } => QueryResponse { query_id, response }, - TransferAsset { assets, dest } => TransferAsset { assets, dest }, - TransferReserveAsset { assets, dest, effects } => - TransferReserveAsset { assets, dest, effects }, - HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => - HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, - HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient }, - HrmpChannelClosing { initiator, sender, recipient } => - HrmpChannelClosing { initiator, sender, recipient }, - Transact { origin_type, require_weight_at_most, call } => - Transact { origin_type, require_weight_at_most, call: call.into() }, - RelayedFrom { who, message } => - RelayedFrom { who, message: alloc::boxed::Box::new((*message).into()) }, - } - } -} - -pub mod opaque { - /// The basic concrete type of `generic::Xcm`, which doesn't make any assumptions about the format of a - /// call other than it is pre-encoded. - pub type Xcm = super::Xcm<()>; - - pub use super::order::opaque::*; -} - -// Convert from a v1 response to a v0 response -impl TryFrom for Response { - type Error = (); - fn try_from(new_response: Response1) -> result::Result { - Ok(match new_response { - Response1::Assets(assets) => Self::Assets(assets.try_into()?), - Response1::Version(..) => return Err(()), - }) - } -} - -impl TryFrom> for Xcm { - type Error = (); - fn try_from(x: Xcm1) -> result::Result, ()> { - use Xcm::*; - Ok(match x { - Xcm1::WithdrawAsset { assets, effects } => WithdrawAsset { - assets: assets.try_into()?, - effects: effects - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - Xcm1::ReserveAssetDeposited { assets, effects } => ReserveAssetDeposit { - assets: assets.try_into()?, - effects: effects - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - Xcm1::ReceiveTeleportedAsset { assets, effects } => TeleportAsset { - assets: assets.try_into()?, - effects: effects - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - Xcm1::QueryResponse { query_id, response } => - QueryResponse { query_id, response: response.try_into()? }, - Xcm1::TransferAsset { assets, beneficiary } => - TransferAsset { assets: assets.try_into()?, dest: beneficiary.try_into()? }, - Xcm1::TransferReserveAsset { assets, dest, effects } => TransferReserveAsset { - assets: assets.try_into()?, - dest: dest.try_into()?, - effects: effects - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - Xcm1::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => - HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, - Xcm1::HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient }, - Xcm1::HrmpChannelClosing { initiator, sender, recipient } => - HrmpChannelClosing { initiator, sender, recipient }, - Xcm1::Transact { origin_type, require_weight_at_most, call } => - Transact { origin_type, require_weight_at_most, call: call.into() }, - Xcm1::RelayedFrom { who, message } => RelayedFrom { - who: MultiLocation1 { interior: who, parents: 0 }.try_into()?, - message: alloc::boxed::Box::new((*message).try_into()?), - }, - Xcm1::SubscribeVersion { .. } | Xcm1::UnsubscribeVersion => return Err(()), - }) - } -} diff --git a/xcm/src/v0/multi_asset.rs b/xcm/src/v0/multi_asset.rs deleted file mode 100644 index dac5a6bfeb7e..000000000000 --- a/xcm/src/v0/multi_asset.rs +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright 2020 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 . - -//! Cross-Consensus Message format data structures. - -use super::MultiLocation; -use crate::v1::{MultiAssetFilter, MultiAssets, WildMultiAsset}; -use alloc::{vec, vec::Vec}; -use core::{ - convert::{TryFrom, TryInto}, - result, -}; -use parity_scale_codec::{self, Decode, Encode}; -use scale_info::TypeInfo; - -pub use crate::v1::AssetInstance; - -/// A single general identifier for an asset. -/// -/// Represents both fungible and non-fungible assets. May only be used to represent a single asset class. -/// -/// Wildcards may or may not be allowed by the interpreting context. -/// -/// Assets classes may be identified in one of two ways: either an abstract identifier or a concrete identifier. -/// Implementations may support only one of these. A single asset may be referenced from multiple asset identifiers, -/// though will tend to have only a single *preferred* identifier. -/// -/// ### Abstract identifiers -/// -/// Abstract identifiers are absolute identifiers that represent a notional asset which can exist within multiple -/// consensus systems. These tend to be simpler to deal with since their broad meaning is unchanged regardless stay of -/// the consensus system in which it is interpreted. -/// -/// However, in the attempt to provide uniformity across consensus systems, they may conflate different instantiations -/// of some notional asset (e.g. the reserve asset and a local reserve-backed derivative of it) under the same name, -/// leading to confusion. It also implies that one notional asset is accounted for locally in only one way. This may not -/// be the case, e.g. where there are multiple bridge instances each providing a bridged "BTC" token yet none being -/// fungible between the others. -/// -/// Since they are meant to be absolute and universal, a global registry is needed to ensure that name collisions do not -/// occur. -/// -/// An abstract identifier is represented as a simple variable-size byte string. As of writing, no global registry -/// exists and no proposals have been put forth for asset labeling. -/// -/// ### Concrete identifiers -/// -/// Concrete identifiers are *relative identifiers* that specifically identify a single asset through its location in a -/// consensus system relative to the context interpreting. Use of a `MultiLocation` ensures that similar but non -/// fungible variants of the same underlying asset can be properly distinguished, and obviates the need for any kind of -/// central registry. -/// -/// The limitation is that the asset identifier cannot be trivially copied between consensus systems and must instead be -/// "re-anchored" whenever being moved to a new consensus system, using the two systems' relative paths. -/// -/// Throughout XCM, messages are authored such that *when interpreted from the receiver's point of view* they will have -/// the desired meaning/effect. This means that relative paths should always by constructed to be read from the point of -/// view of the receiving system, *which may be have a completely different meaning in the authoring system*. -/// -/// Concrete identifiers are the preferred way of identifying an asset since they are entirely unambiguous. -/// -/// A concrete identifier is represented by a `MultiLocation`. If a system has an unambiguous primary asset (such as -/// Bitcoin with BTC or Ethereum with ETH), then it will conventionally be identified as the chain itself. Alternative -/// and more specific ways of referring to an asset within a system include: -/// -/// - `/PalletInstance()` for a Frame chain with a single-asset pallet instance (such as an instance of the -/// Balances pallet). -/// - `/PalletInstance()/GeneralIndex()` for a Frame chain with an indexed multi-asset pallet instance -/// (such as an instance of the Assets pallet). -/// - `/AccountId32` for an ERC-20-style single-asset smart-contract on a Frame-based contracts chain. -/// - `/AccountKey20` for an ERC-20-style single-asset smart-contract on an Ethereum-like chain. -/// -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] -pub enum MultiAsset { - /// No assets. Rarely used. - None, - - /// All assets. Typically used for the subset of assets to be used for an `Order`, and in that context means - /// "all assets currently in holding". - All, - - /// All fungible assets. Typically used for the subset of assets to be used for an `Order`, and in that context - /// means "all fungible assets currently in holding". - AllFungible, - - /// All non-fungible assets. Typically used for the subset of assets to be used for an `Order`, and in that - /// context means "all non-fungible assets currently in holding". - AllNonFungible, - - /// All fungible assets of a given abstract asset `id`entifier. - AllAbstractFungible { id: Vec }, - - /// All non-fungible assets of a given abstract asset `class`. - AllAbstractNonFungible { class: Vec }, - - /// All fungible assets of a given concrete asset `id`entifier. - AllConcreteFungible { id: MultiLocation }, - - /// All non-fungible assets of a given concrete asset `class`. - AllConcreteNonFungible { class: MultiLocation }, - - /// Some specific `amount` of the fungible asset identified by an abstract `id`. - AbstractFungible { - id: Vec, - #[codec(compact)] - amount: u128, - }, - - /// Some specific `instance` of the non-fungible asset whose `class` is identified abstractly. - AbstractNonFungible { class: Vec, instance: AssetInstance }, - - /// Some specific `amount` of the fungible asset identified by an concrete `id`. - ConcreteFungible { - id: MultiLocation, - #[codec(compact)] - amount: u128, - }, - - /// Some specific `instance` of the non-fungible asset whose `class` is identified concretely. - ConcreteNonFungible { class: MultiLocation, instance: AssetInstance }, -} - -impl MultiAsset { - /// Returns `true` if the `MultiAsset` is a wildcard and can refer to classes of assets, instead of just one. - /// - /// Typically can also be inferred by the name starting with `All`. - pub fn is_wildcard(&self) -> bool { - match self { - MultiAsset::None | - MultiAsset::AbstractFungible { .. } | - MultiAsset::AbstractNonFungible { .. } | - MultiAsset::ConcreteFungible { .. } | - MultiAsset::ConcreteNonFungible { .. } => false, - - MultiAsset::All | - MultiAsset::AllFungible | - MultiAsset::AllNonFungible | - MultiAsset::AllAbstractFungible { .. } | - MultiAsset::AllConcreteFungible { .. } | - MultiAsset::AllAbstractNonFungible { .. } | - MultiAsset::AllConcreteNonFungible { .. } => true, - } - } - - fn is_none(&self) -> bool { - match self { - MultiAsset::None | - MultiAsset::AbstractFungible { amount: 0, .. } | - MultiAsset::ConcreteFungible { amount: 0, .. } => true, - - _ => false, - } - } - - fn is_fungible(&self) -> bool { - match self { - MultiAsset::All | - MultiAsset::AllFungible | - MultiAsset::AllAbstractFungible { .. } | - MultiAsset::AllConcreteFungible { .. } | - MultiAsset::AbstractFungible { .. } | - MultiAsset::ConcreteFungible { .. } => true, - - _ => false, - } - } - - fn is_non_fungible(&self) -> bool { - match self { - MultiAsset::All | - MultiAsset::AllNonFungible | - MultiAsset::AllAbstractNonFungible { .. } | - MultiAsset::AllConcreteNonFungible { .. } | - MultiAsset::AbstractNonFungible { .. } | - MultiAsset::ConcreteNonFungible { .. } => true, - - _ => false, - } - } - - fn is_concrete_fungible(&self, id: &MultiLocation) -> bool { - match self { - MultiAsset::AllFungible => true, - MultiAsset::AllConcreteFungible { id: i } | - MultiAsset::ConcreteFungible { id: i, .. } => i == id, - - _ => false, - } - } - - fn is_abstract_fungible(&self, id: &[u8]) -> bool { - match self { - MultiAsset::AllFungible => true, - MultiAsset::AllAbstractFungible { id: i } | - MultiAsset::AbstractFungible { id: i, .. } => i == id, - _ => false, - } - } - - fn is_concrete_non_fungible(&self, class: &MultiLocation) -> bool { - match self { - MultiAsset::AllNonFungible => true, - MultiAsset::AllConcreteNonFungible { class: i } | - MultiAsset::ConcreteNonFungible { class: i, .. } => i == class, - _ => false, - } - } - - fn is_abstract_non_fungible(&self, class: &[u8]) -> bool { - match self { - MultiAsset::AllNonFungible => true, - MultiAsset::AllAbstractNonFungible { class: i } | - MultiAsset::AbstractNonFungible { class: i, .. } => i == class, - _ => false, - } - } - - fn is_all(&self) -> bool { - matches!(self, MultiAsset::All) - } - - /// Returns true if `self` is a super-set of the given `inner`. - /// - /// Typically, any wildcard is never contained in anything else, and a wildcard can contain any other non-wildcard. - /// For more details, see the implementation and tests. - pub fn contains(&self, inner: &MultiAsset) -> bool { - use MultiAsset::*; - - // Inner cannot be wild - if inner.is_wildcard() { - return false - } - // Everything contains nothing. - if inner.is_none() { - return true - } - - // Everything contains anything. - if self.is_all() { - return true - } - // Nothing contains nothing. - if self.is_none() { - return false - } - - match self { - // Anything fungible contains "all fungibles" - AllFungible => inner.is_fungible(), - // Anything non-fungible contains "all non-fungibles" - AllNonFungible => inner.is_non_fungible(), - - AllConcreteFungible { id } => inner.is_concrete_fungible(id), - AllAbstractFungible { id } => inner.is_abstract_fungible(id), - AllConcreteNonFungible { class } => inner.is_concrete_non_fungible(class), - AllAbstractNonFungible { class } => inner.is_abstract_non_fungible(class), - - ConcreteFungible { id, amount } => matches!( - inner, - ConcreteFungible { id: inner_id , amount: inner_amount } if inner_id == id && amount >= inner_amount - ), - AbstractFungible { id, amount } => matches!( - inner, - AbstractFungible { id: inner_id , amount: inner_amount } if inner_id == id && amount >= inner_amount - ), - ConcreteNonFungible { .. } => self == inner, - AbstractNonFungible { .. } => self == inner, - _ => false, - } - } - - pub fn reanchor(&mut self, prepend: &MultiLocation) -> Result<(), ()> { - use MultiAsset::*; - match self { - AllConcreteFungible { ref mut id } | - AllConcreteNonFungible { class: ref mut id } | - ConcreteFungible { ref mut id, .. } | - ConcreteNonFungible { class: ref mut id, .. } => - id.prepend_with(prepend.clone()).map_err(|_| ()), - _ => Ok(()), - } - } -} - -impl TryFrom for MultiAsset { - type Error = (); - - fn try_from(m: crate::v1::MultiAsset) -> result::Result { - use crate::v1::{AssetId::*, Fungibility::*}; - use MultiAsset::*; - Ok(match (m.id, m.fun) { - (Concrete(id), Fungible(amount)) => ConcreteFungible { id: id.try_into()?, amount }, - (Concrete(class), NonFungible(instance)) => - ConcreteNonFungible { class: class.try_into()?, instance }, - (Abstract(id), Fungible(amount)) => AbstractFungible { id, amount }, - (Abstract(class), NonFungible(instance)) => AbstractNonFungible { class, instance }, - }) - } -} - -impl TryFrom for Vec { - type Error = (); - - fn try_from(m: MultiAssets) -> result::Result, ()> { - m.drain().into_iter().map(MultiAsset::try_from).collect() - } -} - -impl TryFrom for MultiAsset { - type Error = (); - - fn try_from(m: WildMultiAsset) -> result::Result { - use crate::v1::{AssetId::*, WildFungibility::*}; - use MultiAsset::*; - Ok(match m { - WildMultiAsset::All => All, - WildMultiAsset::AllOf { id, fun } => match (id, fun) { - (Concrete(id), Fungible) => AllConcreteFungible { id: id.try_into()? }, - (Concrete(class), NonFungible) => - AllConcreteNonFungible { class: class.try_into()? }, - (Abstract(id), Fungible) => AllAbstractFungible { id }, - (Abstract(class), NonFungible) => AllAbstractNonFungible { class }, - }, - }) - } -} - -impl TryFrom for Vec { - type Error = (); - - fn try_from(m: WildMultiAsset) -> result::Result, ()> { - Ok(vec![m.try_into()?]) - } -} - -impl TryFrom for Vec { - type Error = (); - - fn try_from(m: MultiAssetFilter) -> result::Result, ()> { - match m { - MultiAssetFilter::Definite(assets) => assets.try_into(), - MultiAssetFilter::Wild(wildcard) => wildcard.try_into(), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn contains_works() { - use alloc::vec; - use MultiAsset::*; - // trivial case: all contains any non-wildcard. - assert!(All.contains(&None)); - assert!(All.contains(&AbstractFungible { id: alloc::vec![99u8], amount: 1 })); - - // trivial case: none contains nothing, except itself. - assert!(None.contains(&None)); - assert!(!None.contains(&AllFungible)); - assert!(!None.contains(&All)); - - // A bit more sneaky: Nothing can contain wildcard, even All ir the thing itself. - assert!(!All.contains(&All)); - assert!(!All.contains(&AllFungible)); - assert!(!AllFungible.contains(&AllFungible)); - assert!(!AllNonFungible.contains(&AllNonFungible)); - - // For fungibles, containing is basically equality, or equal id with higher amount. - assert!(!AbstractFungible { id: vec![99u8], amount: 99 } - .contains(&AbstractFungible { id: vec![1u8], amount: 99 })); - assert!(AbstractFungible { id: vec![99u8], amount: 99 } - .contains(&AbstractFungible { id: vec![99u8], amount: 99 })); - assert!(AbstractFungible { id: vec![99u8], amount: 99 } - .contains(&AbstractFungible { id: vec![99u8], amount: 9 })); - assert!(!AbstractFungible { id: vec![99u8], amount: 99 } - .contains(&AbstractFungible { id: vec![99u8], amount: 100 })); - - // For non-fungibles, containing is equality. - assert!(!AbstractNonFungible { class: vec![99u8], instance: AssetInstance::Index(9) } - .contains(&AbstractNonFungible { - class: vec![98u8], - instance: AssetInstance::Index(9) - })); - assert!(!AbstractNonFungible { class: vec![99u8], instance: AssetInstance::Index(8) } - .contains(&AbstractNonFungible { - class: vec![99u8], - instance: AssetInstance::Index(9) - })); - assert!(AbstractNonFungible { class: vec![99u8], instance: AssetInstance::Index(9) } - .contains(&AbstractNonFungible { - class: vec![99u8], - instance: AssetInstance::Index(9) - })); - } -} diff --git a/xcm/src/v0/multi_location.rs b/xcm/src/v0/multi_location.rs deleted file mode 100644 index 0df525f06577..000000000000 --- a/xcm/src/v0/multi_location.rs +++ /dev/null @@ -1,728 +0,0 @@ -// Copyright 2020-2021 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 . - -//! Cross-Consensus Message format data structures. - -use super::Junction; -use core::{mem, result}; -use parity_scale_codec::{self, Decode, Encode}; - -/// A relative path between state-bearing consensus systems. -/// -/// A location in a consensus system is defined as an *isolatable state machine* held within global consensus. The -/// location in question need not have a sophisticated consensus algorithm of its own; a single account within -/// Ethereum, for example, could be considered a location. -/// -/// A very-much non-exhaustive list of types of location include: -/// - A (normal, layer-1) block chain, e.g. the Bitcoin mainnet or a parachain. -/// - A layer-0 super-chain, e.g. the Polkadot Relay chain. -/// - A layer-2 smart contract, e.g. an ERC-20 on Ethereum. -/// - A logical functional component of a chain, e.g. a single instance of a pallet on a Frame-based Substrate chain. -/// - An account. -/// -/// A `MultiLocation` is a *relative identifier*, meaning that it can only be used to define the relative path -/// between two locations, and cannot generally be used to refer to a location universally. It is comprised of a -/// number of *junctions*, each morphing the previous location, either diving down into one of its internal locations, -/// called a *sub-consensus*, or going up into its parent location. Correct `MultiLocation` values must have all -/// `Parent` junctions as a prefix to all *sub-consensus* junctions. -/// -/// This specific `MultiLocation` implementation uses a Rust `enum` in order to make pattern matching easier. -/// -/// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, scale_info::TypeInfo)] -pub enum MultiLocation { - /// The interpreting consensus system. - Null, - /// A relative path comprising 1 junction. - X1(Junction), - /// A relative path comprising 2 junctions. - X2(Junction, Junction), - /// A relative path comprising 3 junctions. - X3(Junction, Junction, Junction), - /// A relative path comprising 4 junctions. - X4(Junction, Junction, Junction, Junction), - /// A relative path comprising 5 junctions. - X5(Junction, Junction, Junction, Junction, Junction), - /// A relative path comprising 6 junctions. - X6(Junction, Junction, Junction, Junction, Junction, Junction), - /// A relative path comprising 7 junctions. - X7(Junction, Junction, Junction, Junction, Junction, Junction, Junction), - /// A relative path comprising 8 junctions. - X8(Junction, Junction, Junction, Junction, Junction, Junction, Junction, Junction), -} - -/// Maximum number of junctions a `MultiLocation` can contain. -pub const MAX_MULTILOCATION_LENGTH: usize = 8; - -xcm_procedural::impl_conversion_functions_for_multilocation_v0!(); - -pub struct MultiLocationIterator(MultiLocation); -impl Iterator for MultiLocationIterator { - type Item = Junction; - fn next(&mut self) -> Option { - self.0.take_first() - } -} - -pub struct MultiLocationReverseIterator(MultiLocation); -impl Iterator for MultiLocationReverseIterator { - type Item = Junction; - fn next(&mut self) -> Option { - self.0.take_last() - } -} - -pub struct MultiLocationRefIterator<'a>(&'a MultiLocation, usize); -impl<'a> Iterator for MultiLocationRefIterator<'a> { - type Item = &'a Junction; - fn next(&mut self) -> Option<&'a Junction> { - let result = self.0.at(self.1); - self.1 += 1; - result - } -} - -pub struct MultiLocationReverseRefIterator<'a>(&'a MultiLocation, usize); -impl<'a> Iterator for MultiLocationReverseRefIterator<'a> { - type Item = &'a Junction; - fn next(&mut self) -> Option<&'a Junction> { - self.1 += 1; - self.0.at(self.0.len().checked_sub(self.1)?) - } -} - -impl MultiLocation { - /// Returns first junction, or `None` if the location is empty. - pub fn first(&self) -> Option<&Junction> { - match &self { - MultiLocation::Null => None, - MultiLocation::X1(ref a) => Some(a), - MultiLocation::X2(ref a, ..) => Some(a), - MultiLocation::X3(ref a, ..) => Some(a), - MultiLocation::X4(ref a, ..) => Some(a), - MultiLocation::X5(ref a, ..) => Some(a), - MultiLocation::X6(ref a, ..) => Some(a), - MultiLocation::X7(ref a, ..) => Some(a), - MultiLocation::X8(ref a, ..) => Some(a), - } - } - - /// Returns last junction, or `None` if the location is empty. - pub fn last(&self) -> Option<&Junction> { - match &self { - MultiLocation::Null => None, - MultiLocation::X1(ref a) => Some(a), - MultiLocation::X2(.., ref a) => Some(a), - MultiLocation::X3(.., ref a) => Some(a), - MultiLocation::X4(.., ref a) => Some(a), - MultiLocation::X5(.., ref a) => Some(a), - MultiLocation::X6(.., ref a) => Some(a), - MultiLocation::X7(.., ref a) => Some(a), - MultiLocation::X8(.., ref a) => Some(a), - } - } - - /// Splits off the first junction, returning the remaining suffix (first item in tuple) and the first element - /// (second item in tuple) or `None` if it was empty. - pub fn split_first(self) -> (MultiLocation, Option) { - match self { - MultiLocation::Null => (MultiLocation::Null, None), - MultiLocation::X1(a) => (MultiLocation::Null, Some(a)), - MultiLocation::X2(a, b) => (MultiLocation::X1(b), Some(a)), - MultiLocation::X3(a, b, c) => (MultiLocation::X2(b, c), Some(a)), - MultiLocation::X4(a, b, c, d) => (MultiLocation::X3(b, c, d), Some(a)), - MultiLocation::X5(a, b, c, d, e) => (MultiLocation::X4(b, c, d, e), Some(a)), - MultiLocation::X6(a, b, c, d, e, f) => (MultiLocation::X5(b, c, d, e, f), Some(a)), - MultiLocation::X7(a, b, c, d, e, f, g) => - (MultiLocation::X6(b, c, d, e, f, g), Some(a)), - MultiLocation::X8(a, b, c, d, e, f, g, h) => - (MultiLocation::X7(b, c, d, e, f, g, h), Some(a)), - } - } - - /// Splits off the last junction, returning the remaining prefix (first item in tuple) and the last element - /// (second item in tuple) or `None` if it was empty. - pub fn split_last(self) -> (MultiLocation, Option) { - match self { - MultiLocation::Null => (MultiLocation::Null, None), - MultiLocation::X1(a) => (MultiLocation::Null, Some(a)), - MultiLocation::X2(a, b) => (MultiLocation::X1(a), Some(b)), - MultiLocation::X3(a, b, c) => (MultiLocation::X2(a, b), Some(c)), - MultiLocation::X4(a, b, c, d) => (MultiLocation::X3(a, b, c), Some(d)), - MultiLocation::X5(a, b, c, d, e) => (MultiLocation::X4(a, b, c, d), Some(e)), - MultiLocation::X6(a, b, c, d, e, f) => (MultiLocation::X5(a, b, c, d, e), Some(f)), - MultiLocation::X7(a, b, c, d, e, f, g) => - (MultiLocation::X6(a, b, c, d, e, f), Some(g)), - MultiLocation::X8(a, b, c, d, e, f, g, h) => - (MultiLocation::X7(a, b, c, d, e, f, g), Some(h)), - } - } - - /// Removes the first element from `self`, returning it (or `None` if it was empty). - pub fn take_first(&mut self) -> Option { - let mut d = MultiLocation::Null; - mem::swap(&mut *self, &mut d); - let (tail, head) = d.split_first(); - *self = tail; - head - } - - /// Removes the last element from `self`, returning it (or `None` if it was empty). - pub fn take_last(&mut self) -> Option { - let mut d = MultiLocation::Null; - mem::swap(&mut *self, &mut d); - let (head, tail) = d.split_last(); - *self = head; - tail - } - - /// Consumes `self` and returns a `MultiLocation` suffixed with `new`, or an `Err` with the original value of - /// `self` in case of overflow. - pub fn pushed_with(self, new: Junction) -> result::Result { - Ok(match self { - MultiLocation::Null => MultiLocation::X1(new), - MultiLocation::X1(a) => MultiLocation::X2(a, new), - MultiLocation::X2(a, b) => MultiLocation::X3(a, b, new), - MultiLocation::X3(a, b, c) => MultiLocation::X4(a, b, c, new), - MultiLocation::X4(a, b, c, d) => MultiLocation::X5(a, b, c, d, new), - MultiLocation::X5(a, b, c, d, e) => MultiLocation::X6(a, b, c, d, e, new), - MultiLocation::X6(a, b, c, d, e, f) => MultiLocation::X7(a, b, c, d, e, f, new), - MultiLocation::X7(a, b, c, d, e, f, g) => MultiLocation::X8(a, b, c, d, e, f, g, new), - s => Err(s)?, - }) - } - - /// Consumes `self` and returns a `MultiLocation` prefixed with `new`, or an `Err` with the original value of - /// `self` in case of overflow. - pub fn pushed_front_with(self, new: Junction) -> result::Result { - Ok(match self { - MultiLocation::Null => MultiLocation::X1(new), - MultiLocation::X1(a) => MultiLocation::X2(new, a), - MultiLocation::X2(a, b) => MultiLocation::X3(new, a, b), - MultiLocation::X3(a, b, c) => MultiLocation::X4(new, a, b, c), - MultiLocation::X4(a, b, c, d) => MultiLocation::X5(new, a, b, c, d), - MultiLocation::X5(a, b, c, d, e) => MultiLocation::X6(new, a, b, c, d, e), - MultiLocation::X6(a, b, c, d, e, f) => MultiLocation::X7(new, a, b, c, d, e, f), - MultiLocation::X7(a, b, c, d, e, f, g) => MultiLocation::X8(new, a, b, c, d, e, f, g), - s => Err(s)?, - }) - } - - /// Returns the number of junctions in `self`. - pub fn len(&self) -> usize { - match &self { - MultiLocation::Null => 0, - MultiLocation::X1(..) => 1, - MultiLocation::X2(..) => 2, - MultiLocation::X3(..) => 3, - MultiLocation::X4(..) => 4, - MultiLocation::X5(..) => 5, - MultiLocation::X6(..) => 6, - MultiLocation::X7(..) => 7, - MultiLocation::X8(..) => 8, - } - } - - /// Returns the junction at index `i`, or `None` if the location doesn't contain that many elements. - pub fn at(&self, i: usize) -> Option<&Junction> { - Some(match (i, &self) { - (0, MultiLocation::X1(ref a)) => a, - (0, MultiLocation::X2(ref a, ..)) => a, - (0, MultiLocation::X3(ref a, ..)) => a, - (0, MultiLocation::X4(ref a, ..)) => a, - (0, MultiLocation::X5(ref a, ..)) => a, - (0, MultiLocation::X6(ref a, ..)) => a, - (0, MultiLocation::X7(ref a, ..)) => a, - (0, MultiLocation::X8(ref a, ..)) => a, - (1, MultiLocation::X2(_, ref a)) => a, - (1, MultiLocation::X3(_, ref a, ..)) => a, - (1, MultiLocation::X4(_, ref a, ..)) => a, - (1, MultiLocation::X5(_, ref a, ..)) => a, - (1, MultiLocation::X6(_, ref a, ..)) => a, - (1, MultiLocation::X7(_, ref a, ..)) => a, - (1, MultiLocation::X8(_, ref a, ..)) => a, - (2, MultiLocation::X3(_, _, ref a)) => a, - (2, MultiLocation::X4(_, _, ref a, ..)) => a, - (2, MultiLocation::X5(_, _, ref a, ..)) => a, - (2, MultiLocation::X6(_, _, ref a, ..)) => a, - (2, MultiLocation::X7(_, _, ref a, ..)) => a, - (2, MultiLocation::X8(_, _, ref a, ..)) => a, - (3, MultiLocation::X4(_, _, _, ref a)) => a, - (3, MultiLocation::X5(_, _, _, ref a, ..)) => a, - (3, MultiLocation::X6(_, _, _, ref a, ..)) => a, - (3, MultiLocation::X7(_, _, _, ref a, ..)) => a, - (3, MultiLocation::X8(_, _, _, ref a, ..)) => a, - (4, MultiLocation::X5(_, _, _, _, ref a)) => a, - (4, MultiLocation::X6(_, _, _, _, ref a, ..)) => a, - (4, MultiLocation::X7(_, _, _, _, ref a, ..)) => a, - (4, MultiLocation::X8(_, _, _, _, ref a, ..)) => a, - (5, MultiLocation::X6(_, _, _, _, _, ref a)) => a, - (5, MultiLocation::X7(_, _, _, _, _, ref a, ..)) => a, - (5, MultiLocation::X8(_, _, _, _, _, ref a, ..)) => a, - (6, MultiLocation::X7(_, _, _, _, _, _, ref a)) => a, - (6, MultiLocation::X8(_, _, _, _, _, _, ref a, ..)) => a, - (7, MultiLocation::X8(_, _, _, _, _, _, _, ref a)) => a, - _ => return None, - }) - } - - /// Returns a mutable reference to the junction at index `i`, or `None` if the location doesn't contain that many - /// elements. - pub fn at_mut(&mut self, i: usize) -> Option<&mut Junction> { - Some(match (i, self) { - (0, MultiLocation::X1(ref mut a)) => a, - (0, MultiLocation::X2(ref mut a, ..)) => a, - (0, MultiLocation::X3(ref mut a, ..)) => a, - (0, MultiLocation::X4(ref mut a, ..)) => a, - (0, MultiLocation::X5(ref mut a, ..)) => a, - (0, MultiLocation::X6(ref mut a, ..)) => a, - (0, MultiLocation::X7(ref mut a, ..)) => a, - (0, MultiLocation::X8(ref mut a, ..)) => a, - (1, MultiLocation::X2(_, ref mut a)) => a, - (1, MultiLocation::X3(_, ref mut a, ..)) => a, - (1, MultiLocation::X4(_, ref mut a, ..)) => a, - (1, MultiLocation::X5(_, ref mut a, ..)) => a, - (1, MultiLocation::X6(_, ref mut a, ..)) => a, - (1, MultiLocation::X7(_, ref mut a, ..)) => a, - (1, MultiLocation::X8(_, ref mut a, ..)) => a, - (2, MultiLocation::X3(_, _, ref mut a)) => a, - (2, MultiLocation::X4(_, _, ref mut a, ..)) => a, - (2, MultiLocation::X5(_, _, ref mut a, ..)) => a, - (2, MultiLocation::X6(_, _, ref mut a, ..)) => a, - (2, MultiLocation::X7(_, _, ref mut a, ..)) => a, - (2, MultiLocation::X8(_, _, ref mut a, ..)) => a, - (3, MultiLocation::X4(_, _, _, ref mut a)) => a, - (3, MultiLocation::X5(_, _, _, ref mut a, ..)) => a, - (3, MultiLocation::X6(_, _, _, ref mut a, ..)) => a, - (3, MultiLocation::X7(_, _, _, ref mut a, ..)) => a, - (3, MultiLocation::X8(_, _, _, ref mut a, ..)) => a, - (4, MultiLocation::X5(_, _, _, _, ref mut a)) => a, - (4, MultiLocation::X6(_, _, _, _, ref mut a, ..)) => a, - (4, MultiLocation::X7(_, _, _, _, ref mut a, ..)) => a, - (4, MultiLocation::X8(_, _, _, _, ref mut a, ..)) => a, - (5, MultiLocation::X6(_, _, _, _, _, ref mut a)) => a, - (5, MultiLocation::X7(_, _, _, _, _, ref mut a, ..)) => a, - (5, MultiLocation::X8(_, _, _, _, _, ref mut a, ..)) => a, - (6, MultiLocation::X7(_, _, _, _, _, _, ref mut a)) => a, - (6, MultiLocation::X8(_, _, _, _, _, _, ref mut a, ..)) => a, - (7, MultiLocation::X8(_, _, _, _, _, _, _, ref mut a)) => a, - _ => return None, - }) - } - - /// Returns a reference iterator over the junctions. - pub fn iter(&self) -> MultiLocationRefIterator { - MultiLocationRefIterator(&self, 0) - } - - /// Returns a reference iterator over the junctions in reverse. - pub fn iter_rev(&self) -> MultiLocationReverseRefIterator { - MultiLocationReverseRefIterator(&self, 0) - } - - /// Consumes `self` and returns an iterator over the junctions. - pub fn into_iter(self) -> MultiLocationIterator { - MultiLocationIterator(self) - } - - /// Consumes `self` and returns an iterator over the junctions in reverse. - pub fn into_iter_rev(self) -> MultiLocationReverseIterator { - MultiLocationReverseIterator(self) - } - - /// Ensures that self begins with `prefix` and that it has a single `Junction` item following. - /// If so, returns a reference to this `Junction` item. - /// - /// # Example - /// ```rust - /// # use xcm::v0::{MultiLocation::*, Junction::*}; - /// # fn main() { - /// let mut m = X3(Parent, PalletInstance(3), OnlyChild); - /// assert_eq!(m.match_and_split(&X2(Parent, PalletInstance(3))), Some(&OnlyChild)); - /// assert_eq!(m.match_and_split(&X1(Parent)), None); - /// # } - /// ``` - pub fn match_and_split(&self, prefix: &MultiLocation) -> Option<&Junction> { - if prefix.len() + 1 != self.len() || !self.starts_with(prefix) { - return None - } - return self.at(prefix.len()) - } - - /// Returns whether `self` begins with or is equal to `prefix`. - /// - /// # Example - /// ```rust - /// # use xcm::v0::{Junction::*, MultiLocation::*}; - /// let m = X4(Parent, PalletInstance(3), OnlyChild, OnlyChild); - /// assert!(m.starts_with(&X2(Parent, PalletInstance(3)))); - /// assert!(m.starts_with(&m)); - /// assert!(!m.starts_with(&X2(Parent, GeneralIndex(99)))); - /// assert!(!m.starts_with(&X1(PalletInstance(3)))); - /// ``` - pub fn starts_with(&self, prefix: &MultiLocation) -> bool { - if self.len() < prefix.len() { - return false - } - prefix.iter().zip(self.iter()).all(|(l, r)| l == r) - } - - /// Mutates `self`, suffixing it with `new`. Returns `Err` in case of overflow. - pub fn push(&mut self, new: Junction) -> result::Result<(), ()> { - let mut n = MultiLocation::Null; - mem::swap(&mut *self, &mut n); - match n.pushed_with(new) { - Ok(result) => { - *self = result; - Ok(()) - }, - Err(old) => { - *self = old; - Err(()) - }, - } - } - - /// Mutates `self`, prefixing it with `new`. Returns `Err` in case of overflow. - pub fn push_front(&mut self, new: Junction) -> result::Result<(), ()> { - let mut n = MultiLocation::Null; - mem::swap(&mut *self, &mut n); - match n.pushed_front_with(new) { - Ok(result) => { - *self = result; - Ok(()) - }, - Err(old) => { - *self = old; - Err(()) - }, - } - } - - /// Returns the number of `Parent` junctions at the beginning of `self`. - pub fn leading_parent_count(&self) -> usize { - use Junction::Parent; - match self { - MultiLocation::X8(Parent, Parent, Parent, Parent, Parent, Parent, Parent, Parent) => 8, - - MultiLocation::X8(Parent, Parent, Parent, Parent, Parent, Parent, Parent, ..) => 7, - MultiLocation::X7(Parent, Parent, Parent, Parent, Parent, Parent, Parent) => 7, - - MultiLocation::X8(Parent, Parent, Parent, Parent, Parent, Parent, ..) => 6, - MultiLocation::X7(Parent, Parent, Parent, Parent, Parent, Parent, ..) => 6, - MultiLocation::X6(Parent, Parent, Parent, Parent, Parent, Parent) => 6, - - MultiLocation::X8(Parent, Parent, Parent, Parent, Parent, ..) => 5, - MultiLocation::X7(Parent, Parent, Parent, Parent, Parent, ..) => 5, - MultiLocation::X6(Parent, Parent, Parent, Parent, Parent, ..) => 5, - MultiLocation::X5(Parent, Parent, Parent, Parent, Parent) => 5, - - MultiLocation::X8(Parent, Parent, Parent, Parent, ..) => 4, - MultiLocation::X7(Parent, Parent, Parent, Parent, ..) => 4, - MultiLocation::X6(Parent, Parent, Parent, Parent, ..) => 4, - MultiLocation::X5(Parent, Parent, Parent, Parent, ..) => 4, - MultiLocation::X4(Parent, Parent, Parent, Parent) => 4, - - MultiLocation::X8(Parent, Parent, Parent, ..) => 3, - MultiLocation::X7(Parent, Parent, Parent, ..) => 3, - MultiLocation::X6(Parent, Parent, Parent, ..) => 3, - MultiLocation::X5(Parent, Parent, Parent, ..) => 3, - MultiLocation::X4(Parent, Parent, Parent, ..) => 3, - MultiLocation::X3(Parent, Parent, Parent) => 3, - - MultiLocation::X8(Parent, Parent, ..) => 2, - MultiLocation::X7(Parent, Parent, ..) => 2, - MultiLocation::X6(Parent, Parent, ..) => 2, - MultiLocation::X5(Parent, Parent, ..) => 2, - MultiLocation::X4(Parent, Parent, ..) => 2, - MultiLocation::X3(Parent, Parent, ..) => 2, - MultiLocation::X2(Parent, Parent) => 2, - - MultiLocation::X8(Parent, ..) => 1, - MultiLocation::X7(Parent, ..) => 1, - MultiLocation::X6(Parent, ..) => 1, - MultiLocation::X5(Parent, ..) => 1, - MultiLocation::X4(Parent, ..) => 1, - MultiLocation::X3(Parent, ..) => 1, - MultiLocation::X2(Parent, ..) => 1, - MultiLocation::X1(Parent) => 1, - _ => 0, - } - } - - /// This function ensures a multi-junction is in its canonicalized/normalized form, removing - /// any internal `[Non-Parent, Parent]` combinations. - pub fn canonicalize(&mut self) { - let mut normalized = MultiLocation::Null; - let mut iter = self.iter(); - // We build up the the new normalized path by taking items from the original multi-location. - // When the next item we would add is `Parent`, we instead remove the last item assuming - // it is non-parent. - const EXPECT_MESSAGE: &'static str = - "`self` is a well formed multi-location with N junctions; \ - this loop iterates over the junctions of `self`; \ - the loop can push to the new multi-location at most one time; \ - thus the size of the new multi-location is at most N junctions; \ - qed"; - while let Some(j) = iter.next() { - if j == &Junction::Parent { - match normalized.last() { - None | Some(Junction::Parent) => {}, - Some(_) => { - normalized.take_last(); - continue - }, - } - } - - normalized.push(j.clone()).expect(EXPECT_MESSAGE); - } - - core::mem::swap(self, &mut normalized); - } - - /// Mutate `self` so that it is suffixed with `suffix`. The correct normalized form is returned, - /// removing any internal `[Non-Parent, Parent]` combinations. - /// - /// In the case of overflow, `self` is unmodified and we return `Err` with `suffix`. - /// - /// # Example - /// ```rust - /// # use xcm::v0::{MultiLocation::*, Junction::*}; - /// # fn main() { - /// let mut m = X3(Parent, Parachain(21), OnlyChild); - /// assert_eq!(m.append_with(X2(Parent, PalletInstance(3))), Ok(())); - /// assert_eq!(m, X3(Parent, Parachain(21), PalletInstance(3))); - /// # } - /// ``` - pub fn append_with(&mut self, suffix: MultiLocation) -> Result<(), MultiLocation> { - let mut prefix = suffix; - core::mem::swap(self, &mut prefix); - match self.prepend_with(prefix) { - Ok(()) => Ok(()), - Err(prefix) => { - let mut suffix = prefix; - core::mem::swap(self, &mut suffix); - Err(suffix) - }, - } - } - - /// Mutate `self` so that it is prefixed with `prefix`. The correct normalized form is returned, - /// removing any internal [Non-Parent, `Parent`] combinations. - /// - /// In the case of overflow, `self` is unmodified and we return `Err` with `prefix`. - /// - /// # Example - /// ```rust - /// # use xcm::v0::{MultiLocation::*, Junction::*, NetworkId::Any}; - /// # fn main() { - /// let mut m = X3(Parent, Parent, PalletInstance(3)); - /// assert_eq!(m.prepend_with(X3(Parent, Parachain(21), OnlyChild)), Ok(())); - /// assert_eq!(m, X2(Parent, PalletInstance(3))); - /// # } - /// ``` - pub fn prepend_with(&mut self, prefix: MultiLocation) -> Result<(), MultiLocation> { - let mut prefix = prefix; - - // This will guarantee that all `Parent` junctions in the prefix are leading, which is - // important for calculating the `skipped` items below. - prefix.canonicalize(); - - let self_leading_parents = self.leading_parent_count(); - // These are the number of `non-parent` items in the prefix that we can - // potentially remove if the original location leads with parents. - let prefix_rest = prefix.len() - prefix.leading_parent_count(); - // 2 * skipped items will be removed when performing the normalization below. - let skipped = self_leading_parents.min(prefix_rest); - - // Pre-pending this prefix would create a multi-location with too many junctions. - if self.len() + prefix.len() - 2 * skipped > MAX_MULTILOCATION_LENGTH { - return Err(prefix) - } - - // Here we cancel out `[Non-Parent, Parent]` items (normalization), where - // the non-parent item comes from the end of the prefix, and the parent item - // comes from the front of the original location. - // - // We calculated already how many of these there should be above. - for _ in 0..skipped { - let _non_parent = prefix.take_last(); - let _parent = self.take_first(); - debug_assert!( - _non_parent.is_some() && _non_parent != Some(Junction::Parent), - "prepend_with should always remove a non-parent from the end of the prefix", - ); - debug_assert!( - _parent == Some(Junction::Parent), - "prepend_with should always remove a parent from the front of the location", - ); - } - - for j in prefix.into_iter_rev() { - self.push_front(j) - .expect("len + prefix minus 2*skipped is less than max length; qed"); - } - Ok(()) - } - - /// Returns true iff `self` is an interior location. For this it may not contain any `Junction`s - /// for which `Junction::is_interior` returns `false`. This is generally true, except for the - /// `Parent` item. - /// - /// # Example - /// ```rust - /// # use xcm::v0::{MultiLocation::*, Junction::*, NetworkId::Any}; - /// # fn main() { - /// let parent = X1(Parent); - /// assert_eq!(parent.is_interior(), false); - /// let m = X2(PalletInstance(12), AccountIndex64 { network: Any, index: 23 }); - /// assert_eq!(m.is_interior(), true); - /// # } - /// ``` - pub fn is_interior(&self) -> bool { - self.iter().all(Junction::is_interior) - } -} - -#[cfg(test)] -mod tests { - use super::MultiLocation::{self, *}; - use crate::opaque::v0::{Junction::*, NetworkId::Any}; - - #[test] - fn match_and_split_works() { - let m = X3(Parent, Parachain(42), AccountIndex64 { network: Any, index: 23 }); - assert_eq!(m.match_and_split(&X1(Parent)), None); - assert_eq!( - m.match_and_split(&X2(Parent, Parachain(42))), - Some(&AccountIndex64 { network: Any, index: 23 }) - ); - assert_eq!(m.match_and_split(&m), None); - } - - #[test] - fn append_with_works() { - let acc = AccountIndex64 { network: Any, index: 23 }; - let mut m = X2(Parent, Parachain(42)); - assert_eq!(m.append_with(X2(PalletInstance(3), acc.clone())), Ok(())); - assert_eq!(m, X4(Parent, Parachain(42), PalletInstance(3), acc.clone())); - - // cannot append to create overly long multilocation - let acc = AccountIndex64 { network: Any, index: 23 }; - let mut m = X7(Parent, Parent, Parent, Parent, Parent, Parent, Parachain(42)); - let suffix = X2(PalletInstance(3), acc.clone()); - assert_eq!(m.append_with(suffix.clone()), Err(suffix)); - } - - #[test] - fn prepend_with_works() { - let mut m = X3(Parent, Parachain(42), AccountIndex64 { network: Any, index: 23 }); - assert_eq!(m.prepend_with(X2(Parent, OnlyChild)), Ok(())); - assert_eq!(m, X3(Parent, Parachain(42), AccountIndex64 { network: Any, index: 23 })); - - // cannot prepend to create overly long multilocation - let mut m = X7(Parent, Parent, Parent, Parent, Parent, Parent, Parachain(42)); - let prefix = X2(Parent, Parent); - assert_eq!(m.prepend_with(prefix.clone()), Err(prefix)); - - // Can handle shared prefix and resizing correctly. - let mut m = X1(Parent); - let prefix = X8( - Parachain(100), - OnlyChild, - OnlyChild, - OnlyChild, - OnlyChild, - OnlyChild, - OnlyChild, - Parent, - ); - assert_eq!(m.prepend_with(prefix.clone()), Ok(())); - assert_eq!(m, X5(Parachain(100), OnlyChild, OnlyChild, OnlyChild, OnlyChild)); - - let mut m = X1(Parent); - let prefix = X8(Parent, Parent, Parent, Parent, Parent, Parent, Parent, Parent); - assert_eq!(m.prepend_with(prefix.clone()), Err(prefix)); - - let mut m = X1(Parent); - let prefix = X7(Parent, Parent, Parent, Parent, Parent, Parent, Parent); - assert_eq!(m.prepend_with(prefix.clone()), Ok(())); - assert_eq!(m, X8(Parent, Parent, Parent, Parent, Parent, Parent, Parent, Parent)); - - let mut m = X1(Parent); - let prefix = X8(Parent, Parent, Parent, Parent, OnlyChild, Parent, Parent, Parent); - assert_eq!(m.prepend_with(prefix.clone()), Ok(())); - assert_eq!(m, X7(Parent, Parent, Parent, Parent, Parent, Parent, Parent)); - } - - #[test] - fn canonicalize_works() { - let mut m = X1(Parent); - m.canonicalize(); - assert_eq!(m, X1(Parent)); - - let mut m = X1(Parachain(1)); - m.canonicalize(); - assert_eq!(m, X1(Parachain(1))); - - let mut m = X6(Parent, Parachain(1), Parent, Parachain(2), Parent, Parachain(3)); - m.canonicalize(); - assert_eq!(m, X2(Parent, Parachain(3))); - - let mut m = X5(Parachain(1), Parent, Parachain(2), Parent, Parachain(3)); - m.canonicalize(); - assert_eq!(m, X1(Parachain(3))); - - let mut m = X6(Parachain(1), Parent, Parachain(2), Parent, Parachain(3), Parent); - m.canonicalize(); - assert_eq!(m, Null); - - let mut m = X5(Parachain(1), Parent, Parent, Parent, Parachain(3)); - m.canonicalize(); - assert_eq!(m, X3(Parent, Parent, Parachain(3))); - - let mut m = X4(Parachain(1), Parachain(2), Parent, Parent); - m.canonicalize(); - assert_eq!(m, Null); - - let mut m = X4(Parent, Parent, Parachain(1), Parachain(2)); - m.canonicalize(); - assert_eq!(m, X4(Parent, Parent, Parachain(1), Parachain(2))); - } - - #[test] - fn conversion_from_other_types_works() { - use crate::v1::{self, Junction, Junctions}; - use core::convert::TryInto; - - fn takes_multilocation>(_arg: Arg) {} - - takes_multilocation(Null); - takes_multilocation(Parent); - takes_multilocation([Parent, Parachain(4)]); - - assert_eq!(v1::MultiLocation::here().try_into(), Ok(MultiLocation::Null)); - assert_eq!( - v1::MultiLocation::new(1, Junctions::X1(Junction::Parachain(8))).try_into(), - Ok(X2(Parent, Parachain(8))), - ); - assert_eq!( - v1::MultiLocation::new(24, Junctions::Here).try_into(), - Err::(()), - ); - } -} diff --git a/xcm/src/v0/order.rs b/xcm/src/v0/order.rs deleted file mode 100644 index 54117e31f9c5..000000000000 --- a/xcm/src/v0/order.rs +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright 2020 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 . - -//! Version 0 of the Cross-Consensus Message format data structures. - -use super::{super::v1::Order as Order1, MultiAsset, MultiLocation, Xcm}; -use alloc::vec::Vec; -use core::{ - convert::{TryFrom, TryInto}, - result, -}; -use derivative::Derivative; -use parity_scale_codec::{self, Decode, Encode}; - -/// An instruction to be executed on some or all of the assets in holding, used by asset-related XCM messages. -#[derive(Derivative, Encode, Decode, scale_info::TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -#[scale_info(bounds(), skip_type_params(Call))] -pub enum Order { - /// Do nothing. Not generally used. - #[codec(index = 0)] - Null, - - /// Remove the asset(s) (`assets`) from holding and place equivalent assets under the ownership of `dest` within - /// this consensus system. - /// - /// - `assets`: The asset(s) to remove from holding. - /// - `dest`: The new owner for the assets. - /// - /// Errors: - #[codec(index = 1)] - DepositAsset { assets: Vec, dest: MultiLocation }, - - /// Remove the asset(s) (`assets`) from holding and place equivalent assets under the ownership of `dest` within - /// this consensus system. - /// - /// Send an onward XCM message to `dest` of `ReserveAssetDeposit` with the given `effects`. - /// - /// - `assets`: The asset(s) to remove from holding. - /// - `dest`: The new owner for the assets. - /// - `effects`: The orders that should be contained in the `ReserveAssetDeposit` which is sent onwards to - /// `dest`. - /// - /// Errors: - #[codec(index = 2)] - DepositReserveAsset { assets: Vec, dest: MultiLocation, effects: Vec> }, - - /// Remove the asset(s) (`give`) from holding and replace them with alternative assets. - /// - /// The minimum amount of assets to be received into holding for the order not to fail may be stated. - /// - /// - `give`: The asset(s) to remove from holding. - /// - `receive`: The minimum amount of assets(s) which `give` should be exchanged for. The meaning of wildcards - /// is undefined and they should be not be used. - /// - /// Errors: - #[codec(index = 3)] - ExchangeAsset { give: Vec, receive: Vec }, - - /// Remove the asset(s) (`assets`) from holding and send a `WithdrawAsset` XCM message to a reserve location. - /// - /// - `assets`: The asset(s) to remove from holding. - /// - `reserve`: A valid location that acts as a reserve for all asset(s) in `assets`. The sovereign account - /// of this consensus system *on the reserve location* will have appropriate assets withdrawn and `effects` will - /// be executed on them. There will typically be only one valid location on any given asset/chain combination. - /// - `effects`: The orders to execute on the assets once withdrawn *on the reserve location*. - /// - /// Errors: - #[codec(index = 4)] - InitiateReserveWithdraw { - assets: Vec, - reserve: MultiLocation, - effects: Vec>, - }, - - /// Remove the asset(s) (`assets`) from holding and send a `TeleportAsset` XCM message to a destination location. - /// - /// - `assets`: The asset(s) to remove from holding. - /// - `destination`: A valid location that has a bi-lateral teleportation arrangement. - /// - `effects`: The orders to execute on the assets once arrived *on the destination location*. - /// - /// Errors: - #[codec(index = 5)] - InitiateTeleport { assets: Vec, dest: MultiLocation, effects: Vec> }, - - /// Send a `Balances` XCM message with the `assets` value equal to the holding contents, or a portion thereof. - /// - /// - `query_id`: An identifier that will be replicated into the returned XCM message. - /// - `dest`: A valid destination for the returned XCM message. This may be limited to the current origin. - /// - `assets`: A filter for the assets that should be reported back. The assets reported back will be, asset- - /// wise, *the lesser of this value and the holding account*. No wildcards will be used when reporting assets - /// back. - /// - /// Errors: - #[codec(index = 6)] - QueryHolding { - #[codec(compact)] - query_id: u64, - dest: MultiLocation, - assets: Vec, - }, - - /// Pay for the execution of some XCM with up to `weight` picoseconds of execution time, paying for this with - /// up to `fees` from the holding account. - /// - /// Errors: - #[codec(index = 7)] - BuyExecution { - fees: MultiAsset, - weight: u64, - debt: u64, - halt_on_error: bool, - xcm: Vec>, - }, -} - -pub mod opaque { - pub type Order = super::Order<()>; -} - -impl Order { - pub fn into(self) -> Order { - Order::from(self) - } - pub fn from(order: Order) -> Self { - use Order::*; - match order { - Null => Null, - DepositAsset { assets, dest } => DepositAsset { assets, dest }, - DepositReserveAsset { assets, dest, effects } => - DepositReserveAsset { assets, dest, effects }, - ExchangeAsset { give, receive } => ExchangeAsset { give, receive }, - InitiateReserveWithdraw { assets, reserve, effects } => - InitiateReserveWithdraw { assets, reserve, effects }, - InitiateTeleport { assets, dest, effects } => - InitiateTeleport { assets, dest, effects }, - QueryHolding { query_id, dest, assets } => QueryHolding { query_id, dest, assets }, - BuyExecution { fees, weight, debt, halt_on_error, xcm } => { - let xcm = xcm.into_iter().map(Xcm::from).collect(); - BuyExecution { fees, weight, debt, halt_on_error, xcm } - }, - } - } -} - -impl TryFrom> for Order { - type Error = (); - fn try_from(old: Order1) -> result::Result, ()> { - use Order::*; - Ok(match old { - Order1::Noop => Null, - Order1::DepositAsset { assets, beneficiary, .. } => - DepositAsset { assets: assets.try_into()?, dest: beneficiary.try_into()? }, - Order1::DepositReserveAsset { assets, dest, effects, .. } => DepositReserveAsset { - assets: assets.try_into()?, - dest: dest.try_into()?, - effects: effects - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - Order1::ExchangeAsset { give, receive } => - ExchangeAsset { give: give.try_into()?, receive: receive.try_into()? }, - Order1::InitiateReserveWithdraw { assets, reserve, effects } => - InitiateReserveWithdraw { - assets: assets.try_into()?, - reserve: reserve.try_into()?, - effects: effects - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - Order1::InitiateTeleport { assets, dest, effects } => InitiateTeleport { - assets: assets.try_into()?, - dest: dest.try_into()?, - effects: effects - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - Order1::QueryHolding { query_id, dest, assets } => - QueryHolding { query_id, dest: dest.try_into()?, assets: assets.try_into()? }, - Order1::BuyExecution { fees, weight, debt, halt_on_error, instructions } => { - let xcm = instructions - .into_iter() - .map(Xcm::::try_from) - .collect::>()?; - BuyExecution { fees: fees.try_into()?, weight, debt, halt_on_error, xcm } - }, - }) - } -} diff --git a/xcm/src/v0/traits.rs b/xcm/src/v0/traits.rs deleted file mode 100644 index cfbc6a2e6a8f..000000000000 --- a/xcm/src/v0/traits.rs +++ /dev/null @@ -1,263 +0,0 @@ -// Copyright 2020 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 . - -//! Cross-Consensus Message format data structures. - -use core::result; -use parity_scale_codec::{Decode, Encode}; - -use super::{MultiLocation, Xcm}; - -#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, scale_info::TypeInfo)] -pub enum Error { - Undefined, - /// An arithmetic overflow happened. - Overflow, - /// The operation is intentionally unsupported. - Unimplemented, - UnhandledXcmVersion, - /// The implementation does not handle a given XCM. - UnhandledXcmMessage, - /// The implementation does not handle an effect present in an XCM. - UnhandledEffect, - EscalationOfPrivilege, - UntrustedReserveLocation, - UntrustedTeleportLocation, - DestinationBufferOverflow, - /// The message and destination was recognized as being reachable but the operation could not be completed. - /// A human-readable explanation of the specific issue is provided. - SendFailed(#[codec(skip)] &'static str), - /// The message and destination combination was not recognized as being reachable. - CannotReachDestination(MultiLocation, Xcm<()>), - MultiLocationFull, - FailedToDecode, - BadOrigin, - ExceedsMaxMessageSize, - /// An asset transaction (like withdraw or deposit) failed. - /// See implementers of the `TransactAsset` trait for sources. - /// Causes can include type conversion failures between id or balance types. - FailedToTransactAsset(#[codec(skip)] &'static str), - /// Execution of the XCM would potentially result in a greater weight used than the pre-specified - /// weight limit. The amount that is potentially required is the parameter. - WeightLimitReached(Weight), - /// An asset wildcard was passed where it was not expected (e.g. as the asset to withdraw in a - /// `WithdrawAsset` XCM). - Wildcard, - /// The case where an XCM message has specified a weight limit on an interior call and this - /// limit is too low. - /// - /// Used by: - /// - `Transact` - MaxWeightInvalid, - /// The fees specified by the XCM message were not found in the holding account. - /// - /// Used by: - /// - `BuyExecution` - NotHoldingFees, - /// The weight of an XCM message is not computable ahead of execution. This generally means at least part - /// of the message is invalid, which could be due to it containing overly nested structures or an invalid - /// nested data segment (e.g. for the call in `Transact`). - WeightNotComputable, - /// The XCM did not pass the barrier condition for execution. The barrier condition differs on different - /// chains and in different circumstances, but generally it means that the conditions surrounding the message - /// were not such that the chain considers the message worth spending time executing. Since most chains - /// lift the barrier to execution on appropriate payment, presentation of an NFT voucher, or based on the - /// message origin, it means that none of those were the case. - Barrier, - /// Indicates that it is not possible for a location to have an asset be withdrawn or transferred from its - /// ownership. This probably means it doesn't own (enough of) it, but may also indicate that it is under a - /// lock, hold, freeze or is otherwise unavailable. - NotWithdrawable, - /// Indicates that the consensus system cannot deposit an asset under the ownership of a particular location. - LocationCannotHold, - /// The assets given to purchase weight is are insufficient for the weight desired. - TooExpensive, - /// The given asset is not handled. - AssetNotFound, - /// `execute_xcm` has been called too many times recursively. - RecursionLimitReached, -} - -impl From<()> for Error { - fn from(_: ()) -> Self { - Self::Undefined - } -} - -pub type Result = result::Result<(), Error>; - -/// Local weight type; execution time in picoseconds. -pub type Weight = u64; - -/// Outcome of an XCM execution. -#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, scale_info::TypeInfo)] -pub enum Outcome { - /// Execution completed successfully; given weight was used. - Complete(Weight), - /// Execution started, but did not complete successfully due to the given error; given weight was used. - Incomplete(Weight, Error), - /// Execution did not start due to the given error. - Error(Error), -} - -impl Outcome { - pub fn ensure_complete(self) -> Result { - match self { - Outcome::Complete(_) => Ok(()), - Outcome::Incomplete(_, e) => Err(e), - Outcome::Error(e) => Err(e), - } - } - pub fn ensure_execution(self) -> result::Result { - match self { - Outcome::Complete(w) => Ok(w), - Outcome::Incomplete(w, _) => Ok(w), - Outcome::Error(e) => Err(e), - } - } - /// How much weight was used by the XCM execution attempt. - pub fn weight_used(&self) -> Weight { - match self { - Outcome::Complete(w) => *w, - Outcome::Incomplete(w, _) => *w, - Outcome::Error(_) => 0, - } - } -} - -/// Type of XCM message executor. -pub trait ExecuteXcm { - /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is - /// a basic hard-limit and the implementation may place further restrictions or requirements on weight and - /// other aspects. - fn execute_xcm(origin: MultiLocation, message: Xcm, weight_limit: Weight) -> Outcome { - log::debug!( - target: "xcm::execute_xcm", - "origin: {:?}, message: {:?}, weight_limit: {:?}", - origin, - message, - weight_limit, - ); - Self::execute_xcm_in_credit(origin, message, weight_limit, 0) - } - - /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. - /// - /// Some amount of `weight_credit` may be provided which, depending on the implementation, may allow - /// execution without associated payment. - fn execute_xcm_in_credit( - origin: MultiLocation, - message: Xcm, - weight_limit: Weight, - weight_credit: Weight, - ) -> Outcome; -} - -impl ExecuteXcm for () { - fn execute_xcm_in_credit( - _origin: MultiLocation, - _message: Xcm, - _weight_limit: Weight, - _weight_credit: Weight, - ) -> Outcome { - Outcome::Error(Error::Unimplemented) - } -} - -/// Utility for sending an XCM message. -/// -/// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each router might return -/// `CannotReachDestination` to pass the execution to the next sender item. Note that each `CannotReachDestination` -/// might alter the destination and the XCM message for to the next router. -/// -/// -/// # Example -/// ```rust -/// # use xcm::v0::{MultiLocation, Xcm, Junction, Error, OriginKind, SendXcm, Result}; -/// # use parity_scale_codec::Encode; -/// -/// /// A sender that only passes the message through and does nothing. -/// struct Sender1; -/// impl SendXcm for Sender1 { -/// fn send_xcm(destination: MultiLocation, message: Xcm<()>) -> Result { -/// return Err(Error::CannotReachDestination(destination, message)) -/// } -/// } -/// -/// /// A sender that accepts a message that has an X2 junction, otherwise stops the routing. -/// struct Sender2; -/// impl SendXcm for Sender2 { -/// fn send_xcm(destination: MultiLocation, message: Xcm<()>) -> Result { -/// if let MultiLocation::X2(j1, j2) = destination { -/// Ok(()) -/// } else { -/// Err(Error::Undefined) -/// } -/// } -/// } -/// -/// /// A sender that accepts a message from an X1 parent junction, passing through otherwise. -/// struct Sender3; -/// impl SendXcm for Sender3 { -/// fn send_xcm(destination: MultiLocation, message: Xcm<()>) -> Result { -/// match destination { -/// MultiLocation::X1(j) if j == Junction::Parent => Ok(()), -/// _ => Err(Error::CannotReachDestination(destination, message)), -/// } -/// } -/// } -/// -/// // A call to send via XCM. We don't really care about this. -/// # fn main() { -/// let call: Vec = ().encode(); -/// let message = Xcm::Transact { origin_type: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; -/// let destination = MultiLocation::X1(Junction::Parent); -/// -/// assert!( -/// // Sender2 will block this. -/// <(Sender1, Sender2, Sender3) as SendXcm>::send_xcm(destination.clone(), message.clone()) -/// .is_err() -/// ); -/// -/// assert!( -/// // Sender3 will catch this. -/// <(Sender1, Sender3) as SendXcm>::send_xcm(destination.clone(), message.clone()) -/// .is_ok() -/// ); -/// # } -/// ``` -pub trait SendXcm { - /// Send an XCM `message` to a given `destination`. - /// - /// If it is not a destination which can be reached with this type but possibly could by others, then it *MUST* - /// return `CannotReachDestination`. Any other error will cause the tuple implementation to exit early without - /// trying other type fields. - fn send_xcm(destination: MultiLocation, message: Xcm<()>) -> Result; -} - -#[impl_trait_for_tuples::impl_for_tuples(30)] -impl SendXcm for Tuple { - fn send_xcm(destination: MultiLocation, message: Xcm<()>) -> Result { - for_tuples!( #( - // we shadow `destination` and `message` in each expansion for the next one. - let (destination, message) = match Tuple::send_xcm(destination, message) { - Err(Error::CannotReachDestination(d, m)) => (d, m), - o @ _ => return o, - }; - )* ); - Err(Error::CannotReachDestination(destination, message)) - } -} diff --git a/xcm/src/v1/junction.rs b/xcm/src/v1/junction.rs index c4835d60c5b1..af740447daaf 100644 --- a/xcm/src/v1/junction.rs +++ b/xcm/src/v1/junction.rs @@ -17,9 +17,9 @@ //! Support data structures for `MultiLocation`, primarily the `Junction` datatype. use super::{BodyId, BodyPart, Junctions, MultiLocation, NetworkId}; -use crate::v0::Junction as Junction0; +use crate::v3::Junction as NewJunction; use alloc::vec::Vec; -use core::convert::TryFrom; +use core::convert::{TryFrom, TryInto}; use parity_scale_codec::{self, Decode, Encode}; use scale_info::TypeInfo; @@ -78,23 +78,25 @@ pub enum Junction { Plurality { id: BodyId, part: BodyPart }, } -impl TryFrom for Junction { +impl TryFrom for Junction { type Error = (); - fn try_from(value: Junction0) -> Result { - match value { - Junction0::Parent => Err(()), - Junction0::Parachain(id) => Ok(Self::Parachain(id)), - Junction0::AccountId32 { network, id } => Ok(Self::AccountId32 { network, id }), - Junction0::AccountIndex64 { network, index } => - Ok(Self::AccountIndex64 { network, index }), - Junction0::AccountKey20 { network, key } => Ok(Self::AccountKey20 { network, key }), - Junction0::PalletInstance(index) => Ok(Self::PalletInstance(index)), - Junction0::GeneralIndex(id) => Ok(Self::GeneralIndex(id)), - Junction0::GeneralKey(key) => Ok(Self::GeneralKey(key)), - Junction0::OnlyChild => Ok(Self::OnlyChild), - Junction0::Plurality { id, part } => Ok(Self::Plurality { id: id.into(), part }), - } + fn try_from(value: NewJunction) -> Result { + use NewJunction::*; + Ok(match value { + Parachain(id) => Self::Parachain(id), + AccountId32 { network, id } => Self::AccountId32 { network: network.try_into()?, id }, + AccountIndex64 { network, index } => + Self::AccountIndex64 { network: network.try_into()?, index }, + AccountKey20 { network, key } => + Self::AccountKey20 { network: network.try_into()?, key }, + PalletInstance(index) => Self::PalletInstance(index), + GeneralIndex(id) => Self::GeneralIndex(id), + GeneralKey(key) => Self::GeneralKey(key), + OnlyChild => Self::OnlyChild, + Plurality { id, part } => Self::Plurality { id: id.into(), part }, + _ => return Err(()), + }) } } diff --git a/xcm/src/v1/mod.rs b/xcm/src/v1/mod.rs index 43e7d504533c..949403c83c5f 100644 --- a/xcm/src/v1/mod.rs +++ b/xcm/src/v1/mod.rs @@ -60,11 +60,11 @@ //! - v1 Orders that do allow the notion of `All` to be used as wildcards, will instead use a new //! type called `MultiAssetFilter`. -use super::{ - v0::{Response as OldResponse, Xcm as OldXcm}, +use crate::{ v2::{Instruction, Response as NewResponse, Xcm as NewXcm}, + v3::NetworkId as NewNetworkId, + DoubleEncoded, }; -use crate::DoubleEncoded; use alloc::vec::Vec; use core::{ convert::{TryFrom, TryInto}, @@ -92,9 +92,6 @@ pub use multilocation::{ pub use order::Order; pub use traits::{Error, ExecuteXcm, Outcome, Result, SendXcm}; -// These parts of XCM v0 have been unchanged in XCM v1, and are re-imported here. -pub use super::v0::{BodyId, BodyPart, NetworkId, OriginKind}; - /// A prelude for importing all types typically used when interacting with XCM messages. pub mod prelude { pub use super::{ @@ -119,6 +116,121 @@ pub mod prelude { }; } +/// Basically just the XCM (more general) version of `ParachainDispatchOrigin`. +#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] +pub enum OriginKind { + /// Origin should just be the native dispatch origin representation for the sender in the + /// local runtime framework. For Cumulus/Frame chains this is the `Parachain` or `Relay` origin + /// if coming from a chain, though there may be others if the `MultiLocation` XCM origin has a + /// primary/native dispatch origin form. + Native, + + /// Origin should just be the standard account-based origin with the sovereign account of + /// the sender. For Cumulus/Frame chains, this is the `Signed` origin. + SovereignAccount, + + /// Origin should be the super-user. For Cumulus/Frame chains, this is the `Root` origin. + /// This will not usually be an available option. + Superuser, + + /// Origin should be interpreted as an XCM native origin and the `MultiLocation` should be + /// encoded directly in the dispatch origin unchanged. For Cumulus/Frame chains, this will be + /// the `pallet_xcm::Origin::Xcm` type. + Xcm, +} + +/// A global identifier of an account-bearing consensus system. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum NetworkId { + /// Unidentified/any. + Any, + /// Some named network. + Named(Vec), + /// The Polkadot Relay chain + Polkadot, + /// Kusama. + Kusama, +} + +impl TryInto for Option { + type Error = (); + fn try_into(self) -> result::Result { + use NewNetworkId::*; + Ok(match self { + None => NetworkId::Any, + Some(Polkadot) => NetworkId::Polkadot, + Some(Kusama) => NetworkId::Kusama, + _ => return Err(()), + }) + } +} + +/// An identifier of a pluralistic body. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum BodyId { + /// The only body in its context. + Unit, + /// A named body. + Named(Vec), + /// An indexed body. + Index(#[codec(compact)] u32), + /// The unambiguous executive body (for Polkadot, this would be the Polkadot council). + Executive, + /// The unambiguous technical body (for Polkadot, this would be the Technical Committee). + Technical, + /// The unambiguous legislative body (for Polkadot, this could be considered the opinion of a majority of + /// lock-voters). + Legislative, + /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it + /// may be considered as that). + Judicial, +} + +/// A part of a pluralistic body. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum BodyPart { + /// The body's declaration, under whatever means it decides. + Voice, + /// A given number of members of the body. + Members { + #[codec(compact)] + count: u32, + }, + /// A given number of members of the body, out of some larger caucus. + Fraction { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + /// No less than the given proportion of members of the body. + AtLeastProportion { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + /// More than than the given proportion of members of the body. + MoreThanProportion { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, +} + +impl BodyPart { + /// Returns `true` if the part represents a strict majority (> 50%) of the body in question. + pub fn is_majority(&self) -> bool { + match self { + BodyPart::Fraction { nom, denom } if *nom * 2 > *denom => true, + BodyPart::AtLeastProportion { nom, denom } if *nom * 2 > *denom => true, + BodyPart::MoreThanProportion { nom, denom } if *nom * 2 >= *denom => true, + _ => false, + } + } +} + /// Response data to a query. #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] pub enum Response { @@ -384,69 +496,6 @@ pub mod opaque { pub use super::order::opaque::*; } -// Convert from a v0 response to a v1 response -impl TryFrom for Response { - type Error = (); - fn try_from(old_response: OldResponse) -> result::Result { - match old_response { - OldResponse::Assets(assets) => Ok(Self::Assets(assets.try_into()?)), - } - } -} - -impl TryFrom> for Xcm { - type Error = (); - fn try_from(old: OldXcm) -> result::Result, ()> { - use Xcm::*; - Ok(match old { - OldXcm::WithdrawAsset { assets, effects } => WithdrawAsset { - assets: assets.try_into()?, - effects: effects - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - OldXcm::ReserveAssetDeposit { assets, effects } => ReserveAssetDeposited { - assets: assets.try_into()?, - effects: effects - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - OldXcm::TeleportAsset { assets, effects } => ReceiveTeleportedAsset { - assets: assets.try_into()?, - effects: effects - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - OldXcm::QueryResponse { query_id, response } => - QueryResponse { query_id, response: response.try_into()? }, - OldXcm::TransferAsset { assets, dest } => - TransferAsset { assets: assets.try_into()?, beneficiary: dest.try_into()? }, - OldXcm::TransferReserveAsset { assets, dest, effects } => TransferReserveAsset { - assets: assets.try_into()?, - dest: dest.try_into()?, - effects: effects - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - OldXcm::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => - HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, - OldXcm::HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient }, - OldXcm::HrmpChannelClosing { initiator, sender, recipient } => - HrmpChannelClosing { initiator, sender, recipient }, - OldXcm::Transact { origin_type, require_weight_at_most, call } => - Transact { origin_type, require_weight_at_most, call: call.into() }, - OldXcm::RelayedFrom { who, message } => RelayedFrom { - who: MultiLocation::try_from(who)?.try_into()?, - message: alloc::boxed::Box::new((*message).try_into()?), - }, - }) - } -} - impl TryFrom> for Xcm { type Error = (); fn try_from(old: NewXcm) -> result::Result, ()> { diff --git a/xcm/src/v1/multiasset.rs b/xcm/src/v1/multiasset.rs index f4d0f1bf04be..fd2f2a4925ec 100644 --- a/xcm/src/v1/multiasset.rs +++ b/xcm/src/v1/multiasset.rs @@ -24,12 +24,14 @@ //! account. use super::MultiLocation; -use crate::v3::{MultiAssetFilter as NewMultiAssetFilter, WildMultiAsset as NewWildMultiAsset}; +use crate::v3::{ + AssetId as NewAssetId, MultiAsset as NewMultiAsset, MultiAssetFilter as NewMultiAssetFilter, + MultiAssets as NewMultiAssets, WildMultiAsset as NewWildMultiAsset, +}; use alloc::{vec, vec::Vec}; use core::{ cmp::Ordering, convert::{TryFrom, TryInto}, - result, }; use parity_scale_codec::{self as codec, Decode, Encode}; use scale_info::TypeInfo; @@ -115,6 +117,17 @@ impl From> for AssetId { } } +impl TryFrom for AssetId { + type Error = (); + fn try_from(old: NewAssetId) -> Result { + use NewAssetId::*; + Ok(match old { + Concrete(l) => Self::Concrete(l.try_into()?), + Abstract(v) => Self::Abstract(v), + }) + } +} + impl AssetId { /// Prepend a `MultiLocation` to a concrete asset, giving it a new root location. pub fn prepend_with(&mut self, prepend: &MultiLocation) -> Result<(), ()> { @@ -248,42 +261,10 @@ impl MultiAsset { } } -impl TryFrom for MultiAsset { - type Error = (); - fn try_from(old: super::super::v0::MultiAsset) -> result::Result { - use super::super::v0::MultiAsset as V0; - use AssetId::*; - use Fungibility::*; - let (id, fun) = match old { - V0::ConcreteFungible { id, amount } => (Concrete(id.try_into()?), Fungible(amount)), - V0::ConcreteNonFungible { class, instance } => - (Concrete(class.try_into()?), NonFungible(instance)), - V0::AbstractFungible { id, amount } => (Abstract(id), Fungible(amount)), - V0::AbstractNonFungible { class, instance } => (Abstract(class), NonFungible(instance)), - _ => return Err(()), - }; - Ok(MultiAsset { id, fun }) - } -} - -impl TryFrom for Option { - type Error = (); - fn try_from(old: super::super::v0::MultiAsset) -> result::Result, ()> { - match old { - super::super::v0::MultiAsset::None => return Ok(None), - x => return Ok(Some(x.try_into()?)), - } - } -} - -impl TryFrom> for MultiAsset { +impl TryFrom for MultiAsset { type Error = (); - fn try_from(mut old: Vec) -> result::Result { - if old.len() == 1 { - old.remove(0).try_into() - } else { - Err(()) - } + fn try_from(new: NewMultiAsset) -> Result { + Ok(Self { id: new.id.try_into()?, fun: new.fun }) } } @@ -298,15 +279,15 @@ impl Decode for MultiAssets { } } -impl TryFrom> for MultiAssets { +impl TryFrom for MultiAssets { type Error = (); - fn try_from(old: Vec) -> result::Result { - let v = old + fn try_from(new: NewMultiAssets) -> Result { + let v = new + .drain() .into_iter() - .map(Option::::try_from) - .filter_map(|x| x.transpose()) - .collect::, ()>>()?; - Ok(v.into()) + .map(MultiAsset::try_from) + .collect::, ()>>()?; + Ok(MultiAssets(v)) } } @@ -451,6 +432,7 @@ impl MultiAssets { self.0.get(index) } } + /// Classification of whether an asset is fungible or not. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] pub enum WildFungibility { @@ -469,35 +451,6 @@ pub enum WildMultiAsset { AllOf { id: AssetId, fun: WildFungibility }, } -impl TryFrom for WildMultiAsset { - type Error = (); - fn try_from(old: super::super::v0::MultiAsset) -> result::Result { - use super::super::v0::MultiAsset as V0; - use AssetId::*; - use WildFungibility::*; - let (id, fun) = match old { - V0::All => return Ok(WildMultiAsset::All), - V0::AllConcreteFungible { id } => (Concrete(id.try_into()?), Fungible), - V0::AllConcreteNonFungible { class } => (Concrete(class.try_into()?), NonFungible), - V0::AllAbstractFungible { id } => (Abstract(id), Fungible), - V0::AllAbstractNonFungible { class } => (Abstract(class), NonFungible), - _ => return Err(()), - }; - Ok(WildMultiAsset::AllOf { id, fun }) - } -} - -impl TryFrom> for WildMultiAsset { - type Error = (); - fn try_from(mut old: Vec) -> result::Result { - if old.len() == 1 { - old.remove(0).try_into() - } else { - Err(()) - } - } -} - impl WildMultiAsset { /// Returns true if `self` is a super-set of the given `inner`. /// @@ -584,35 +537,25 @@ impl MultiAssetFilter { } } -impl TryFrom> for MultiAssetFilter { +impl TryFrom for WildMultiAsset { type Error = (); - fn try_from( - mut old: Vec, - ) -> result::Result { - if old.len() == 1 && old[0].is_wildcard() { - Ok(MultiAssetFilter::Wild(old.remove(0).try_into()?)) - } else { - Ok(MultiAssetFilter::Definite(old.try_into()?)) - } - } -} - -impl From for WildMultiAsset { - fn from(old: NewWildMultiAsset) -> Self { + fn try_from(new: NewWildMultiAsset) -> Result { use NewWildMultiAsset::*; - match old { - AllOf { id, fun } | AllOfCounted { id, fun, .. } => Self::AllOf { id, fun }, + Ok(match new { + AllOf { id, fun } | AllOfCounted { id, fun, .. } => + Self::AllOf { id: id.try_into()?, fun }, All | AllCounted(_) => Self::All, - } + }) } } -impl From for MultiAssetFilter { - fn from(old: NewMultiAssetFilter) -> Self { +impl TryFrom for MultiAssetFilter { + type Error = (); + fn try_from(old: NewMultiAssetFilter) -> Result { use NewMultiAssetFilter::*; - match old { - Definite(x) => Self::Definite(x), - Wild(x) => Self::Wild(x.into()), - } + Ok(match old { + Definite(x) => Self::Definite(x.try_into()?), + Wild(x) => Self::Wild(x.try_into()?), + }) } } diff --git a/xcm/src/v1/multilocation.rs b/xcm/src/v1/multilocation.rs index b02bf9d3b07a..a47f4b8ceec0 100644 --- a/xcm/src/v1/multilocation.rs +++ b/xcm/src/v1/multilocation.rs @@ -17,7 +17,11 @@ //! Cross-Consensus Message format data structures. use super::Junction; -use core::{convert::TryFrom, mem, result}; +use crate::v3::MultiLocation as NewMultiLocation; +use core::{ + convert::{TryFrom, TryInto}, + mem, result, +}; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; @@ -412,6 +416,13 @@ impl MultiLocation { } } +impl TryFrom for MultiLocation { + type Error = (); + fn try_from(x: NewMultiLocation) -> result::Result { + Ok(MultiLocation { parents: x.parents, interior: x.interior.try_into()? }) + } +} + /// A unit struct which can be converted into a `MultiLocation` of `parents` value 1. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] pub struct Parent; @@ -423,7 +434,7 @@ impl From for MultiLocation { /// A tuple struct which can be converted into a `MultiLocation` of `parents` value 1 with the inner interior. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] -pub struct ParentThen(Junctions); +pub struct ParentThen(pub Junctions); impl From for MultiLocation { fn from(ParentThen(interior): ParentThen) -> Self { MultiLocation { parents: 1, interior } @@ -432,7 +443,7 @@ impl From for MultiLocation { /// A unit struct which can be converted into a `MultiLocation` of the inner `parents` value. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] -pub struct Ancestor(u8); +pub struct Ancestor(pub u8); impl From for MultiLocation { fn from(Ancestor(parents): Ancestor) -> Self { MultiLocation { parents, interior: Junctions::Here } @@ -441,10 +452,10 @@ impl From for MultiLocation { /// A unit struct which can be converted into a `MultiLocation` of the inner `parents` value and the inner interior. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] -pub struct AncestorThen(u8, Junctions); -impl From for MultiLocation { - fn from(AncestorThen(parents, interior): AncestorThen) -> Self { - MultiLocation { parents, interior } +pub struct AncestorThen(pub u8, pub Interior); +impl> From> for MultiLocation { + fn from(AncestorThen(parents, interior): AncestorThen) -> Self { + MultiLocation { parents, interior: interior.into() } } } @@ -1057,9 +1068,6 @@ mod tests { #[test] fn conversion_from_other_types_works() { - use crate::v0; - use core::convert::TryInto; - fn takes_multilocation>(_arg: Arg) {} takes_multilocation(Parent); @@ -1076,24 +1084,5 @@ mod tests { takes_multilocation((Parent, Here)); takes_multilocation(ParentThen(X1(Parachain(75)))); takes_multilocation([Parachain(100), PalletInstance(3)]); - - assert_eq!(v0::MultiLocation::Null.try_into(), Ok(MultiLocation::here())); - assert_eq!( - v0::MultiLocation::X1(v0::Junction::Parent).try_into(), - Ok(MultiLocation::parent()) - ); - assert_eq!( - v0::MultiLocation::X2(v0::Junction::Parachain(88), v0::Junction::Parent).try_into(), - Ok(MultiLocation::here()), - ); - assert_eq!( - v0::MultiLocation::X3( - v0::Junction::Parent, - v0::Junction::Parent, - v0::Junction::GeneralKey(b"foo".to_vec()), - ) - .try_into(), - Ok(MultiLocation { parents: 2, interior: X1(GeneralKey(b"foo".to_vec())) }), - ); } } diff --git a/xcm/src/v1/order.rs b/xcm/src/v1/order.rs index 00ee69458cd0..66f90395d8da 100644 --- a/xcm/src/v1/order.rs +++ b/xcm/src/v1/order.rs @@ -17,12 +17,9 @@ //! Version 1 of the Cross-Consensus Message format data structures. use super::{MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, Xcm}; -use crate::{v0::Order as OldOrder, v2::Instruction}; +use crate::v2::Instruction; use alloc::{vec, vec::Vec}; -use core::{ - convert::{TryFrom, TryInto}, - result, -}; +use core::{convert::TryFrom, result}; use derivative::Derivative; use parity_scale_codec::{self, Decode, Encode}; use scale_info::TypeInfo; @@ -185,56 +182,6 @@ impl Order { } } -impl TryFrom> for Order { - type Error = (); - fn try_from(old: OldOrder) -> result::Result, ()> { - use Order::*; - Ok(match old { - OldOrder::Null => Noop, - OldOrder::DepositAsset { assets, dest } => DepositAsset { - assets: assets.try_into()?, - max_assets: 1, - beneficiary: dest.try_into()?, - }, - OldOrder::DepositReserveAsset { assets, dest, effects } => DepositReserveAsset { - assets: assets.try_into()?, - max_assets: 1, - dest: dest.try_into()?, - effects: effects - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - OldOrder::ExchangeAsset { give, receive } => - ExchangeAsset { give: give.try_into()?, receive: receive.try_into()? }, - OldOrder::InitiateReserveWithdraw { assets, reserve, effects } => - InitiateReserveWithdraw { - assets: assets.try_into()?, - reserve: reserve.try_into()?, - effects: effects - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - OldOrder::InitiateTeleport { assets, dest, effects } => InitiateTeleport { - assets: assets.try_into()?, - dest: dest.try_into()?, - effects: effects - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - OldOrder::QueryHolding { query_id, dest, assets } => - QueryHolding { query_id, dest: dest.try_into()?, assets: assets.try_into()? }, - OldOrder::BuyExecution { fees, weight, debt, halt_on_error, xcm } => { - let instructions = - xcm.into_iter().map(Xcm::::try_from).collect::>()?; - BuyExecution { fees: fees.try_into()?, weight, debt, halt_on_error, instructions } - }, - }) - } -} - impl TryFrom> for Order { type Error = (); fn try_from(old: Instruction) -> result::Result, ()> { diff --git a/xcm/src/v1/traits.rs b/xcm/src/v1/traits.rs index 33b60455b0b2..c896ef38f8a5 100644 --- a/xcm/src/v1/traits.rs +++ b/xcm/src/v1/traits.rs @@ -42,7 +42,7 @@ pub enum Error { /// A human-readable explanation of the specific issue is provided. SendFailed(#[codec(skip)] &'static str), /// The message and destination combination was not recognized as being reachable. - CannotReachDestination(MultiLocation, Xcm<()>), + NotApplicable(MultiLocation, Xcm<()>), MultiLocationFull, FailedToDecode, BadOrigin, @@ -188,7 +188,7 @@ impl ExecuteXcm for () { /// Utility for sending an XCM message. /// /// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each router might return -/// `CannotReachDestination` to pass the execution to the next sender item. Note that each `CannotReachDestination` +/// `NotApplicable` to pass the execution to the next sender item. Note that each `NotApplicable` /// might alter the destination and the XCM message for to the next router. /// /// @@ -201,7 +201,7 @@ impl ExecuteXcm for () { /// struct Sender1; /// impl SendXcm for Sender1 { /// fn send_xcm(destination: impl Into, message: Xcm<()>) -> Result { -/// return Err(Error::CannotReachDestination(destination.into(), message)) +/// return Err(Error::NotApplicable(destination.into(), message)) /// } /// } /// @@ -230,7 +230,7 @@ impl ExecuteXcm for () { /// { /// Ok(()) /// } else { -/// Err(Error::CannotReachDestination(destination, message)) +/// Err(Error::NotApplicable(destination, message)) /// } /// } /// } @@ -257,7 +257,7 @@ pub trait SendXcm { /// Send an XCM `message` to a given `destination`. /// /// If it is not a destination which can be reached with this type but possibly could by others, then it *MUST* - /// return `CannotReachDestination`. Any other error will cause the tuple implementation to exit early without + /// return `NotApplicable`. Any other error will cause the tuple implementation to exit early without /// trying other type fields. fn send_xcm(destination: impl Into, message: Xcm<()>) -> Result; } @@ -268,10 +268,10 @@ impl SendXcm for Tuple { for_tuples!( #( // we shadow `destination` and `message` in each expansion for the next one. let (destination, message) = match Tuple::send_xcm(destination, message) { - Err(Error::CannotReachDestination(d, m)) => (d, m), + Err(Error::NotApplicable(d, m)) => (d, m), o @ _ => return o, }; )* ); - Err(Error::CannotReachDestination(destination.into(), message)) + Err(Error::NotApplicable(destination.into(), message)) } } diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index c76cd10c513a..3fa82fc43ec0 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -801,16 +801,16 @@ impl TryFrom for Response { impl TryFrom for Response { type Error = (); fn try_from(response: NewResponse) -> result::Result { - match response { - NewResponse::Assets(assets) => Ok(Self::Assets(assets)), - NewResponse::Version(version) => Ok(Self::Version(version)), - NewResponse::ExecutionResult(error) => Ok(Self::ExecutionResult(match error { + Ok(match response { + NewResponse::Assets(assets) => Self::Assets(assets.try_into()?), + NewResponse::Version(version) => Self::Version(version), + NewResponse::ExecutionResult(error) => Self::ExecutionResult(match error { Some((i, e)) => Some((i, e.try_into()?)), None => None, - })), - NewResponse::Null => Ok(Self::Null), - _ => Err(()), - } + }), + NewResponse::Null => Self::Null, + _ => return Err(()), + }) } } @@ -929,14 +929,20 @@ impl TryFrom> for Instruction { fn try_from(instruction: NewInstruction) -> result::Result { use NewInstruction::*; Ok(match instruction { - WithdrawAsset(assets) => Self::WithdrawAsset(assets), - ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets), - ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets), + WithdrawAsset(assets) => Self::WithdrawAsset(assets.try_into()?), + ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets.try_into()?), + ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets.try_into()?), QueryResponse { query_id, response, max_weight, .. } => Self::QueryResponse { query_id, response: response.try_into()?, max_weight }, - TransferAsset { assets, beneficiary } => Self::TransferAsset { assets, beneficiary }, - TransferReserveAsset { assets, dest, xcm } => - Self::TransferReserveAsset { assets, dest, xcm: xcm.try_into()? }, + TransferAsset { assets, beneficiary } => Self::TransferAsset { + assets: assets.try_into()?, + beneficiary: beneficiary.try_into()?, + }, + TransferReserveAsset { assets, dest, xcm } => Self::TransferReserveAsset { + assets: assets.try_into()?, + dest: dest.try_into()?, + xcm: xcm.try_into()?, + }, HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient }, @@ -949,47 +955,62 @@ impl TryFrom> for Instruction { }, ReportError(response_info) => Self::ReportError { query_id: response_info.query_id, - dest: response_info.destination, + dest: response_info.destination.try_into()?, max_response_weight: response_info.max_weight, }, DepositAsset { assets, beneficiary } => { let max_assets = assets.count().ok_or(())?; - Self::DepositAsset { assets: assets.into(), max_assets, beneficiary } + let beneficiary = beneficiary.try_into()?; + let assets = assets.try_into()?; + Self::DepositAsset { assets, max_assets, beneficiary } }, DepositReserveAsset { assets, dest, xcm } => { let max_assets = assets.count().ok_or(())?; - Self::DepositReserveAsset { - assets: assets.into(), - max_assets, - dest, - xcm: xcm.try_into()?, - } + let dest = dest.try_into()?; + let xcm = xcm.try_into()?; + let assets = assets.try_into()?; + Self::DepositReserveAsset { assets, max_assets, dest, xcm } + }, + ExchangeAsset { give, receive } => { + let give = give.try_into()?; + let receive = receive.try_into()?; + Self::ExchangeAsset { give, receive } }, - ExchangeAsset { give, receive } => Self::ExchangeAsset { give: give.into(), receive }, InitiateReserveWithdraw { assets, reserve, xcm } => { // No `max_assets` here, so if there's a connt, then we cannot translate. - let assets = assets.try_into().map_err(|_| ())?; - Self::InitiateReserveWithdraw { assets, reserve, xcm: xcm.try_into()? } + let assets = assets.try_into()?; + let reserve = reserve.try_into()?; + let xcm = xcm.try_into()?; + Self::InitiateReserveWithdraw { assets, reserve, xcm } }, InitiateTeleport { assets, dest, xcm } => { // No `max_assets` here, so if there's a connt, then we cannot translate. - let assets = assets.try_into().map_err(|_| ())?; - Self::InitiateTeleport { assets, dest, xcm: xcm.try_into()? } + let assets = assets.try_into()?; + let dest = dest.try_into()?; + let xcm = xcm.try_into()?; + Self::InitiateTeleport { assets, dest, xcm } }, ReportHolding { response_info, assets } => Self::QueryHolding { query_id: response_info.query_id, - dest: response_info.destination, - assets: assets.try_into().map_err(|_| ())?, + dest: response_info.destination.try_into()?, + assets: assets.try_into()?, max_response_weight: response_info.max_weight, }, - BuyExecution { fees, weight_limit } => Self::BuyExecution { fees, weight_limit }, + BuyExecution { fees, weight_limit } => { + let fees = fees.try_into()?; + Self::BuyExecution { fees, weight_limit } + }, ClearOrigin => Self::ClearOrigin, - DescendOrigin(who) => Self::DescendOrigin(who), + DescendOrigin(who) => Self::DescendOrigin(who.try_into()?), RefundSurplus => Self::RefundSurplus, SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, - ClaimAsset { assets, ticket } => Self::ClaimAsset { assets, ticket }, + ClaimAsset { assets, ticket } => { + let assets = assets.try_into()?; + let ticket = ticket.try_into()?; + Self::ClaimAsset { assets, ticket } + }, Trap(code) => Self::Trap(code), SubscribeVersion { query_id, max_response_weight } => Self::SubscribeVersion { query_id, max_response_weight }, diff --git a/xcm/src/v2/traits.rs b/xcm/src/v2/traits.rs index 519ce89823c7..af0240c1ad26 100644 --- a/xcm/src/v2/traits.rs +++ b/xcm/src/v2/traits.rs @@ -146,7 +146,7 @@ impl TryFrom for Error { impl From for Error { fn from(e: SendError) -> Self { match e { - SendError::CannotReachDestination(..) | SendError::Unroutable => Error::Unroutable, + SendError::NotApplicable(..) | SendError::Unroutable => Error::Unroutable, SendError::Transport(s) => Error::Transport(s), SendError::DestinationUnsupported => Error::DestinationUnsupported, SendError::ExceedsMaxMessageSize => Error::ExceedsMaxMessageSize, @@ -243,7 +243,7 @@ pub enum SendError { /// /// This is not considered fatal: if there are alternative transport routes available, then /// they may be attempted. For this reason, the destination and message are contained. - CannotReachDestination(MultiLocation, Xcm<()>), + NotApplicable(MultiLocation, Xcm<()>), /// Destination is routable, but there is some issue with the transport mechanism. This is /// considered fatal. /// A human-readable explanation of the specific issue is provided. @@ -264,7 +264,7 @@ pub type SendResult = result::Result<(), SendError>; /// Utility for sending an XCM message. /// /// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each router might return -/// `CannotReachDestination` to pass the execution to the next sender item. Note that each `CannotReachDestination` +/// `NotApplicable` to pass the execution to the next sender item. Note that each `NotApplicable` /// might alter the destination and the XCM message for to the next router. /// /// @@ -277,7 +277,7 @@ pub type SendResult = result::Result<(), SendError>; /// struct Sender1; /// impl SendXcm for Sender1 { /// fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { -/// return Err(SendError::CannotReachDestination(destination.into(), message)) +/// return Err(SendError::NotApplicable(destination.into(), message)) /// } /// } /// @@ -300,7 +300,7 @@ pub type SendResult = result::Result<(), SendError>; /// let destination = destination.into(); /// match destination { /// MultiLocation { parents: 1, interior: Here } => Ok(()), -/// _ => Err(SendError::CannotReachDestination(destination, message)), +/// _ => Err(SendError::NotApplicable(destination, message)), /// } /// } /// } @@ -331,7 +331,7 @@ pub trait SendXcm { /// Send an XCM `message` to a given `destination`. /// /// If it is not a destination which can be reached with this type but possibly could by others, then it *MUST* - /// return `CannotReachDestination`. Any other error will cause the tuple implementation to exit early without + /// return `NotApplicable`. Any other error will cause the tuple implementation to exit early without /// trying other type fields. fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult; } @@ -342,10 +342,10 @@ impl SendXcm for Tuple { for_tuples!( #( // we shadow `destination` and `message` in each expansion for the next one. let (destination, message) = match Tuple::send_xcm(destination, message) { - Err(SendError::CannotReachDestination(d, m)) => (d, m), + Err(SendError::NotApplicable(d, m)) => (d, m), o @ _ => return o, }; )* ); - Err(SendError::CannotReachDestination(destination.into(), message)) + Err(SendError::NotApplicable(destination.into(), message)) } } diff --git a/xcm/src/v3/junction.rs b/xcm/src/v3/junction.rs new file mode 100644 index 000000000000..d0b323782444 --- /dev/null +++ b/xcm/src/v3/junction.rs @@ -0,0 +1,205 @@ +// Copyright 2020 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 . + +//! Support data structures for `MultiLocation`, primarily the `Junction` datatype. + +use super::{BodyId, BodyPart, Junctions, MultiLocation}; +use crate::{ + v2::{Junction as OldJunction, NetworkId as OldNetworkId}, + VersionedMultiLocation, +}; +use alloc::vec::Vec; +use core::convert::TryFrom; +use parity_scale_codec::{self, Decode, Encode}; +use scale_info::TypeInfo; + +/// A global identifier of a data structure existing within consensus. +/// +/// Maintenance note: Networks with global consensus and which are practically bridgeable within the +/// Polkadot ecosystem are given preference over explicit naming in this enumeration. +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum NetworkId { + /// Network specified by the first 32 bytes of its genesis block. + ByGenesis([u8; 32]), + /// Network defined by the first 32-bytes of the hash and number of some block it contains. + ByFork { block_number: u64, block_hash: [u8; 32] }, + /// The Polkadot mainnet Relay-chain. + Polkadot, + /// The Kusama canary-net Relay-chain. + Kusama, + /// The Westend testnet Relay-chain. + Westend, + /// The Rococo testnet Relay-chain. + Rococo, + /// The Wococo testnet Relay-chain. + Wococo, + /// The Ethereum network, including hard-forks supported by the Etheruem Foundation. + EthereumFoundation, + /// The Ethereum network, including hard-forks supported by Ethereum Classic developers. + EthereumClassic, + /// The Bitcoin network, including hard-forks supported by Bitcoin Core development team. + BitcoinCore, + /// The Bitcoin network, including hard-forks supported by Bitcoin Cash developers. + BitcoinCash, +} + +impl From for Option { + fn from(old: OldNetworkId) -> Option { + use OldNetworkId::*; + match old { + Any => None, + Named(_) => None, + Polkadot => Some(NetworkId::Polkadot), + Kusama => Some(NetworkId::Kusama), + } + } +} + +/// A single item in a path to describe the relative location of a consensus system. +/// +/// Each item assumes a pre-existing location as its context and is defined in terms of it. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum Junction { + /// An indexed parachain belonging to and operated by the context. + /// + /// Generally used when the context is a Polkadot Relay-chain. + Parachain(#[codec(compact)] u32), + /// A 32-byte identifier for an account of a specific network that is respected as a sovereign endpoint within + /// the context. + /// + /// Generally used when the context is a Substrate-based chain. + AccountId32 { network: Option, id: [u8; 32] }, + /// An 8-byte index for an account of a specific network that is respected as a sovereign endpoint within + /// the context. + /// + /// May be used when the context is a Frame-based chain and includes e.g. an indices pallet. + AccountIndex64 { + network: Option, + #[codec(compact)] + index: u64, + }, + /// A 20-byte identifier for an account of a specific network that is respected as a sovereign endpoint within + /// the context. + /// + /// May be used when the context is an Ethereum or Bitcoin chain or smart-contract. + AccountKey20 { network: Option, key: [u8; 20] }, + /// An instanced, indexed pallet that forms a constituent part of the context. + /// + /// Generally used when the context is a Frame-based chain. + PalletInstance(u8), + /// A non-descript index within the context location. + /// + /// Usage will vary widely owing to its generality. + /// + /// NOTE: Try to avoid using this and instead use a more specific item. + GeneralIndex(#[codec(compact)] u128), + /// A nondescript datum acting as a key within the context location. + /// + /// Usage will vary widely owing to its generality. + /// + /// NOTE: Try to avoid using this and instead use a more specific item. + GeneralKey(Vec), + /// The unambiguous child. + /// + /// Not currently used except as a fallback when deriving context. + OnlyChild, + /// A pluralistic body existing within consensus. + /// + /// Typical to be used to represent a governance origin of a chain, but could in principle be used to represent + /// things such as multisigs also. + Plurality { id: BodyId, part: BodyPart }, + /// A global network capable of externalizing its own consensus. This is not generally + /// meaningful outside of the universal level. + GlobalConsensus(NetworkId), +} + +impl From for Junction { + fn from(n: NetworkId) -> Self { + Self::GlobalConsensus(n) + } +} + +impl From<[u8; 32]> for Junction { + fn from(id: [u8; 32]) -> Self { + Self::AccountId32 { network: None, id } + } +} + +impl From<[u8; 20]> for Junction { + fn from(key: [u8; 20]) -> Self { + Self::AccountKey20 { network: None, key } + } +} + +impl From for Junction { + fn from(index: u64) -> Self { + Self::AccountIndex64 { network: None, index } + } +} + +impl From for Junction { + fn from(id: u128) -> Self { + Self::GeneralIndex(id) + } +} + +impl From> for Junction { + fn from(id: Vec) -> Self { + Self::GeneralKey(id) + } +} + +impl TryFrom for Junction { + type Error = (); + fn try_from(value: OldJunction) -> Result { + use OldJunction::*; + Ok(match value { + Parachain(id) => Self::Parachain(id), + AccountId32 { network, id } => Self::AccountId32 { network: network.into(), id }, + AccountIndex64 { network, index } => + Self::AccountIndex64 { network: network.into(), index }, + AccountKey20 { network, key } => Self::AccountKey20 { network: network.into(), key }, + PalletInstance(index) => Self::PalletInstance(index), + GeneralIndex(id) => Self::GeneralIndex(id), + GeneralKey(key) => Self::GeneralKey(key), + OnlyChild => Self::OnlyChild, + Plurality { id, part } => Self::Plurality { id: id.into(), part }, + }) + } +} + +impl Junction { + /// Convert `self` into a `MultiLocation` containing 0 parents. + /// + /// Similar to `Into::into`, except that this method can be used in a const evaluation context. + pub const fn into_location(self) -> MultiLocation { + MultiLocation { parents: 0, interior: Junctions::X1(self) } + } + + /// Convert `self` into a `MultiLocation` containing `n` parents. + /// + /// Similar to `Self::into_location`, with the added ability to specify the number of parent junctions. + pub const fn into_exterior(self, n: u8) -> MultiLocation { + MultiLocation { parents: n, interior: Junctions::X1(self) } + } + + /// Convert `self` into a `VersionedMultiLocation` containing 0 parents. + /// + /// Similar to `Into::into`, except that this method can be used in a const evaluation context. + pub const fn into_versioned(self) -> VersionedMultiLocation { + self.into_location().into_versioned() + } +} diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs new file mode 100644 index 000000000000..9ad0171c82a9 --- /dev/null +++ b/xcm/src/v3/junctions.rs @@ -0,0 +1,579 @@ +// Copyright 2020-2021 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 . + +//! XCM `Junctions`/`InteriorMultiLocation` datatype. + +use super::{Junction, MultiLocation, NetworkId}; +use core::{convert::TryFrom, mem, result}; +use parity_scale_codec::{Decode, Encode}; +use scale_info::TypeInfo; + +/// Maximum number of `Junction`s that a `Junctions` can contain. +pub(crate) const MAX_JUNCTIONS: usize = 8; + +/// Non-parent junctions that can be constructed, up to the length of 8. This specific `Junctions` +/// implementation uses a Rust `enum` in order to make pattern matching easier. +/// +/// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for +/// instructions on constructing parent junctions. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum Junctions { + /// The interpreting consensus system. + Here, + /// A relative path comprising 1 junction. + X1(Junction), + /// A relative path comprising 2 junctions. + X2(Junction, Junction), + /// A relative path comprising 3 junctions. + X3(Junction, Junction, Junction), + /// A relative path comprising 4 junctions. + X4(Junction, Junction, Junction, Junction), + /// A relative path comprising 5 junctions. + X5(Junction, Junction, Junction, Junction, Junction), + /// A relative path comprising 6 junctions. + X6(Junction, Junction, Junction, Junction, Junction, Junction), + /// A relative path comprising 7 junctions. + X7(Junction, Junction, Junction, Junction, Junction, Junction, Junction), + /// A relative path comprising 8 junctions. + X8(Junction, Junction, Junction, Junction, Junction, Junction, Junction, Junction), +} + +pub struct JunctionsIterator(Junctions); +impl Iterator for JunctionsIterator { + type Item = Junction; + fn next(&mut self) -> Option { + self.0.take_first() + } +} + +impl DoubleEndedIterator for JunctionsIterator { + fn next_back(&mut self) -> Option { + self.0.take_last() + } +} + +pub struct JunctionsRefIterator<'a> { + junctions: &'a Junctions, + next: usize, + back: usize, +} + +impl<'a> Iterator for JunctionsRefIterator<'a> { + type Item = &'a Junction; + fn next(&mut self) -> Option<&'a Junction> { + if self.next.saturating_add(self.back) >= self.junctions.len() { + return None + } + + let result = self.junctions.at(self.next); + self.next += 1; + result + } +} + +impl<'a> DoubleEndedIterator for JunctionsRefIterator<'a> { + fn next_back(&mut self) -> Option<&'a Junction> { + let next_back = self.back.saturating_add(1); + // checked_sub here, because if the result is less than 0, we end iteration + let index = self.junctions.len().checked_sub(next_back)?; + if self.next > index { + return None + } + self.back = next_back; + + self.junctions.at(index) + } +} + +impl<'a> IntoIterator for &'a Junctions { + type Item = &'a Junction; + type IntoIter = JunctionsRefIterator<'a>; + fn into_iter(self) -> Self::IntoIter { + JunctionsRefIterator { junctions: self, next: 0, back: 0 } + } +} + +impl IntoIterator for Junctions { + type Item = Junction; + type IntoIter = JunctionsIterator; + fn into_iter(self) -> Self::IntoIter { + JunctionsIterator(self) + } +} + +impl Junctions { + /// Convert `self` into a `MultiLocation` containing 0 parents. + /// + /// Similar to `Into::into`, except that this method can be used in a const evaluation context. + pub const fn into_location(self) -> MultiLocation { + MultiLocation { parents: 0, interior: self } + } + + /// Convert `self` into a `MultiLocation` containing `n` parents. + /// + /// Similar to `Self::into_location`, with the added ability to specify the number of parent junctions. + pub const fn into_exterior(self, n: u8) -> MultiLocation { + MultiLocation { parents: n, interior: self } + } + + /// Extract the network ID treating this value as a universal location. + /// + /// This will return an `Err` if the first item is not a `GlobalConsensus`, which would indicate + /// that this value is not a universal location. + pub fn global_consensus(&self) -> Result { + if let Some(Junction::GlobalConsensus(ref network)) = self.first() { + Ok(network.clone()) + } else { + Err(()) + } + } + + /// Consumes `self` and returns how `viewer` would address it locally. + pub fn relative_to(mut self, viewer: &Junctions) -> MultiLocation { + let mut i = 0; + while match (self.first(), viewer.at(i)) { + (Some(x), Some(y)) => x == y, + _ => false, + } { + self = self.split_first().0; + // NOTE: Cannot overflow as loop can only iterate at most `MAX_JUNCTIONS` times. + i += 1; + } + // AUDIT NOTES: + // - above loop ensures that `i <= viewer.len()`. + // - `viewer.len()` is at most `MAX_JUNCTIONS`, so won't overflow a `u8`. + MultiLocation { parents: (viewer.len() - i) as u8, interior: self } + } + + /// Returns first junction, or `None` if the location is empty. + pub fn first(&self) -> Option<&Junction> { + match &self { + Junctions::Here => None, + Junctions::X1(ref a) => Some(a), + Junctions::X2(ref a, ..) => Some(a), + Junctions::X3(ref a, ..) => Some(a), + Junctions::X4(ref a, ..) => Some(a), + Junctions::X5(ref a, ..) => Some(a), + Junctions::X6(ref a, ..) => Some(a), + Junctions::X7(ref a, ..) => Some(a), + Junctions::X8(ref a, ..) => Some(a), + } + } + + /// Returns last junction, or `None` if the location is empty. + pub fn last(&self) -> Option<&Junction> { + match &self { + Junctions::Here => None, + Junctions::X1(ref a) => Some(a), + Junctions::X2(.., ref a) => Some(a), + Junctions::X3(.., ref a) => Some(a), + Junctions::X4(.., ref a) => Some(a), + Junctions::X5(.., ref a) => Some(a), + Junctions::X6(.., ref a) => Some(a), + Junctions::X7(.., ref a) => Some(a), + Junctions::X8(.., ref a) => Some(a), + } + } + + /// Splits off the first junction, returning the remaining suffix (first item in tuple) and the first element + /// (second item in tuple) or `None` if it was empty. + pub fn split_first(self) -> (Junctions, Option) { + match self { + Junctions::Here => (Junctions::Here, None), + Junctions::X1(a) => (Junctions::Here, Some(a)), + Junctions::X2(a, b) => (Junctions::X1(b), Some(a)), + Junctions::X3(a, b, c) => (Junctions::X2(b, c), Some(a)), + Junctions::X4(a, b, c, d) => (Junctions::X3(b, c, d), Some(a)), + Junctions::X5(a, b, c, d, e) => (Junctions::X4(b, c, d, e), Some(a)), + Junctions::X6(a, b, c, d, e, f) => (Junctions::X5(b, c, d, e, f), Some(a)), + Junctions::X7(a, b, c, d, e, f, g) => (Junctions::X6(b, c, d, e, f, g), Some(a)), + Junctions::X8(a, b, c, d, e, f, g, h) => (Junctions::X7(b, c, d, e, f, g, h), Some(a)), + } + } + + /// Splits off the last junction, returning the remaining prefix (first item in tuple) and the last element + /// (second item in tuple) or `None` if it was empty. + pub fn split_last(self) -> (Junctions, Option) { + match self { + Junctions::Here => (Junctions::Here, None), + Junctions::X1(a) => (Junctions::Here, Some(a)), + Junctions::X2(a, b) => (Junctions::X1(a), Some(b)), + Junctions::X3(a, b, c) => (Junctions::X2(a, b), Some(c)), + Junctions::X4(a, b, c, d) => (Junctions::X3(a, b, c), Some(d)), + Junctions::X5(a, b, c, d, e) => (Junctions::X4(a, b, c, d), Some(e)), + Junctions::X6(a, b, c, d, e, f) => (Junctions::X5(a, b, c, d, e), Some(f)), + Junctions::X7(a, b, c, d, e, f, g) => (Junctions::X6(a, b, c, d, e, f), Some(g)), + Junctions::X8(a, b, c, d, e, f, g, h) => (Junctions::X7(a, b, c, d, e, f, g), Some(h)), + } + } + + /// Removes the first element from `self`, returning it (or `None` if it was empty). + pub fn take_first(&mut self) -> Option { + let mut d = Junctions::Here; + mem::swap(&mut *self, &mut d); + let (tail, head) = d.split_first(); + *self = tail; + head + } + + /// Removes the last element from `self`, returning it (or `None` if it was empty). + pub fn take_last(&mut self) -> Option { + let mut d = Junctions::Here; + mem::swap(&mut *self, &mut d); + let (head, tail) = d.split_last(); + *self = head; + tail + } + + /// Mutates `self` to be appended with `new` or returns an `Err` with `new` if would overflow. + pub fn push(&mut self, new: impl Into) -> result::Result<(), Junction> { + let new = new.into(); + let mut dummy = Junctions::Here; + mem::swap(self, &mut dummy); + match dummy.pushed_with(new) { + Ok(s) => { + *self = s; + Ok(()) + }, + Err((s, j)) => { + *self = s; + Err(j) + }, + } + } + + /// Mutates `self` to be prepended with `new` or returns an `Err` with `new` if would overflow. + pub fn push_front(&mut self, new: impl Into) -> result::Result<(), Junction> { + let new = new.into(); + let mut dummy = Junctions::Here; + mem::swap(self, &mut dummy); + match dummy.pushed_front_with(new) { + Ok(s) => { + *self = s; + Ok(()) + }, + Err((s, j)) => { + *self = s; + Err(j) + }, + } + } + + /// Consumes `self` and returns a `Junctions` suffixed with `new`, or an `Err` with the + /// original value of `self` and `new` in case of overflow. + pub fn pushed_with(self, new: impl Into) -> result::Result { + let new = new.into(); + Ok(match self { + Junctions::Here => Junctions::X1(new), + Junctions::X1(a) => Junctions::X2(a, new), + Junctions::X2(a, b) => Junctions::X3(a, b, new), + Junctions::X3(a, b, c) => Junctions::X4(a, b, c, new), + Junctions::X4(a, b, c, d) => Junctions::X5(a, b, c, d, new), + Junctions::X5(a, b, c, d, e) => Junctions::X6(a, b, c, d, e, new), + Junctions::X6(a, b, c, d, e, f) => Junctions::X7(a, b, c, d, e, f, new), + Junctions::X7(a, b, c, d, e, f, g) => Junctions::X8(a, b, c, d, e, f, g, new), + s => Err((s, new))?, + }) + } + + /// Consumes `self` and returns a `Junctions` prefixed with `new`, or an `Err` with the + /// original value of `self` and `new` in case of overflow. + pub fn pushed_front_with( + self, + new: impl Into, + ) -> result::Result { + let new = new.into(); + Ok(match self { + Junctions::Here => Junctions::X1(new), + Junctions::X1(a) => Junctions::X2(new, a), + Junctions::X2(a, b) => Junctions::X3(new, a, b), + Junctions::X3(a, b, c) => Junctions::X4(new, a, b, c), + Junctions::X4(a, b, c, d) => Junctions::X5(new, a, b, c, d), + Junctions::X5(a, b, c, d, e) => Junctions::X6(new, a, b, c, d, e), + Junctions::X6(a, b, c, d, e, f) => Junctions::X7(new, a, b, c, d, e, f), + Junctions::X7(a, b, c, d, e, f, g) => Junctions::X8(new, a, b, c, d, e, f, g), + s => Err((s, new))?, + }) + } + + /// Mutate `self` so that it is suffixed with `suffix`. + /// + /// Does not modify `self` and returns `Err` with `suffix` in case of overflow. + /// + /// # Example + /// ```rust + /// # use xcm::v3::{Junctions::*, Junction::*, MultiLocation}; + /// # fn main() { + /// let mut m = X1(Parachain(21)); + /// assert_eq!(m.append_with(X1(PalletInstance(3))), Ok(())); + /// assert_eq!(m, X2(Parachain(21), PalletInstance(3))); + /// # } + /// ``` + pub fn append_with(&mut self, suffix: impl Into) -> Result<(), Junctions> { + let suffix = suffix.into(); + if self.len().saturating_add(suffix.len()) > MAX_JUNCTIONS { + return Err(suffix) + } + for j in suffix.into_iter() { + self.push(j).expect("Already checked the sum of the len()s; qed") + } + Ok(()) + } + + /// Returns the number of junctions in `self`. + pub const fn len(&self) -> usize { + match &self { + Junctions::Here => 0, + Junctions::X1(..) => 1, + Junctions::X2(..) => 2, + Junctions::X3(..) => 3, + Junctions::X4(..) => 4, + Junctions::X5(..) => 5, + Junctions::X6(..) => 6, + Junctions::X7(..) => 7, + Junctions::X8(..) => 8, + } + } + + /// Returns the junction at index `i`, or `None` if the location doesn't contain that many elements. + pub fn at(&self, i: usize) -> Option<&Junction> { + Some(match (i, self) { + (0, Junctions::X1(ref a)) => a, + (0, Junctions::X2(ref a, ..)) => a, + (0, Junctions::X3(ref a, ..)) => a, + (0, Junctions::X4(ref a, ..)) => a, + (0, Junctions::X5(ref a, ..)) => a, + (0, Junctions::X6(ref a, ..)) => a, + (0, Junctions::X7(ref a, ..)) => a, + (0, Junctions::X8(ref a, ..)) => a, + (1, Junctions::X2(_, ref a)) => a, + (1, Junctions::X3(_, ref a, ..)) => a, + (1, Junctions::X4(_, ref a, ..)) => a, + (1, Junctions::X5(_, ref a, ..)) => a, + (1, Junctions::X6(_, ref a, ..)) => a, + (1, Junctions::X7(_, ref a, ..)) => a, + (1, Junctions::X8(_, ref a, ..)) => a, + (2, Junctions::X3(_, _, ref a)) => a, + (2, Junctions::X4(_, _, ref a, ..)) => a, + (2, Junctions::X5(_, _, ref a, ..)) => a, + (2, Junctions::X6(_, _, ref a, ..)) => a, + (2, Junctions::X7(_, _, ref a, ..)) => a, + (2, Junctions::X8(_, _, ref a, ..)) => a, + (3, Junctions::X4(_, _, _, ref a)) => a, + (3, Junctions::X5(_, _, _, ref a, ..)) => a, + (3, Junctions::X6(_, _, _, ref a, ..)) => a, + (3, Junctions::X7(_, _, _, ref a, ..)) => a, + (3, Junctions::X8(_, _, _, ref a, ..)) => a, + (4, Junctions::X5(_, _, _, _, ref a)) => a, + (4, Junctions::X6(_, _, _, _, ref a, ..)) => a, + (4, Junctions::X7(_, _, _, _, ref a, ..)) => a, + (4, Junctions::X8(_, _, _, _, ref a, ..)) => a, + (5, Junctions::X6(_, _, _, _, _, ref a)) => a, + (5, Junctions::X7(_, _, _, _, _, ref a, ..)) => a, + (5, Junctions::X8(_, _, _, _, _, ref a, ..)) => a, + (6, Junctions::X7(_, _, _, _, _, _, ref a)) => a, + (6, Junctions::X8(_, _, _, _, _, _, ref a, ..)) => a, + (7, Junctions::X8(_, _, _, _, _, _, _, ref a)) => a, + _ => return None, + }) + } + + /// Returns a mutable reference to the junction at index `i`, or `None` if the location doesn't contain that many + /// elements. + pub fn at_mut(&mut self, i: usize) -> Option<&mut Junction> { + Some(match (i, self) { + (0, Junctions::X1(ref mut a)) => a, + (0, Junctions::X2(ref mut a, ..)) => a, + (0, Junctions::X3(ref mut a, ..)) => a, + (0, Junctions::X4(ref mut a, ..)) => a, + (0, Junctions::X5(ref mut a, ..)) => a, + (0, Junctions::X6(ref mut a, ..)) => a, + (0, Junctions::X7(ref mut a, ..)) => a, + (0, Junctions::X8(ref mut a, ..)) => a, + (1, Junctions::X2(_, ref mut a)) => a, + (1, Junctions::X3(_, ref mut a, ..)) => a, + (1, Junctions::X4(_, ref mut a, ..)) => a, + (1, Junctions::X5(_, ref mut a, ..)) => a, + (1, Junctions::X6(_, ref mut a, ..)) => a, + (1, Junctions::X7(_, ref mut a, ..)) => a, + (1, Junctions::X8(_, ref mut a, ..)) => a, + (2, Junctions::X3(_, _, ref mut a)) => a, + (2, Junctions::X4(_, _, ref mut a, ..)) => a, + (2, Junctions::X5(_, _, ref mut a, ..)) => a, + (2, Junctions::X6(_, _, ref mut a, ..)) => a, + (2, Junctions::X7(_, _, ref mut a, ..)) => a, + (2, Junctions::X8(_, _, ref mut a, ..)) => a, + (3, Junctions::X4(_, _, _, ref mut a)) => a, + (3, Junctions::X5(_, _, _, ref mut a, ..)) => a, + (3, Junctions::X6(_, _, _, ref mut a, ..)) => a, + (3, Junctions::X7(_, _, _, ref mut a, ..)) => a, + (3, Junctions::X8(_, _, _, ref mut a, ..)) => a, + (4, Junctions::X5(_, _, _, _, ref mut a)) => a, + (4, Junctions::X6(_, _, _, _, ref mut a, ..)) => a, + (4, Junctions::X7(_, _, _, _, ref mut a, ..)) => a, + (4, Junctions::X8(_, _, _, _, ref mut a, ..)) => a, + (5, Junctions::X6(_, _, _, _, _, ref mut a)) => a, + (5, Junctions::X7(_, _, _, _, _, ref mut a, ..)) => a, + (5, Junctions::X8(_, _, _, _, _, ref mut a, ..)) => a, + (6, Junctions::X7(_, _, _, _, _, _, ref mut a)) => a, + (6, Junctions::X8(_, _, _, _, _, _, ref mut a, ..)) => a, + (7, Junctions::X8(_, _, _, _, _, _, _, ref mut a)) => a, + _ => return None, + }) + } + + /// Returns a reference iterator over the junctions. + pub fn iter(&self) -> JunctionsRefIterator { + JunctionsRefIterator { junctions: self, next: 0, back: 0 } + } + + /// Ensures that self begins with `prefix` and that it has a single `Junction` item following. + /// If so, returns a reference to this `Junction` item. + /// + /// # Example + /// ```rust + /// # use xcm::v3::{Junctions::*, Junction::*}; + /// # fn main() { + /// let mut m = X3(Parachain(2), PalletInstance(3), OnlyChild); + /// assert_eq!(m.match_and_split(&X2(Parachain(2), PalletInstance(3))), Some(&OnlyChild)); + /// assert_eq!(m.match_and_split(&X1(Parachain(2))), None); + /// # } + /// ``` + pub fn match_and_split(&self, prefix: &Junctions) -> Option<&Junction> { + if prefix.len() + 1 != self.len() { + return None + } + for i in 0..prefix.len() { + if prefix.at(i) != self.at(i) { + return None + } + } + return self.at(prefix.len()) + } +} + +impl TryFrom for Junctions { + type Error = MultiLocation; + fn try_from(x: MultiLocation) -> result::Result { + if x.parents > 0 { + Err(x) + } else { + Ok(x.interior) + } + } +} + +impl> From for Junctions { + fn from(x: T) -> Self { + Self::X1(x.into()) + } +} + +impl From<[Junction; 0]> for Junctions { + fn from(_: [Junction; 0]) -> Self { + Self::Here + } +} + +impl From<()> for Junctions { + fn from(_: ()) -> Self { + Self::Here + } +} + +xcm_procedural::impl_conversion_functions_for_junctions_v3!(); + +#[cfg(test)] +mod tests { + use super::{super::prelude::*, *}; + use alloc::vec; + + #[test] + fn relative_to_works() { + use Junctions::*; + use NetworkId::*; + assert_eq!(X1(Polkadot.into()).relative_to(&X1(Kusama.into())), (Parent, Polkadot).into()); + let base = X3(Kusama.into(), Parachain(1), PalletInstance(1)); + + // Ancestors. + assert_eq!(Here.relative_to(&base), (Parent, Parent, Parent).into()); + assert_eq!(X1(Kusama.into()).relative_to(&base), (Parent, Parent).into()); + assert_eq!(X2(Kusama.into(), Parachain(1)).relative_to(&base), (Parent,).into()); + assert_eq!( + X3(Kusama.into(), Parachain(1), PalletInstance(1)).relative_to(&base), + Here.into() + ); + + // Ancestors with one child. + assert_eq!( + X1(Polkadot.into()).relative_to(&base), + (Parent, Parent, Parent, Polkadot).into() + ); + assert_eq!( + X2(Kusama.into(), Parachain(2)).relative_to(&base), + (Parent, Parent, Parachain(2)).into() + ); + assert_eq!( + X3(Kusama.into(), Parachain(1), PalletInstance(2)).relative_to(&base), + (Parent, PalletInstance(2)).into() + ); + assert_eq!( + X4(Kusama.into(), Parachain(1), PalletInstance(1), [1u8; 32].into()).relative_to(&base), + ([1u8; 32],).into() + ); + + // Ancestors with grandchildren. + assert_eq!( + X2(Polkadot.into(), Parachain(1)).relative_to(&base), + (Parent, Parent, Parent, Polkadot, Parachain(1)).into() + ); + assert_eq!( + X3(Kusama.into(), Parachain(2), PalletInstance(1)).relative_to(&base), + (Parent, Parent, Parachain(2), PalletInstance(1)).into() + ); + assert_eq!( + X4(Kusama.into(), Parachain(1), PalletInstance(2), [1u8; 32].into()).relative_to(&base), + (Parent, PalletInstance(2), [1u8; 32]).into() + ); + assert_eq!( + X5(Kusama.into(), Parachain(1), PalletInstance(1), [1u8; 32].into(), vec![1].into()) + .relative_to(&base), + ([1u8; 32], vec![1]).into() + ); + } + + #[test] + fn global_consensus_works() { + use Junctions::*; + use NetworkId::*; + assert_eq!(X1(Polkadot.into()).global_consensus(), Ok(Polkadot)); + assert_eq!(X2(Kusama.into(), 1u64.into()).global_consensus(), Ok(Kusama)); + assert_eq!(Here.global_consensus(), Err(())); + assert_eq!(X1(1u64.into()).global_consensus(), Err(())); + assert_eq!(X2(1u64.into(), Kusama.into()).global_consensus(), Err(())); + } + + #[test] + fn test_conversion() { + use super::{Junction::*, Junctions::*, NetworkId::*}; + let x: Junctions = GlobalConsensus(Polkadot).into(); + assert_eq!(x, X1(GlobalConsensus(Polkadot))); + let x: Junctions = Polkadot.into(); + assert_eq!(x, X1(GlobalConsensus(Polkadot))); + let x: Junctions = (Polkadot, Kusama).into(); + assert_eq!(x, X2(GlobalConsensus(Polkadot), GlobalConsensus(Kusama))); + } +} diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 85535badc66d..10a8b8ac0726 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -28,19 +28,27 @@ use derivative::Derivative; use parity_scale_codec::{self, Decode, Encode}; use scale_info::TypeInfo; +mod junction; +pub(crate) mod junctions; mod multiasset; +mod multilocation; mod traits; +pub use junction::{Junction, NetworkId}; +pub use junctions::Junctions; pub use multiasset::{ AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssetFilter, MultiAssets, WildFungibility, WildMultiAsset, }; -pub use traits::{Error, ExecuteXcm, Outcome, Result, SendError, SendResult, SendXcm}; -// These parts of XCM v2 are unchanged in XCM v3, and are re-imported here. -pub use super::v2::{ - Ancestor, AncestorThen, BodyId, BodyPart, InteriorMultiLocation, Junction, Junctions, - MultiLocation, NetworkId, OriginKind, Parent, ParentThen, Weight, WeightLimit, +pub use multilocation::{ + Ancestor, AncestorThen, InteriorMultiLocation, MultiLocation, Parent, ParentThen, +}; +pub use traits::{ + send_xcm, validate_send, Error, ExecuteXcm, Outcome, PreparedMessage, Result, SendError, + SendResult, SendXcm, Unwrappable, Weight, }; +// These parts of XCM v2 are unchanged in XCM v3, and are re-imported here. +pub use super::v2::{BodyId, BodyPart, OriginKind, WeightLimit}; /// This module's XCM version. pub const VERSION: super::Version = 3; @@ -71,6 +79,36 @@ impl Xcm { self.0.len() } + /// Return a reference to the inner value. + pub fn inner(&self) -> &[Instruction] { + &self.0 + } + + /// Return a mutable reference to the inner value. + pub fn inner_mut(&mut self) -> &mut Vec> { + &mut self.0 + } + + /// Consume and return the inner value. + pub fn into_inner(self) -> Vec> { + self.0 + } + + /// Return an iterator over references to the items. + pub fn iter(&self) -> impl Iterator> { + self.0.iter() + } + + /// Return an iterator over mutable references to the items. + pub fn iter_mut(&mut self) -> impl Iterator> { + self.0.iter_mut() + } + + /// Consume and return an iterator over the items. + pub fn into_iter(self) -> impl Iterator> { + self.0.into_iter() + } + /// Consume and either return `self` if it contains some instructions, or if it's empty, then /// instead return the result of `f`. pub fn or_else(self, f: impl FnOnce() -> Self) -> Self { @@ -111,11 +149,23 @@ impl Xcm { } } +impl From>> for Xcm { + fn from(c: Vec>) -> Self { + Self(c) + } +} + +impl From> for Vec> { + fn from(c: Xcm) -> Self { + c.0 + } +} + /// A prelude for importing all types typically used when interacting with XCM messages. pub mod prelude { mod contents { pub use super::super::{ - Ancestor, AncestorThen, + send_xcm, validate_send, Ancestor, AncestorThen, AssetId::{self, *}, AssetInstance::{self, *}, BodyId, BodyPart, Error as XcmError, ExecuteXcm, @@ -124,12 +174,13 @@ pub mod prelude { InteriorMultiLocation, Junction::{self, *}, Junctions::{self, *}, - MultiAsset, + MaybeErrorCode, MultiAsset, MultiAssetFilter::{self, *}, MultiAssets, MultiLocation, NetworkId::{self, *}, - OriginKind, Outcome, Parent, ParentThen, QueryId, QueryResponseInfo, Response, - Result as XcmResult, SendError, SendResult, SendXcm, + OriginKind, Outcome, PalletInfo, Parent, ParentThen, PreparedMessage, QueryId, + QueryResponseInfo, Response, Result as XcmResult, SendError, SendResult, SendXcm, + Unwrappable, WeightLimit::{self, *}, WildFungibility::{self, Fungible as WildFungible, NonFungible as WildNonFungible}, WildMultiAsset::{self, *}, @@ -319,7 +370,7 @@ pub enum Instruction { TransferReserveAsset { assets: MultiAssets, dest: MultiLocation, xcm: Xcm<()> }, /// Apply the encoded transaction `call`, whose dispatch-origin should be `origin` as expressed - /// by the kind of origin `origin_type`. + /// by the kind of origin `origin_kind`. /// /// The Transact Status Register is set according to the result of dispatching the call. /// @@ -716,6 +767,42 @@ pub enum Instruction { /// /// Errors: *Infallible*. ClearTransactStatus, + + /// Set the Origin Register to be some child of the Universal Ancestor. + /// + /// Safety: Should only be usable if the Origin is trusted to represent the Universal Ancestor + /// child in general. In general, no Origin should be able to represent the Universal Ancestor + /// child which is the root of the local consensus system since it would by extension + /// allow it to act as any location within the local consensus. + /// + /// The `Junction` parameter should generally be a `GlobalConsensus` variant since it is only + /// these which are children of the Universal Ancestor. + /// + /// Kind: *Instruction* + /// + /// Errors: *Fallible*. + UniversalOrigin(Junction), + + /// Send a message on to Non-Local Consensus system. + /// + /// This will tend to utilize some extra-consensus mechanism, the obvious one being a bridge. + /// A fee may be charged; this may be determined based on the contents of `xcm`. It will be + /// taken from the Holding register. + /// + /// - `network`: The remote consensus system to which the message should be exported. + /// - `destination`: The location relative to the remote consensus system to which the message + /// should be sent on arrival. + /// - `xcm`: The message to be exported. + /// + /// As an example, to export a message for execution on Statemine (parachain #1000 in the + /// Kusama network), you would call with `network: NetworkId::Kusama` and + /// `destination: X1(Parachain(1000))`. Alternatively, to export a message for execution on + /// Polkadot, you would call with `network: NetworkId:: Polkadot` and `destination: Here`. + /// + /// Kind: *Instruction* + /// + /// Errors: *Fallible*. + ExportMessage { network: NetworkId, destination: InteriorMultiLocation, xcm: Xcm<()> }, } impl Xcm { @@ -779,6 +866,9 @@ impl Instruction { ExpectPallet { index, name, module_name, crate_major, min_crate_minor }, ReportTransactStatus(response_info) => ReportTransactStatus(response_info), ClearTransactStatus => ClearTransactStatus, + UniversalOrigin(j) => UniversalOrigin(j), + ExportMessage { network, destination, xcm } => + ExportMessage { network, destination, xcm }, } } } @@ -834,6 +924,9 @@ impl> GetWeight for Instruction { W::expect_pallet(index, name, module_name, crate_major, min_crate_minor), ReportTransactStatus(response_info) => W::report_transact_status(response_info), ClearTransactStatus => W::clear_transact_status(), + UniversalOrigin(j) => W::universal_origin(j), + ExportMessage { network, destination, xcm } => + W::export_message(network, destination, xcm), } } } @@ -853,7 +946,7 @@ impl TryFrom for Response { type Error = (); fn try_from(old_response: OldResponse) -> result::Result { match old_response { - OldResponse::Assets(assets) => Ok(Self::Assets(assets)), + OldResponse::Assets(assets) => Ok(Self::Assets(assets.try_into()?)), OldResponse::Version(version) => Ok(Self::Version(version)), OldResponse::ExecutionResult(error) => Ok(Self::ExecutionResult(match error { Some((i, e)) => Some((i, e.try_into()?)), @@ -878,18 +971,24 @@ impl TryFrom> for Instruction { fn try_from(old_instruction: OldInstruction) -> result::Result { use OldInstruction::*; Ok(match old_instruction { - WithdrawAsset(assets) => Self::WithdrawAsset(assets), - ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets), - ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets), + WithdrawAsset(assets) => Self::WithdrawAsset(assets.try_into()?), + ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets.try_into()?), + ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets.try_into()?), QueryResponse { query_id, response, max_weight } => Self::QueryResponse { query_id, response: response.try_into()?, max_weight, querier: None, }, - TransferAsset { assets, beneficiary } => Self::TransferAsset { assets, beneficiary }, - TransferReserveAsset { assets, dest, xcm } => - Self::TransferReserveAsset { assets, dest, xcm: xcm.try_into()? }, + TransferAsset { assets, beneficiary } => Self::TransferAsset { + assets: assets.try_into()?, + beneficiary: beneficiary.try_into()?, + }, + TransferReserveAsset { assets, dest, xcm } => Self::TransferReserveAsset { + assets: assets.try_into()?, + dest: dest.try_into()?, + xcm: xcm.try_into()?, + }, HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => Self::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, HrmpChannelAccepted { recipient } => Self::HrmpChannelAccepted { recipient }, @@ -902,42 +1001,56 @@ impl TryFrom> for Instruction { }, ReportError { query_id, dest, max_response_weight } => { let response_info = QueryResponseInfo { - destination: dest, + destination: dest.try_into()?, query_id, max_weight: max_response_weight, }; Self::ReportError(response_info) }, - DepositAsset { assets, max_assets, beneficiary } => - Self::DepositAsset { assets: (assets, max_assets).try_into()?, beneficiary }, + DepositAsset { assets, max_assets, beneficiary } => Self::DepositAsset { + assets: (assets, max_assets).try_into()?, + beneficiary: beneficiary.try_into()?, + }, DepositReserveAsset { assets, max_assets, dest, xcm } => { let assets = (assets, max_assets).try_into()?; - Self::DepositReserveAsset { assets, dest, xcm: xcm.try_into()? } + Self::DepositReserveAsset { assets, dest: dest.try_into()?, xcm: xcm.try_into()? } + }, + ExchangeAsset { give, receive } => { + let give = give.try_into()?; + let receive = receive.try_into()?; + Self::ExchangeAsset { give, receive } }, - ExchangeAsset { give, receive } => Self::ExchangeAsset { give: give.into(), receive }, InitiateReserveWithdraw { assets, reserve, xcm } => Self::InitiateReserveWithdraw { - assets: assets.into(), - reserve, + assets: assets.try_into()?, + reserve: reserve.try_into()?, + xcm: xcm.try_into()?, + }, + InitiateTeleport { assets, dest, xcm } => Self::InitiateTeleport { + assets: assets.try_into()?, + dest: dest.try_into()?, xcm: xcm.try_into()?, }, - InitiateTeleport { assets, dest, xcm } => - Self::InitiateTeleport { assets: assets.into(), dest, xcm: xcm.try_into()? }, QueryHolding { query_id, dest, assets, max_response_weight } => { let response_info = QueryResponseInfo { - destination: dest, + destination: dest.try_into()?, query_id, max_weight: max_response_weight, }; - Self::ReportHolding { response_info, assets: assets.into() } + Self::ReportHolding { response_info, assets: assets.try_into()? } }, - BuyExecution { fees, weight_limit } => Self::BuyExecution { fees, weight_limit }, + BuyExecution { fees, weight_limit } => + Self::BuyExecution { fees: fees.try_into()?, weight_limit }, ClearOrigin => Self::ClearOrigin, - DescendOrigin(who) => Self::DescendOrigin(who), + DescendOrigin(who) => Self::DescendOrigin(who.try_into()?), RefundSurplus => Self::RefundSurplus, SetErrorHandler(xcm) => Self::SetErrorHandler(xcm.try_into()?), SetAppendix(xcm) => Self::SetAppendix(xcm.try_into()?), ClearError => Self::ClearError, - ClaimAsset { assets, ticket } => Self::ClaimAsset { assets, ticket }, + ClaimAsset { assets, ticket } => { + let assets = assets.try_into()?; + let ticket = ticket.try_into()?; + Self::ClaimAsset { assets, ticket } + }, Trap(code) => Self::Trap(code), SubscribeVersion { query_id, max_response_weight } => Self::SubscribeVersion { query_id, max_response_weight }, @@ -949,15 +1062,18 @@ impl TryFrom> for Instruction { #[cfg(test)] mod tests { use super::{prelude::*, *}; - use crate::v2::{MultiAssetFilter as OldMultiAssetFilter, WildMultiAsset as OldWildMultiAsset}; + use crate::v2::{ + Junctions::Here as OldHere, MultiAssetFilter as OldMultiAssetFilter, + WildMultiAsset as OldWildMultiAsset, + }; #[test] fn basic_roundtrip_works() { let xcm = Xcm::<()>(vec![TransferAsset { assets: (Here, 1).into(), beneficiary: Here.into() }]); let old_xcm = OldXcm::<()>(vec![OldInstruction::TransferAsset { - assets: (Here, 1).into(), - beneficiary: Here.into(), + assets: (OldHere, 1).into(), + beneficiary: OldHere.into(), }]); assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); @@ -972,12 +1088,12 @@ mod tests { DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); let old_xcm: OldXcm<()> = OldXcm::<()>(vec![ - OldInstruction::ReceiveTeleportedAsset((Here, 1).into()), + OldInstruction::ReceiveTeleportedAsset((OldHere, 1).into()), OldInstruction::ClearOrigin, OldInstruction::DepositAsset { assets: crate::v2::MultiAssetFilter::Wild(crate::v2::WildMultiAsset::All), max_assets: 1, - beneficiary: Here.into(), + beneficiary: OldHere.into(), }, ]); assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); @@ -994,13 +1110,16 @@ mod tests { DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); let old_xcm = OldXcm::<()>(vec![ - OldInstruction::ReserveAssetDeposited((Here, 1).into()), + OldInstruction::ReserveAssetDeposited((OldHere, 1).into()), OldInstruction::ClearOrigin, - OldInstruction::BuyExecution { fees: (Here, 1).into(), weight_limit: Some(1).into() }, + OldInstruction::BuyExecution { + fees: (OldHere, 1).into(), + weight_limit: Some(1).into(), + }, OldInstruction::DepositAsset { assets: crate::v2::MultiAssetFilter::Wild(crate::v2::WildMultiAsset::All), max_assets: 1, - beneficiary: Here.into(), + beneficiary: OldHere.into(), }, ]); assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); @@ -1015,11 +1134,11 @@ mod tests { DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); let old_xcm = OldXcm::<()>(vec![ - OldInstruction::WithdrawAsset((Here, 1).into()), + OldInstruction::WithdrawAsset((OldHere, 1).into()), OldInstruction::DepositAsset { assets: OldMultiAssetFilter::Wild(OldWildMultiAsset::All), max_assets: 1, - beneficiary: Here.into(), + beneficiary: OldHere.into(), }, ]); assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); @@ -1038,11 +1157,11 @@ mod tests { }, ]); let old_xcm = OldXcm::<()>(vec![ - OldInstruction::WithdrawAsset((Here, 1).into()), + OldInstruction::WithdrawAsset((OldHere, 1).into()), OldInstruction::DepositReserveAsset { assets: OldMultiAssetFilter::Wild(OldWildMultiAsset::All), max_assets: 1, - dest: Here.into(), + dest: OldHere.into(), xcm: OldXcm::<()>(vec![]), }, ]); diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index 702e6d29ece5..83cd37109f6d 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -24,16 +24,326 @@ //! account. use super::MultiLocation; -use crate::v2::{MultiAssetFilter as OldMultiAssetFilter, WildMultiAsset as OldWildMultiAsset}; +use crate::v2::{ + AssetId as OldAssetId, MultiAsset as OldMultiAsset, MultiAssetFilter as OldMultiAssetFilter, + MultiAssets as OldMultiAssets, WildMultiAsset as OldWildMultiAsset, +}; use alloc::{vec, vec::Vec}; -use core::convert::TryFrom; -use parity_scale_codec::{Decode, Encode}; +use core::{ + cmp::Ordering, + convert::{TryFrom, TryInto}, +}; +use parity_scale_codec::{self as codec, Decode, Encode}; use scale_info::TypeInfo; -/// These are unchanged from XCM version 2 to version 3. -pub use crate::v2::{ - AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssets, WildFungibility, -}; +pub use crate::v2::{AssetInstance, Fungibility, WildFungibility}; + +/// Classification of an asset being concrete or abstract. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +pub enum AssetId { + Concrete(MultiLocation), + Abstract(Vec), +} + +impl> From for AssetId { + fn from(x: T) -> Self { + Self::Concrete(x.into()) + } +} + +impl From> for AssetId { + fn from(x: Vec) -> Self { + Self::Abstract(x) + } +} + +impl TryFrom for AssetId { + type Error = (); + fn try_from(old: OldAssetId) -> Result { + use OldAssetId::*; + Ok(match old { + Concrete(l) => Self::Concrete(l.try_into()?), + Abstract(v) => Self::Abstract(v), + }) + } +} + +impl AssetId { + /// Prepend a `MultiLocation` to a concrete asset, giving it a new root location. + pub fn prepend_with(&mut self, prepend: &MultiLocation) -> Result<(), ()> { + if let AssetId::Concrete(ref mut l) = self { + l.prepend_with(prepend.clone()).map_err(|_| ())?; + } + Ok(()) + } + + /// Mutate the asset to represent the same value from the perspective of a new `target` + /// location. The local chain's location is provided in `context`. + pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + if let AssetId::Concrete(ref mut l) = self { + l.reanchor(target, context)?; + } + Ok(()) + } + + /// Use the value of `self` along with a `fun` fungibility specifier to create the corresponding `MultiAsset` value. + pub fn into_multiasset(self, fun: Fungibility) -> MultiAsset { + MultiAsset { fun, id: self } + } + + /// Use the value of `self` along with a `fun` fungibility specifier to create the corresponding `WildMultiAsset` + /// wildcard (`AllOf`) value. + pub fn into_wild(self, fun: WildFungibility) -> WildMultiAsset { + WildMultiAsset::AllOf { fun, id: self } + } +} + +#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] +pub struct MultiAsset { + pub id: AssetId, + pub fun: Fungibility, +} + +impl PartialOrd for MultiAsset { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for MultiAsset { + fn cmp(&self, other: &Self) -> Ordering { + match (&self.fun, &other.fun) { + (Fungibility::Fungible(..), Fungibility::NonFungible(..)) => Ordering::Less, + (Fungibility::NonFungible(..), Fungibility::Fungible(..)) => Ordering::Greater, + _ => (&self.id, &self.fun).cmp(&(&other.id, &other.fun)), + } + } +} + +impl, B: Into> From<(A, B)> for MultiAsset { + fn from((id, fun): (A, B)) -> MultiAsset { + MultiAsset { fun: fun.into(), id: id.into() } + } +} + +impl MultiAsset { + pub fn is_fungible(&self, maybe_id: Option) -> bool { + use Fungibility::*; + matches!(self.fun, Fungible(..)) && maybe_id.map_or(true, |i| i == self.id) + } + + pub fn is_non_fungible(&self, maybe_id: Option) -> bool { + use Fungibility::*; + matches!(self.fun, NonFungible(..)) && maybe_id.map_or(true, |i| i == self.id) + } + + /// Prepend a `MultiLocation` to a concrete asset, giving it a new root location. + pub fn prepend_with(&mut self, prepend: &MultiLocation) -> Result<(), ()> { + self.id.prepend_with(prepend) + } + + /// Mutate the location of the asset identifier if concrete, giving it the same location + /// relative to a `target` context. The local context is provided as `context`. + pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + self.id.reanchor(target, context) + } + + /// Mutate the location of the asset identifier if concrete, giving it the same location + /// relative to a `target` context. The local context is provided as `context`. + pub fn reanchored( + mut self, + target: &MultiLocation, + context: &MultiLocation, + ) -> Result { + self.id.reanchor(target, context)?; + Ok(self) + } + + /// Returns true if `self` is a super-set of the given `inner`. + pub fn contains(&self, inner: &MultiAsset) -> bool { + use Fungibility::*; + if self.id == inner.id { + match (&self.fun, &inner.fun) { + (Fungible(a), Fungible(i)) if a >= i => return true, + (NonFungible(a), NonFungible(i)) if a == i => return true, + _ => (), + } + } + false + } +} + +impl TryFrom for MultiAsset { + type Error = (); + fn try_from(old: OldMultiAsset) -> Result { + Ok(Self { id: old.id.try_into()?, fun: old.fun }) + } +} + +/// A `Vec` of `MultiAsset`s. There may be no duplicate fungible items in here and when decoding, they must be sorted. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo, Default)] +pub struct MultiAssets(Vec); + +impl Decode for MultiAssets { + fn decode(input: &mut I) -> Result { + Self::from_sorted_and_deduplicated(Vec::::decode(input)?) + .map_err(|()| "Out of order".into()) + } +} + +impl TryFrom for MultiAssets { + type Error = (); + fn try_from(old: OldMultiAssets) -> Result { + let v = old + .drain() + .into_iter() + .map(MultiAsset::try_from) + .collect::, ()>>()?; + Ok(MultiAssets(v)) + } +} + +impl From> for MultiAssets { + fn from(mut assets: Vec) -> Self { + let mut res = Vec::with_capacity(assets.len()); + if !assets.is_empty() { + assets.sort(); + let mut iter = assets.into_iter(); + if let Some(first) = iter.next() { + let last = iter.fold(first, |a, b| -> MultiAsset { + match (a, b) { + ( + MultiAsset { fun: Fungibility::Fungible(a_amount), id: a_id }, + MultiAsset { fun: Fungibility::Fungible(b_amount), id: b_id }, + ) if a_id == b_id => MultiAsset { + id: a_id, + fun: Fungibility::Fungible(a_amount.saturating_add(b_amount)), + }, + ( + MultiAsset { fun: Fungibility::NonFungible(a_instance), id: a_id }, + MultiAsset { fun: Fungibility::NonFungible(b_instance), id: b_id }, + ) if a_id == b_id && a_instance == b_instance => + MultiAsset { fun: Fungibility::NonFungible(a_instance), id: a_id }, + (to_push, to_remember) => { + res.push(to_push); + to_remember + }, + } + }); + res.push(last); + } + } + Self(res) + } +} + +impl> From for MultiAssets { + fn from(x: T) -> Self { + Self(vec![x.into()]) + } +} + +impl MultiAssets { + /// A new (empty) value. + pub fn new() -> Self { + Self(Vec::new()) + } + + /// Create a new instance of `MultiAssets` from a `Vec` whose contents are sorted and + /// which contain no duplicates. + /// + /// Returns `Ok` if the operation succeeds and `Err` if `r` is out of order or had duplicates. If you can't + /// guarantee that `r` is sorted and deduplicated, then use `From::>::from` which is infallible. + pub fn from_sorted_and_deduplicated(r: Vec) -> Result { + if r.is_empty() { + return Ok(Self(Vec::new())) + } + r.iter().skip(1).try_fold(&r[0], |a, b| -> Result<&MultiAsset, ()> { + if a.id < b.id || a < b && (a.is_non_fungible(None) || b.is_non_fungible(None)) { + Ok(b) + } else { + Err(()) + } + })?; + Ok(Self(r)) + } + + /// Create a new instance of `MultiAssets` from a `Vec` whose contents are sorted and + /// which contain no duplicates. + /// + /// In release mode, this skips any checks to ensure that `r` is correct, making it a negligible-cost operation. + /// Generally though you should avoid using it unless you have a strict proof that `r` is valid. + #[cfg(test)] + pub fn from_sorted_and_deduplicated_skip_checks(r: Vec) -> Self { + Self::from_sorted_and_deduplicated(r).expect("Invalid input r is not sorted/deduped") + } + /// Create a new instance of `MultiAssets` from a `Vec` whose contents are sorted and + /// which contain no duplicates. + /// + /// In release mode, this skips any checks to ensure that `r` is correct, making it a negligible-cost operation. + /// Generally though you should avoid using it unless you have a strict proof that `r` is valid. + /// + /// In test mode, this checks anyway and panics on fail. + #[cfg(not(test))] + pub fn from_sorted_and_deduplicated_skip_checks(r: Vec) -> Self { + Self(r) + } + + /// Add some asset onto the list, saturating. This is quite a laborious operation since it maintains the ordering. + pub fn push(&mut self, a: MultiAsset) { + if let Fungibility::Fungible(ref amount) = a.fun { + for asset in self.0.iter_mut().filter(|x| x.id == a.id) { + if let Fungibility::Fungible(ref mut balance) = asset.fun { + *balance = balance.saturating_add(*amount); + return + } + } + } + self.0.push(a); + self.0.sort(); + } + + /// Returns `true` if this definitely represents no asset. + pub fn is_none(&self) -> bool { + self.0.is_empty() + } + + /// Returns true if `self` is a super-set of the given `inner`. + pub fn contains(&self, inner: &MultiAsset) -> bool { + self.0.iter().any(|i| i.contains(inner)) + } + + /// Consume `self` and return the inner vec. + pub fn drain(self) -> Vec { + self.0 + } + + /// Return a reference to the inner vec. + pub fn inner(&self) -> &Vec { + &self.0 + } + + /// Return the number of distinct asset instances contained. + pub fn len(&self) -> usize { + self.0.len() + } + + /// Prepend a `MultiLocation` to any concrete asset items, giving it a new root location. + pub fn prepend_with(&mut self, prefix: &MultiLocation) -> Result<(), ()> { + self.0.iter_mut().try_for_each(|i| i.prepend_with(prefix)) + } + + /// Mutate the location of the asset identifier if concrete, giving it the same location + /// relative to a `target` context. The local context is provided as `context`. + pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + self.0.iter_mut().try_for_each(|i| i.reanchor(target, context)) + } + + /// Return a reference to an item at a specific index or `None` if it doesn't exist. + pub fn get(&self, index: usize) -> Option<&MultiAsset> { + self.0.get(index) + } +} /// A wildcard representing a set of assets. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] @@ -55,33 +365,35 @@ pub enum WildMultiAsset { }, } -impl From for WildMultiAsset { - fn from(old: OldWildMultiAsset) -> WildMultiAsset { +impl TryFrom for WildMultiAsset { + type Error = (); + fn try_from(old: OldWildMultiAsset) -> Result { use OldWildMultiAsset::*; - match old { - AllOf { id, fun } => Self::AllOf { id, fun }, + Ok(match old { + AllOf { id, fun } => Self::AllOf { id: id.try_into()?, fun }, All => Self::All, - } + }) } } -impl From<(OldWildMultiAsset, u32)> for WildMultiAsset { - fn from(old: (OldWildMultiAsset, u32)) -> WildMultiAsset { +impl TryFrom<(OldWildMultiAsset, u32)> for WildMultiAsset { + type Error = (); + fn try_from(old: (OldWildMultiAsset, u32)) -> Result { use OldWildMultiAsset::*; let count = old.1; - match old.0 { - AllOf { id, fun } => Self::AllOfCounted { id, fun, count }, + Ok(match old.0 { + AllOf { id, fun } => Self::AllOfCounted { id: id.try_into()?, fun, count }, All => Self::AllCounted(count), - } + }) } } impl WildMultiAsset { - /// Returns true if the wild element of `self` matches `inner`. + /// Returns true if `self` is a super-set of the given `inner`. /// - /// Note that for `Counted` variants of wildcards, then it will disregard the count except for - /// always returning `false` when equal to 0. - pub fn matches(&self, inner: &MultiAsset) -> bool { + /// Typically, any wildcard is never contained in anything else, and a wildcard can contain any other non-wildcard. + /// For more details, see the implementation and tests. + pub fn contains(&self, inner: &MultiAsset) -> bool { use WildMultiAsset::*; match self { AllOfCounted { count: 0, .. } | AllCounted(0) => false, @@ -91,13 +403,22 @@ impl WildMultiAsset { } } + /// Returns true if the wild element of `self` matches `inner`. + /// + /// Note that for `Counted` variants of wildcards, then it will disregard the count except for + /// always returning `false` when equal to 0. + #[deprecated = "Use `contains` instead"] + pub fn matches(&self, inner: &MultiAsset) -> bool { + self.contains(inner) + } + /// Mutate the asset to represent the same value from the perspective of a new `target` - /// location. The local chain's location is provided in `ancestry`. - pub fn reanchor(&mut self, target: &MultiLocation, ancestry: &MultiLocation) -> Result<(), ()> { + /// location. The local chain's location is provided in `context`. + pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { use WildMultiAsset::*; match self { AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } => - id.reanchor(target, ancestry), + id.reanchor(target, context), All | AllCounted(_) => Ok(()), } } @@ -172,16 +493,16 @@ impl MultiAssetFilter { pub fn matches(&self, inner: &MultiAsset) -> bool { match self { MultiAssetFilter::Definite(ref assets) => assets.contains(inner), - MultiAssetFilter::Wild(ref wild) => wild.matches(inner), + MultiAssetFilter::Wild(ref wild) => wild.contains(inner), } } /// Mutate the location of the asset identifier if concrete, giving it the same location - /// relative to a `target` context. The local context is provided as `ancestry`. - pub fn reanchor(&mut self, target: &MultiLocation, ancestry: &MultiLocation) -> Result<(), ()> { + /// relative to a `target` context. The local context is provided as `context`. + pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { match self { - MultiAssetFilter::Definite(ref mut assets) => assets.reanchor(target, ancestry), - MultiAssetFilter::Wild(ref mut wild) => wild.reanchor(target, ancestry), + MultiAssetFilter::Definite(ref mut assets) => assets.reanchor(target, context), + MultiAssetFilter::Wild(ref mut wild) => wild.reanchor(target, context), } } @@ -204,12 +525,13 @@ impl MultiAssetFilter { } } -impl From for MultiAssetFilter { - fn from(old: OldMultiAssetFilter) -> MultiAssetFilter { - match old { - OldMultiAssetFilter::Definite(x) => Self::Definite(x.into()), - OldMultiAssetFilter::Wild(x) => Self::Wild(x.into()), - } +impl TryFrom for MultiAssetFilter { + type Error = (); + fn try_from(old: OldMultiAssetFilter) -> Result { + Ok(match old { + OldMultiAssetFilter::Definite(x) => Self::Definite(x.try_into()?), + OldMultiAssetFilter::Wild(x) => Self::Wild(x.try_into()?), + }) } } @@ -218,9 +540,17 @@ impl TryFrom<(OldMultiAssetFilter, u32)> for MultiAssetFilter { fn try_from(old: (OldMultiAssetFilter, u32)) -> Result { let count = old.1; Ok(match old.0 { - OldMultiAssetFilter::Definite(x) if count >= x.len() as u32 => Self::Definite(x.into()), - OldMultiAssetFilter::Wild(x) => Self::Wild((x, count).into()), + OldMultiAssetFilter::Definite(x) if count >= x.len() as u32 => + Self::Definite(x.try_into()?), + OldMultiAssetFilter::Wild(x) => Self::Wild((x, count).try_into()?), _ => return Err(()), }) } } + +#[test] +fn conversion_works() { + use super::prelude::*; + + let _: MultiAssets = (Here, 1).into(); +} diff --git a/xcm/src/v3/multilocation.rs b/xcm/src/v3/multilocation.rs new file mode 100644 index 000000000000..e5124be27abd --- /dev/null +++ b/xcm/src/v3/multilocation.rs @@ -0,0 +1,727 @@ +// Copyright 2020-2021 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 . + +//! XCM `MultiLocation` datatype. + +use super::{Junction, Junctions}; +use crate::{v2::MultiLocation as OldMultiLocation, VersionedMultiLocation}; +use core::{ + convert::{TryFrom, TryInto}, + result, +}; +use parity_scale_codec::{Decode, Encode}; +use scale_info::TypeInfo; + +/// A relative path between state-bearing consensus systems. +/// +/// A location in a consensus system is defined as an *isolatable state machine* held within global +/// consensus. The location in question need not have a sophisticated consensus algorithm of its +/// own; a single account within Ethereum, for example, could be considered a location. +/// +/// A very-much non-exhaustive list of types of location include: +/// - A (normal, layer-1) block chain, e.g. the Bitcoin mainnet or a parachain. +/// - A layer-0 super-chain, e.g. the Polkadot Relay chain. +/// - A layer-2 smart contract, e.g. an ERC-20 on Ethereum. +/// - A logical functional component of a chain, e.g. a single instance of a pallet on a Frame-based +/// Substrate chain. +/// - An account. +/// +/// A `MultiLocation` is a *relative identifier*, meaning that it can only be used to define the +/// relative path between two locations, and cannot generally be used to refer to a location +/// universally. It is comprised of an integer number of parents specifying the number of times to +/// "escape" upwards into the containing consensus system and then a number of *junctions*, each +/// diving down and specifying some interior portion of state (which may be considered a +/// "sub-consensus" system). +/// +/// This specific `MultiLocation` implementation uses a `Junctions` datatype which is a Rust `enum` +/// in order to make pattern matching easier. There are occasions where it is important to ensure +/// that a value is strictly an interior location, in those cases, `Junctions` may be used. +/// +/// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system. +#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo)] +pub struct MultiLocation { + /// The number of parent junctions at the beginning of this `MultiLocation`. + pub parents: u8, + /// The interior (i.e. non-parent) junctions that this `MultiLocation` contains. + pub interior: Junctions, +} + +impl Default for MultiLocation { + fn default() -> Self { + Self { parents: 0, interior: Junctions::Here } + } +} + +/// A relative location which is constrained to be an interior location of the context. +/// +/// See also `MultiLocation`. +pub type InteriorMultiLocation = Junctions; + +impl MultiLocation { + /// Creates a new `MultiLocation` with the given number of parents and interior junctions. + pub fn new(parents: u8, interior: impl Into) -> MultiLocation { + MultiLocation { parents, interior: interior.into() } + } + + /// Consume `self` and return the equivalent `VersionedMultiLocation` value. + pub const fn into_versioned(self) -> VersionedMultiLocation { + VersionedMultiLocation::V3(self) + } + + /// Creates a new `MultiLocation` with 0 parents and a `Here` interior. + /// + /// The resulting `MultiLocation` can be interpreted as the "current consensus system". + pub const fn here() -> MultiLocation { + MultiLocation { parents: 0, interior: Junctions::Here } + } + + /// Creates a new `MultiLocation` which evaluates to the parent context. + pub const fn parent() -> MultiLocation { + MultiLocation { parents: 1, interior: Junctions::Here } + } + + /// Creates a new `MultiLocation` which evaluates to the grand parent context. + pub const fn grandparent() -> MultiLocation { + MultiLocation { parents: 2, interior: Junctions::Here } + } + + /// Creates a new `MultiLocation` with `parents` and an empty (`Here`) interior. + pub const fn ancestor(parents: u8) -> MultiLocation { + MultiLocation { parents, interior: Junctions::Here } + } + + /// Whether the `MultiLocation` has no parents and has a `Here` interior. + pub const fn is_here(&self) -> bool { + self.parents == 0 && self.interior.len() == 0 + } + + /// Return a reference to the interior field. + pub fn interior(&self) -> &Junctions { + &self.interior + } + + /// Return a mutable reference to the interior field. + pub fn interior_mut(&mut self) -> &mut Junctions { + &mut self.interior + } + + /// Returns the number of `Parent` junctions at the beginning of `self`. + pub const fn parent_count(&self) -> u8 { + self.parents + } + + /// Returns boolean indicating whether `self` contains only the specified amount of + /// parents and no interior junctions. + pub const fn contains_parents_only(&self, count: u8) -> bool { + matches!(self.interior, Junctions::Here) && self.parents == count + } + + /// Returns the number of parents and junctions in `self`. + pub const fn len(&self) -> usize { + self.parent_count() as usize + self.interior.len() + } + + /// Returns the first interior junction, or `None` if the location is empty or contains only + /// parents. + pub fn first_interior(&self) -> Option<&Junction> { + self.interior.first() + } + + /// Returns last junction, or `None` if the location is empty or contains only parents. + pub fn last(&self) -> Option<&Junction> { + self.interior.last() + } + + /// Splits off the first interior junction, returning the remaining suffix (first item in tuple) + /// and the first element (second item in tuple) or `None` if it was empty. + pub fn split_first_interior(self) -> (MultiLocation, Option) { + let MultiLocation { parents, interior: junctions } = self; + let (suffix, first) = junctions.split_first(); + let multilocation = MultiLocation { parents, interior: suffix }; + (multilocation, first) + } + + /// Splits off the last interior junction, returning the remaining prefix (first item in tuple) + /// and the last element (second item in tuple) or `None` if it was empty or if `self` only + /// contains parents. + pub fn split_last_interior(self) -> (MultiLocation, Option) { + let MultiLocation { parents, interior: junctions } = self; + let (prefix, last) = junctions.split_last(); + let multilocation = MultiLocation { parents, interior: prefix }; + (multilocation, last) + } + + /// Mutates `self`, suffixing its interior junctions with `new`. Returns `Err` with `new` in + /// case of overflow. + pub fn push_interior(&mut self, new: impl Into) -> result::Result<(), Junction> { + self.interior.push(new) + } + + /// Mutates `self`, prefixing its interior junctions with `new`. Returns `Err` with `new` in + /// case of overflow. + pub fn push_front_interior( + &mut self, + new: impl Into, + ) -> result::Result<(), Junction> { + self.interior.push_front(new) + } + + /// Consumes `self` and returns a `MultiLocation` suffixed with `new`, or an `Err` with theoriginal value of + /// `self` in case of overflow. + pub fn pushed_with_interior( + self, + new: impl Into, + ) -> result::Result { + match self.interior.pushed_with(new) { + Ok(i) => Ok(MultiLocation { interior: i, parents: self.parents }), + Err((i, j)) => Err((MultiLocation { interior: i, parents: self.parents }, j)), + } + } + + /// Consumes `self` and returns a `MultiLocation` prefixed with `new`, or an `Err` with the original value of + /// `self` in case of overflow. + pub fn pushed_front_with_interior( + self, + new: impl Into, + ) -> result::Result { + match self.interior.pushed_front_with(new) { + Ok(i) => Ok(MultiLocation { interior: i, parents: self.parents }), + Err((i, j)) => Err((MultiLocation { interior: i, parents: self.parents }, j)), + } + } + + /// Returns the junction at index `i`, or `None` if the location is a parent or if the location + /// does not contain that many elements. + pub fn at(&self, i: usize) -> Option<&Junction> { + let num_parents = self.parents as usize; + if i < num_parents { + return None + } + self.interior.at(i - num_parents) + } + + /// Returns a mutable reference to the junction at index `i`, or `None` if the location is a + /// parent or if it doesn't contain that many elements. + pub fn at_mut(&mut self, i: usize) -> Option<&mut Junction> { + let num_parents = self.parents as usize; + if i < num_parents { + return None + } + self.interior.at_mut(i - num_parents) + } + + /// Decrements the parent count by 1. + pub fn dec_parent(&mut self) { + self.parents = self.parents.saturating_sub(1); + } + + /// Removes the first interior junction from `self`, returning it + /// (or `None` if it was empty or if `self` contains only parents). + pub fn take_first_interior(&mut self) -> Option { + self.interior.take_first() + } + + /// Removes the last element from `interior`, returning it (or `None` if it was empty or if + /// `self` only contains parents). + pub fn take_last(&mut self) -> Option { + self.interior.take_last() + } + + /// Ensures that `self` has the same number of parents as `prefix`, its junctions begins with + /// the junctions of `prefix` and that it has a single `Junction` item following. + /// If so, returns a reference to this `Junction` item. + /// + /// # Example + /// ```rust + /// # use xcm::v3::{Junctions::*, Junction::*, MultiLocation}; + /// # fn main() { + /// let mut m = MultiLocation::new(1, X2(PalletInstance(3), OnlyChild)); + /// assert_eq!( + /// m.match_and_split(&MultiLocation::new(1, X1(PalletInstance(3)))), + /// Some(&OnlyChild), + /// ); + /// assert_eq!(m.match_and_split(&MultiLocation::new(1, Here)), None); + /// # } + /// ``` + pub fn match_and_split(&self, prefix: &MultiLocation) -> Option<&Junction> { + if self.parents != prefix.parents { + return None + } + self.interior.match_and_split(&prefix.interior) + } + + /// Mutate `self` so that it is suffixed with `suffix`. + /// + /// Does not modify `self` and returns `Err` with `suffix` in case of overflow. + /// + /// # Example + /// ```rust + /// # use xcm::v3::{Junctions::*, Junction::*, MultiLocation, Parent}; + /// # fn main() { + /// let mut m: MultiLocation = (Parent, Parachain(21), 69u64).into(); + /// assert_eq!(m.append_with((Parent, PalletInstance(3))), Ok(())); + /// assert_eq!(m, MultiLocation::new(1, X2(Parachain(21), PalletInstance(3)))); + /// # } + /// ``` + pub fn append_with(&mut self, suffix: impl Into) -> Result<(), Self> { + let prefix = core::mem::replace(self, suffix.into()); + match self.prepend_with(prefix) { + Ok(()) => Ok(()), + Err(prefix) => Err(core::mem::replace(self, prefix)), + } + } + + /// Consume `self` and return its value suffixed with `suffix`. + /// + /// Returns `Err` with the original value of `self` and `suffix` in case of overflow. + /// + /// # Example + /// ```rust + /// # use xcm::v3::{Junctions::*, Junction::*, MultiLocation, Parent}; + /// # fn main() { + /// let mut m: MultiLocation = (Parent, Parachain(21), 69u64).into(); + /// let r = m.appended_with((Parent, PalletInstance(3))).unwrap(); + /// assert_eq!(r, MultiLocation::new(1, X2(Parachain(21), PalletInstance(3)))); + /// # } + /// ``` + pub fn appended_with(mut self, suffix: impl Into) -> Result { + match self.append_with(suffix) { + Ok(()) => Ok(self), + Err(suffix) => Err((self, suffix)), + } + } + + /// Mutate `self` so that it is prefixed with `prefix`. + /// + /// Does not modify `self` and returns `Err` with `prefix` in case of overflow. + /// + /// # Example + /// ```rust + /// # use xcm::v3::{Junctions::*, Junction::*, MultiLocation, Parent}; + /// # fn main() { + /// let mut m: MultiLocation = (Parent, Parent, PalletInstance(3)).into(); + /// assert_eq!(m.prepend_with((Parent, Parachain(21), OnlyChild)), Ok(())); + /// assert_eq!(m, MultiLocation::new(1, X1(PalletInstance(3)))); + /// # } + /// ``` + pub fn prepend_with(&mut self, prefix: impl Into) -> Result<(), Self> { + // prefix self (suffix) + // P .. P I .. I p .. p i .. i + let mut prefix = prefix.into(); + let prepend_interior = prefix.interior.len().saturating_sub(self.parents as usize); + let final_interior = self.interior.len().saturating_add(prepend_interior); + if final_interior > super::junctions::MAX_JUNCTIONS { + return Err(prefix) + } + let suffix_parents = (self.parents as usize).saturating_sub(prefix.interior.len()); + let final_parents = (prefix.parents as usize).saturating_add(suffix_parents); + if final_parents > 255 { + return Err(prefix) + } + + // cancel out the final item on the prefix interior for one of the suffix's parents. + while self.parents > 0 && prefix.take_last().is_some() { + self.dec_parent(); + } + + // now we have either removed all suffix's parents or prefix interior. + // this means we can combine the prefix's and suffix's remaining parents/interior since + // we know that with at least one empty, the overall order will be respected: + // prefix self (suffix) + // P .. P (I) p .. p i .. i => P + p .. (no I) i + // -- or -- + // P .. P I .. I (p) i .. i => P (no p) .. I + i + + self.parents = self.parents.saturating_add(prefix.parents); + for j in prefix.interior.into_iter().rev() { + self.push_front_interior(j) + .expect("final_interior no greater than MAX_JUNCTIONS; qed"); + } + Ok(()) + } + + /// Consume `self` and return its value prefixed with `prefix`. + /// + /// Returns `Err` with the original value of `self` and `prefix` in case of overflow. + /// + /// # Example + /// ```rust + /// # use xcm::v3::{Junctions::*, Junction::*, MultiLocation, Parent}; + /// # fn main() { + /// let m: MultiLocation = (Parent, Parent, PalletInstance(3)).into(); + /// let r = m.prepended_with((Parent, Parachain(21), OnlyChild)).unwrap(); + /// assert_eq!(r, MultiLocation::new(1, X1(PalletInstance(3)))); + /// # } + /// ``` + pub fn prepended_with(mut self, prefix: impl Into) -> Result { + match self.prepend_with(prefix) { + Ok(()) => Ok(self), + Err(prefix) => Err((self, prefix)), + } + } + + /// Mutate `self` so that it represents the same location from the point of view of `target`. + /// The context of `self` is provided as `context`. + /// + /// Does not modify `self` in case of overflow. + pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + // TODO: https://github.com/paritytech/polkadot/issues/4489 Optimize this. + + // 1. Use our `context` to figure out how the `target` would address us. + let inverted_target = context.inverted(target)?; + + // 2. Prepend `inverted_target` to `self` to get self's location from the perspective of + // `target`. + self.prepend_with(inverted_target).map_err(|_| ())?; + + // 3. Given that we know some of `target` context, ensure that any parents in `self` are + // strictly needed. + self.simplify(target.interior()); + + Ok(()) + } + + /// Consume `self` and return a new value representing the same location from the point of view + /// of `target`. The context of `self` is provided as `context`. + /// + /// Returns the original `self` in case of overflow. + pub fn reanchored( + mut self, + target: &MultiLocation, + context: &MultiLocation, + ) -> Result { + match self.reanchor(target, context) { + Ok(()) => Ok(self), + Err(()) => Err(self), + } + } + + /// Treating `self` as a context, determine how it would be referenced by a `target` location. + pub fn inverted(&self, target: &MultiLocation) -> Result { + use Junction::OnlyChild; + let mut context = self.clone(); + let mut junctions = Junctions::Here; + for _ in 0..target.parent_count() { + junctions = junctions + .pushed_front_with(context.interior.take_last().unwrap_or(OnlyChild)) + .map_err(|_| ())?; + } + let parents = target.interior().len() as u8; + Ok(MultiLocation::new(parents, junctions)) + } + + /// Remove any unneeded parents/junctions in `self` based on the given context it will be + /// interpreted in. + pub fn simplify(&mut self, context: &Junctions) { + if context.len() < self.parents as usize { + // Not enough context + return + } + while self.parents > 0 { + let maybe = context.at(context.len() - (self.parents as usize)); + match (self.interior.first(), maybe) { + (Some(i), Some(j)) if i == j => { + self.interior.take_first(); + self.parents -= 1; + }, + _ => break, + } + } + } +} + +impl TryFrom for MultiLocation { + type Error = (); + fn try_from(x: OldMultiLocation) -> result::Result { + Ok(MultiLocation { parents: x.parents, interior: x.interior.try_into()? }) + } +} + +/// A unit struct which can be converted into a `MultiLocation` of `parents` value 1. +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] +pub struct Parent; +impl From for MultiLocation { + fn from(_: Parent) -> Self { + MultiLocation { parents: 1, interior: Junctions::Here } + } +} + +/// A tuple struct which can be converted into a `MultiLocation` of `parents` value 1 with the inner interior. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] +pub struct ParentThen(pub Junctions); +impl From for MultiLocation { + fn from(ParentThen(interior): ParentThen) -> Self { + MultiLocation { parents: 1, interior } + } +} + +/// A unit struct which can be converted into a `MultiLocation` of the inner `parents` value. +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] +pub struct Ancestor(pub u8); +impl From for MultiLocation { + fn from(Ancestor(parents): Ancestor) -> Self { + MultiLocation { parents, interior: Junctions::Here } + } +} + +/// A unit struct which can be converted into a `MultiLocation` of the inner `parents` value and the inner interior. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] +pub struct AncestorThen(pub u8, pub Interior); +impl> From> for MultiLocation { + fn from(AncestorThen(parents, interior): AncestorThen) -> Self { + MultiLocation { parents, interior: interior.into() } + } +} + +xcm_procedural::impl_conversion_functions_for_multilocation_v3!(); + +#[cfg(test)] +mod tests { + use crate::v3::prelude::*; + use parity_scale_codec::{Decode, Encode}; + + #[test] + fn conversion_works() { + let x: MultiLocation = Parent.into(); + assert_eq!(x, MultiLocation { parents: 1, interior: Here }); + // let x: MultiLocation = (Parent,).into(); + // assert_eq!(x, MultiLocation { parents: 1, interior: Here }); + // let x: MultiLocation = (Parent, Parent).into(); + // assert_eq!(x, MultiLocation { parents: 2, interior: Here }); + let x: MultiLocation = (Parent, Parent, OnlyChild).into(); + assert_eq!(x, MultiLocation { parents: 2, interior: OnlyChild.into() }); + let x: MultiLocation = OnlyChild.into(); + assert_eq!(x, MultiLocation { parents: 0, interior: OnlyChild.into() }); + let x: MultiLocation = (OnlyChild,).into(); + assert_eq!(x, MultiLocation { parents: 0, interior: OnlyChild.into() }); + } + + #[test] + fn inverted_works() { + let context: MultiLocation = (Parachain(1000), PalletInstance(42)).into(); + let target = (Parent, PalletInstance(69)).into(); + let expected = (Parent, PalletInstance(42)).into(); + let inverted = context.inverted(&target).unwrap(); + assert_eq!(inverted, expected); + + let context: MultiLocation = (Parachain(1000), PalletInstance(42), GeneralIndex(1)).into(); + let target = (Parent, Parent, PalletInstance(69), GeneralIndex(2)).into(); + let expected = (Parent, Parent, PalletInstance(42), GeneralIndex(1)).into(); + let inverted = context.inverted(&target).unwrap(); + assert_eq!(inverted, expected); + } + + #[test] + fn simplify_basic_works() { + let mut location: MultiLocation = + (Parent, Parent, Parachain(1000), PalletInstance(42), GeneralIndex(69)).into(); + let context = X2(Parachain(1000), PalletInstance(42)); + let expected = GeneralIndex(69).into(); + location.simplify(&context); + assert_eq!(location, expected); + + let mut location: MultiLocation = (Parent, PalletInstance(42), GeneralIndex(69)).into(); + let context = X1(PalletInstance(42)); + let expected = GeneralIndex(69).into(); + location.simplify(&context); + assert_eq!(location, expected); + + let mut location: MultiLocation = (Parent, PalletInstance(42), GeneralIndex(69)).into(); + let context = X2(Parachain(1000), PalletInstance(42)); + let expected = GeneralIndex(69).into(); + location.simplify(&context); + assert_eq!(location, expected); + + let mut location: MultiLocation = + (Parent, Parent, Parachain(1000), PalletInstance(42), GeneralIndex(69)).into(); + let context = X3(OnlyChild, Parachain(1000), PalletInstance(42)); + let expected = GeneralIndex(69).into(); + location.simplify(&context); + assert_eq!(location, expected); + } + + #[test] + fn simplify_incompatible_location_fails() { + let mut location: MultiLocation = + (Parent, Parent, Parachain(1000), PalletInstance(42), GeneralIndex(69)).into(); + let context = X3(Parachain(1000), PalletInstance(42), GeneralIndex(42)); + let expected = + (Parent, Parent, Parachain(1000), PalletInstance(42), GeneralIndex(69)).into(); + location.simplify(&context); + assert_eq!(location, expected); + + let mut location: MultiLocation = + (Parent, Parent, Parachain(1000), PalletInstance(42), GeneralIndex(69)).into(); + let context = X1(Parachain(1000)); + let expected = + (Parent, Parent, Parachain(1000), PalletInstance(42), GeneralIndex(69)).into(); + location.simplify(&context); + assert_eq!(location, expected); + } + + #[test] + fn reanchor_works() { + let mut id: MultiLocation = (Parent, Parachain(1000), GeneralIndex(42)).into(); + let context = Parachain(2000).into(); + let target = (Parent, Parachain(1000)).into(); + let expected = GeneralIndex(42).into(); + id.reanchor(&target, &context).unwrap(); + assert_eq!(id, expected); + } + + #[test] + fn encode_and_decode_works() { + let m = MultiLocation { + parents: 1, + interior: X2(Parachain(42), AccountIndex64 { network: None, index: 23 }), + }; + let encoded = m.encode(); + assert_eq!(encoded, [1, 2, 0, 168, 2, 0, 92].to_vec()); + let decoded = MultiLocation::decode(&mut &encoded[..]); + assert_eq!(decoded, Ok(m)); + } + + #[test] + fn match_and_split_works() { + let m = MultiLocation { + parents: 1, + interior: X2(Parachain(42), AccountIndex64 { network: None, index: 23 }), + }; + assert_eq!(m.match_and_split(&MultiLocation { parents: 1, interior: Here }), None); + assert_eq!( + m.match_and_split(&MultiLocation { parents: 1, interior: X1(Parachain(42)) }), + Some(&AccountIndex64 { network: None, index: 23 }) + ); + assert_eq!(m.match_and_split(&m), None); + } + + #[test] + fn append_with_works() { + let acc = AccountIndex64 { network: None, index: 23 }; + let mut m = MultiLocation { parents: 1, interior: X1(Parachain(42)) }; + assert_eq!(m.append_with(X2(PalletInstance(3), acc.clone())), Ok(())); + assert_eq!( + m, + MultiLocation { + parents: 1, + interior: X3(Parachain(42), PalletInstance(3), acc.clone()) + } + ); + + // cannot append to create overly long multilocation + let acc = AccountIndex64 { network: None, index: 23 }; + let m = MultiLocation { + parents: 254, + interior: X5(Parachain(42), OnlyChild, OnlyChild, OnlyChild, OnlyChild), + }; + let suffix: MultiLocation = (PalletInstance(3), acc.clone(), OnlyChild, OnlyChild).into(); + assert_eq!(m.clone().append_with(suffix.clone()), Err(suffix)); + } + + #[test] + fn prepend_with_works() { + let mut m = MultiLocation { + parents: 1, + interior: X2(Parachain(42), AccountIndex64 { network: None, index: 23 }), + }; + assert_eq!(m.prepend_with(MultiLocation { parents: 1, interior: X1(OnlyChild) }), Ok(())); + assert_eq!( + m, + MultiLocation { + parents: 1, + interior: X2(Parachain(42), AccountIndex64 { network: None, index: 23 }) + } + ); + + // cannot prepend to create overly long multilocation + let mut m = MultiLocation { parents: 254, interior: X1(Parachain(42)) }; + let prefix = MultiLocation { parents: 2, interior: Here }; + assert_eq!(m.prepend_with(prefix.clone()), Err(prefix)); + + let prefix = MultiLocation { parents: 1, interior: Here }; + assert_eq!(m.prepend_with(prefix), Ok(())); + assert_eq!(m, MultiLocation { parents: 255, interior: X1(Parachain(42)) }); + } + + #[test] + fn double_ended_ref_iteration_works() { + let m = X3(Parachain(1000), Parachain(3), PalletInstance(5)); + let mut iter = m.iter(); + + let first = iter.next().unwrap(); + assert_eq!(first, &Parachain(1000)); + let third = iter.next_back().unwrap(); + assert_eq!(third, &PalletInstance(5)); + let second = iter.next_back().unwrap(); + assert_eq!(iter.next(), None); + assert_eq!(iter.next_back(), None); + assert_eq!(second, &Parachain(3)); + + let res = Here + .pushed_with(first.clone()) + .unwrap() + .pushed_with(second.clone()) + .unwrap() + .pushed_with(third.clone()) + .unwrap(); + assert_eq!(m, res); + + // make sure there's no funny business with the 0 indexing + let m = Here; + let mut iter = m.iter(); + + assert_eq!(iter.next(), None); + assert_eq!(iter.next_back(), None); + } + + #[test] + fn conversion_from_other_types_works() { + use crate::v1; + use core::convert::TryInto; + + fn takes_multilocation>(_arg: Arg) {} + + takes_multilocation(Parent); + takes_multilocation(Here); + takes_multilocation(X1(Parachain(42))); + takes_multilocation((Ancestor(255), PalletInstance(8))); + takes_multilocation((Ancestor(5), Parachain(1), PalletInstance(3))); + takes_multilocation((Ancestor(2), Here)); + takes_multilocation(AncestorThen( + 3, + X2(Parachain(43), AccountIndex64 { network: None, index: 155 }), + )); + takes_multilocation((Parent, AccountId32 { network: None, id: [0; 32] })); + takes_multilocation((Parent, Here)); + takes_multilocation(ParentThen(X1(Parachain(75)))); + takes_multilocation([Parachain(100), PalletInstance(3)]); + + assert_eq!( + v1::MultiLocation::from(v1::Junctions::Here).try_into(), + Ok(MultiLocation::here()) + ); + assert_eq!(v1::MultiLocation::from(v1::Parent).try_into(), Ok(MultiLocation::parent())); + assert_eq!( + v1::MultiLocation::from(( + v1::Parent, + v1::Parent, + v1::Junction::GeneralKey(b"foo".to_vec()), + )) + .try_into(), + Ok(MultiLocation { parents: 2, interior: X1(GeneralKey(b"foo".to_vec())) }), + ); + } +} diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index b28e7a730784..1072d140b980 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -108,8 +108,11 @@ pub enum Error { /// The given operation would lead to an overflow of the Holding Register. #[codec(index = 26)] HoldingWouldOverflow, - /// `MultiLocation` value failed to be reanchored. + /// The message was unable to be exported. #[codec(index = 27)] + ExportError, + /// `MultiLocation` value failed to be reanchored. + #[codec(index = 28)] ReanchorFailed, // Errors that happen prior to instructions being executed. These fall outside of the XCM spec. @@ -164,7 +167,8 @@ impl TryFrom for Error { impl From for Error { fn from(e: SendError) -> Self { match e { - SendError::CannotReachDestination(..) | SendError::Unroutable => Error::Unroutable, + SendError::NotApplicable | SendError::Unroutable | SendError::MissingArgument => + Error::Unroutable, SendError::Transport(s) => Error::Transport(s), SendError::DestinationUnsupported => Error::DestinationUnsupported, SendError::ExceedsMaxMessageSize => Error::ExceedsMaxMessageSize, @@ -213,8 +217,20 @@ impl Outcome { } } +pub trait PreparedMessage { + fn weight_of(&self) -> Weight; +} + /// Type of XCM message executor. pub trait ExecuteXcm { + type Prepared: PreparedMessage; + fn prepare(message: Xcm) -> result::Result>; + fn execute( + origin: impl Into, + pre: Self::Prepared, + weight_credit: Weight, + ) -> Outcome; + /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is /// a basic hard-limit and the implementation may place further restrictions or requirements on weight and /// other aspects. @@ -243,17 +259,33 @@ pub trait ExecuteXcm { message: Xcm, weight_limit: Weight, weight_credit: Weight, - ) -> Outcome; + ) -> Outcome { + let pre = match Self::prepare(message) { + Ok(x) => x, + Err(_) => return Outcome::Error(Error::WeightNotComputable), + }; + let xcm_weight = pre.weight_of(); + if xcm_weight > weight_limit { + return Outcome::Error(Error::WeightLimitReached(xcm_weight)) + } + Self::execute(origin, pre, weight_credit) + } +} + +pub enum Weightless {} +impl PreparedMessage for Weightless { + fn weight_of(&self) -> Weight { + unreachable!() + } } impl ExecuteXcm for () { - fn execute_xcm_in_credit( - _origin: impl Into, - _message: Xcm, - _weight_limit: Weight, - _weight_credit: Weight, - ) -> Outcome { - Outcome::Error(Error::Unimplemented) + type Prepared = Weightless; + fn prepare(message: Xcm) -> result::Result> { + Err(message) + } + fn execute(_: impl Into, _: Self::Prepared, _: Weight) -> Outcome { + unreachable!() } } @@ -263,8 +295,8 @@ pub enum SendError { /// The message and destination combination was not recognized as being reachable. /// /// This is not considered fatal: if there are alternative transport routes available, then - /// they may be attempted. For this reason, the destination and message are contained. - CannotReachDestination(MultiLocation, Xcm<()>), + /// they may be attempted. + NotApplicable, /// Destination is routable, but there is some issue with the transport mechanism. This is /// considered fatal. /// A human-readable explanation of the specific issue is provided. @@ -277,15 +309,37 @@ pub enum SendError { /// Message could not be sent due to its size exceeding the maximum allowed by the transport /// layer. ExceedsMaxMessageSize, + /// A needed argument is `None` when it should be `Some`. + MissingArgument, } /// Result value when attempting to send an XCM message. -pub type SendResult = result::Result<(), SendError>; +pub type SendResult = result::Result<(T, MultiAssets), SendError>; + +pub trait Unwrappable { + type Inner; + fn none() -> Self; + fn some(i: Self::Inner) -> Self; + fn take(self) -> Option; +} + +impl Unwrappable for Option { + type Inner = T; + fn none() -> Self { + None + } + fn some(i: Self::Inner) -> Self { + Some(i) + } + fn take(self) -> Option { + self + } +} /// Utility for sending an XCM message. /// /// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each router might return -/// `CannotReachDestination` to pass the execution to the next sender item. Note that each `CannotReachDestination` +/// `NotApplicable` to pass the execution to the next sender item. Note that each `NotApplicable` /// might alter the destination and the XCM message for to the next router. /// /// @@ -293,37 +347,48 @@ pub type SendResult = result::Result<(), SendError>; /// ```rust /// # use xcm::v3::prelude::*; /// # use parity_scale_codec::Encode; +/// # use std::convert::Infallible; /// /// /// A sender that only passes the message through and does nothing. /// struct Sender1; /// impl SendXcm for Sender1 { -/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { -/// return Err(SendError::CannotReachDestination(destination.into(), message)) +/// type Ticket = Infallible; +/// fn validate(_: &mut Option, _: &mut Option>) -> SendResult { +/// Err(SendError::NotApplicable) +/// } +/// fn deliver(_: Infallible) -> Result<(), SendError> { +/// unreachable!() /// } /// } /// /// /// A sender that accepts a message that has an X2 junction, otherwise stops the routing. /// struct Sender2; /// impl SendXcm for Sender2 { -/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { -/// if let MultiLocation { parents: 0, interior: X2(j1, j2) } = destination.into() { -/// Ok(()) -/// } else { -/// Err(SendError::Unroutable) +/// type Ticket = (); +/// fn validate(destination: &mut Option, message: &mut Option>) -> SendResult<()> { +/// match destination.as_ref().ok_or(SendError::MissingArgument)? { +/// MultiLocation { parents: 0, interior: X2(j1, j2) } => Ok(((), MultiAssets::new())), +/// _ => Err(SendError::Unroutable), /// } /// } +/// fn deliver(_: ()) -> Result<(), SendError> { +/// Ok(()) +/// } /// } /// /// /// A sender that accepts a message from a parent, passing through otherwise. /// struct Sender3; /// impl SendXcm for Sender3 { -/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { -/// let destination = destination.into(); -/// match destination { -/// MultiLocation { parents: 1, interior: Here } => Ok(()), -/// _ => Err(SendError::CannotReachDestination(destination, message)), +/// type Ticket = (); +/// fn validate(destination: &mut Option, message: &mut Option>) -> SendResult<()> { +/// match destination.as_ref().ok_or(SendError::MissingArgument)? { +/// MultiLocation { parents: 1, interior: Here } => Ok(((), MultiAssets::new())), +/// _ => Err(SendError::NotApplicable), /// } /// } +/// fn deliver(_: ()) -> Result<(), SendError> { +/// Ok(()) +/// } /// } /// /// // A call to send via XCM. We don't really care about this. @@ -335,38 +400,94 @@ pub type SendResult = result::Result<(), SendError>; /// call: call.into(), /// }]); /// -/// assert!( -/// // Sender2 will block this. -/// <(Sender1, Sender2, Sender3) as SendXcm>::send_xcm(Parent, message.clone()) -/// .is_err() -/// ); +/// // Sender2 will block this. +/// assert!(send_xcm::<(Sender1, Sender2, Sender3)>(Parent.into(), message.clone()).is_err()); /// -/// assert!( -/// // Sender3 will catch this. -/// <(Sender1, Sender3) as SendXcm>::send_xcm(Parent, message.clone()) -/// .is_ok() -/// ); +/// // Sender3 will catch this. +/// assert!(send_xcm::<(Sender1, Sender3)>(Parent.into(), message.clone()).is_ok()); /// # } /// ``` pub trait SendXcm { - /// Send an XCM `message` to a given `destination`. + type Ticket; + + /// Check whether the given `_message` is deliverable to the given `_destination` and if so + /// determine the cost which will be paid by this chain to do so, returning a `Validated` token + /// which can be used to enact delivery. /// - /// If it is not a destination which can be reached with this type but possibly could by others, then it *MUST* - /// return `CannotReachDestination`. Any other error will cause the tuple implementation to exit early without - /// trying other type fields. - fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult; + /// The `destination` and `message` must be `Some` (or else an error will be returned) and they + /// may only be consumed if the `Err` is not `NotApplicable`. + /// + /// If it is not a destination which can be reached with this type but possibly could by others, + /// then this *MUST* return `NotApplicable`. Any other error will cause the tuple + /// implementation to exit early without trying other type fields. + fn validate( + destination: &mut Option, + message: &mut Option>, + ) -> SendResult; + + /// Actually carry out the delivery operation for a previously validated message sending. + fn deliver(ticket: Self::Ticket) -> result::Result<(), SendError>; } #[impl_trait_for_tuples::impl_for_tuples(30)] impl SendXcm for Tuple { - fn send_xcm(destination: impl Into, message: Xcm<()>) -> SendResult { + for_tuples! { type Ticket = (#( Option ),* ); } + + fn validate( + destination: &mut Option, + message: &mut Option>, + ) -> SendResult { + let mut maybe_cost: Option = None; + let one_ticket: Self::Ticket = (for_tuples! { #( + if maybe_cost.is_some() { + None + } else { + match Tuple::validate(destination, message) { + Err(SendError::NotApplicable) => None, + Err(e) => { return Err(e) }, + Ok((v, c)) => { + maybe_cost = Some(c); + Some(v) + }, + } + } + ),* }); + if let Some(cost) = maybe_cost { + Ok((one_ticket, cost)) + } else { + Err(SendError::NotApplicable) + } + } + + fn deliver(one_ticket: Self::Ticket) -> result::Result<(), SendError> { for_tuples!( #( - // we shadow `destination` and `message` in each expansion for the next one. - let (destination, message) = match Tuple::send_xcm(destination, message) { - Err(SendError::CannotReachDestination(d, m)) => (d, m), - o @ _ => return o, - }; + if let Some(validated) = one_ticket.Tuple { + return Tuple::deliver(validated); + } )* ); - Err(SendError::CannotReachDestination(destination.into(), message)) + Err(SendError::Unroutable) } } + +/// Convenience function for using a `SendXcm` implementation. Just interprets the `dest` and wraps +/// both in `Some` before passing them as as mutable references into `T::send_xcm`. +pub fn validate_send(dest: MultiLocation, msg: Xcm<()>) -> SendResult { + T::validate(&mut Some(dest), &mut Some(msg)) +} + +/// Convenience function for using a `SendXcm` implementation. Just interprets the `dest` and wraps +/// both in `Some` before passing them as as mutable references into `T::send_xcm`. +/// +/// Returns either `Ok` with the price of the delivery, or `Err` with the reason why the message +/// could not be sent. +/// +/// Generally you'll want to validate and get the price first to ensure that the sender can pay it +/// before actually doing the delivery. +pub fn send_xcm( + dest: MultiLocation, + msg: Xcm<()>, +) -> result::Result { + let (ticket, price) = T::validate(&mut Some(dest), &mut Some(msg))?; + T::deliver(ticket)?; + Ok(price) +} diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index 36be7d2e41d5..1af8ff237d51 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -6,6 +6,7 @@ description = "Tools & types for building with XCM and its executor." version = "0.9.17" [dependencies] +impl-trait-for-tuples = "0.2.2" parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive"] } scale-info = { version = "1.0", default-features = false, features = ["derive"] } xcm = { path = "..", default-features = false } @@ -27,6 +28,8 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-xcm = { path = "../pallet-xcm" } polkadot-runtime-parachains = { path = "../../runtime/parachains" } +assert_matches = "1.5.0" + [features] default = ["std"] runtime-benchmarks = [] diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index be4a6291c61d..8a29a3246617 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -16,10 +16,20 @@ //! Various implementations for `ShouldExecute`. -use frame_support::{ensure, traits::Contains, weights::Weight}; +use frame_support::{ + ensure, + traits::{Contains, Get}, + weights::Weight, +}; use polkadot_parachain::primitives::IsSystem; use sp_std::{marker::PhantomData, result::Result}; -use xcm::latest::{Instruction::*, Junction, Junctions, MultiLocation, WeightLimit::*, Xcm}; +use xcm::latest::{ + Instruction::{self, *}, + InteriorMultiLocation, Junction, Junctions, + Junctions::X1, + MultiLocation, + WeightLimit::*, +}; use xcm_executor::traits::{OnResponse, ShouldExecute}; /// Execution barrier that just takes `max_weight` from `weight_credit`. @@ -31,14 +41,14 @@ pub struct TakeWeightCredit; impl ShouldExecute for TakeWeightCredit { fn should_execute( _origin: &MultiLocation, - _message: &mut Xcm, + _instructions: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, ) -> Result<(), ()> { log::trace!( target: "xcm::barriers", - "TakeWeightCredit origin: {:?}, message: {:?}, max_weight: {:?}, weight_credit: {:?}", - _origin, _message, max_weight, weight_credit, + "TakeWeightCredit origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + _origin, _instructions, max_weight, weight_credit, ); *weight_credit = weight_credit.checked_sub(max_weight).ok_or(())?; Ok(()) @@ -54,17 +64,18 @@ pub struct AllowTopLevelPaidExecutionFrom(PhantomData); impl> ShouldExecute for AllowTopLevelPaidExecutionFrom { fn should_execute( origin: &MultiLocation, - message: &mut Xcm, + instructions: &mut [Instruction], max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ()> { log::trace!( target: "xcm::barriers", - "AllowTopLevelPaidExecutionFrom origin: {:?}, message: {:?}, max_weight: {:?}, weight_credit: {:?}", - origin, message, max_weight, _weight_credit, + "AllowTopLevelPaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + origin, instructions, max_weight, _weight_credit, ); + ensure!(T::contains(origin), ()); - let mut iter = message.0.iter_mut(); + let mut iter = instructions.iter_mut(); let i = iter.next().ok_or(())?; match i { ReceiveTeleportedAsset(..) | @@ -91,20 +102,116 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionFro } } -/// Allows execution from any origin that is contained in `T` (i.e. `T::Contains(origin)`) without any payments. +/// A derivative barrier, which scans the first `MaxPrefixes` instructions for origin-alterers and +/// then evaluates `should_execute` of the `InnerBarrier` based on the remaining instructions and +/// the newly computed origin. +/// +/// This effectively allows for the possibility of distinguishing an origin which is acting as a +/// router for its derivative locations (or as a bridge for a remote location) and an origin which +/// is actually trying to send a message for itself. In the former case, the message will be +/// prefixed with origin-mutating instructions. +/// +/// Any barriers which should be interpreted based on the computed origin rather than the original +/// message origin should be subject to this. This is the case for most barriers since the +/// effective origin is generally more important than the routing origin. Any other barriers, and +/// especially those which should be interpreted only the routing origin should not be subject to +/// this. +/// +/// E.g. +/// ```nocompile +/// type MyBarrier = ( +/// TakeWeightCredit, +/// AllowTopLevelPaidExecutionFrom, +/// WithComputedOrigin<( +/// AllowTopLevelPaidExecutionFrom, +/// AllowUnpaidExecutionFrom, +/// AllowSubscriptionsFrom, +/// AllowKnownQueryResponses, +/// )>, +/// ); +/// ``` +/// +/// In the above example, `AllowUnpaidExecutionFrom` appears once underneath +/// `WithComputedOrigin`. This is in order to distinguish between messages which are notionally +/// from a derivative location of `ParentLocation` but that just happened to be sent via +/// `ParentLocaction` rather than messages that were sent by the parent. +/// +/// Similarly `AllowTopLevelPaidExecutionFrom` appears twice: once inside of `WithComputedOrigin` +/// where we provide the list of origins which are derivative origins, and then secondly outside +/// of `WithComputedOrigin` where we provide the list of locations which are direct origins. It's +/// reasonable for these lists to be merged into one and that used both inside and out. +/// +/// Finally, we see `AllowSubscriptionsFrom` and `AllowKnownQueryResponses` are both inside of +/// `WithComputedOrigin`. This means that if a message begins with origin-mutating instructions, +/// then it must be the finally computed origin which we accept subscriptions or expect a query +/// response from. For example, even if an origin appeared in the `AllowedSubscribers` list, we +/// would ignore this rule if it began with origin mutators and they changed the origin to something +/// which was not on the list. +pub struct WithComputedOrigin( + PhantomData<(InnerBarrier, LocalUniversal, MaxPrefixes)>, +); +impl< + InnerBarrier: ShouldExecute, + LocalUniversal: Get, + MaxPrefixes: Get, + > ShouldExecute for WithComputedOrigin +{ + fn should_execute( + origin: &MultiLocation, + instructions: &mut [Instruction], + max_weight: Weight, + weight_credit: &mut Weight, + ) -> Result<(), ()> { + log::trace!( + target: "xcm::barriers", + "WithComputedOrigin origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + origin, instructions, max_weight, weight_credit, + ); + let mut actual_origin = origin.clone(); + let mut skipped = 0; + // NOTE: We do not check the validity of `UniversalOrigin` here, meaning that a malicious + // origin could place a `UniversalOrigin` in order to spoof some location which gets free + // execution. This technical could get it past the barrier condition, but the execution + // would instantly fail since the first instruction would cause an error with the + // invalid UniversalOrigin. + while skipped < MaxPrefixes::get() as usize { + match instructions.get(skipped) { + Some(UniversalOrigin(new_global)) => { + // Note the origin is *relative to local consensus*! So we need to escape local + // consensus with the `parents` before diving in into the `universal_location`. + actual_origin = X1(new_global.clone()).relative_to(&LocalUniversal::get()); + }, + Some(DescendOrigin(j)) => { + actual_origin.append_with(j.clone()).map_err(|_| ())?; + }, + _ => break, + } + skipped += 1; + } + InnerBarrier::should_execute( + &actual_origin, + &mut instructions[skipped..], + max_weight, + weight_credit, + ) + } +} + +/// Allows execution from any origin that is contained in `T` (i.e. `T::Contains(origin)`) without +/// any payments. /// Use only for executions from trusted origin groups. pub struct AllowUnpaidExecutionFrom(PhantomData); impl> ShouldExecute for AllowUnpaidExecutionFrom { fn should_execute( origin: &MultiLocation, - _message: &mut Xcm, + instructions: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ()> { log::trace!( target: "xcm::barriers", - "AllowUnpaidExecutionFrom origin: {:?}, message: {:?}, max_weight: {:?}, weight_credit: {:?}", - origin, _message, _max_weight, _weight_credit, + "AllowUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + origin, instructions, _max_weight, _weight_credit, ); ensure!(T::contains(origin), ()); Ok(()) @@ -128,16 +235,16 @@ pub struct AllowKnownQueryResponses(PhantomData ShouldExecute for AllowKnownQueryResponses { fn should_execute( origin: &MultiLocation, - message: &mut Xcm, + instructions: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ()> { log::trace!( target: "xcm::barriers", - "AllowKnownQueryResponses origin: {:?}, message: {:?}, max_weight: {:?}, weight_credit: {:?}", - origin, message, _max_weight, _weight_credit, + "AllowKnownQueryResponses origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + origin, instructions, _max_weight, _weight_credit, ); - match message.0.first() { + match instructions.first() { Some(QueryResponse { query_id, querier, .. }) if ResponseHandler::expecting_response(origin, *query_id, querier.as_ref()) => Ok(()), @@ -152,17 +259,17 @@ pub struct AllowSubscriptionsFrom(PhantomData); impl> ShouldExecute for AllowSubscriptionsFrom { fn should_execute( origin: &MultiLocation, - message: &mut Xcm, + instructions: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ()> { log::trace!( target: "xcm::barriers", - "AllowSubscriptionsFrom origin: {:?}, message: {:?}, max_weight: {:?}, weight_credit: {:?}", - origin, message, _max_weight, _weight_credit, + "AllowSubscriptionsFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + origin, instructions, _max_weight, _weight_credit, ); ensure!(T::contains(origin), ()); - match (message.0.len(), message.0.first()) { + match (instructions.len(), instructions.first()) { (1, Some(SubscribeVersion { .. })) | (1, Some(UnsubscribeVersion)) => Ok(()), _ => Err(()), } diff --git a/xcm/xcm-builder/src/bridging_tests/local_para_para.rs b/xcm/xcm-builder/src/bridging_tests/local_para_para.rs new file mode 100644 index 000000000000..0e6bcfd4b6dd --- /dev/null +++ b/xcm/xcm-builder/src/bridging_tests/local_para_para.rs @@ -0,0 +1,110 @@ +// Copyright 2021 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 . + +//! This test is when we're sending an XCM from a parachain which hosts a bridge to another +//! network's bridge parachain. The destination of the XCM is within the global consensus of the +//! remote side of the bridge. + +use super::*; + +parameter_types! { + pub UniversalLocation: Junctions = X2(GlobalConsensus(Local::get()), Parachain(1)); + pub RemoteUniversalLocation: Junctions = X2(GlobalConsensus(Remote::get()), Parachain(1)); +} +type TheBridge = + TestBridge>; +type Router = LocalUnpaidExporter, UniversalLocation>; + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// | +/// | +/// | +/// | +/// Parachain(1) ===> Parachain(1) +/// ``` +#[test] +fn sending_to_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); + let dest = (Parent, Parent, Remote::get(), Parachain(1)).into(); + assert_eq!(send_xcm::(dest, msg), Ok((Here, 100).into())); + assert_eq!(TheBridge::service(), 1); + assert_eq!( + take_received_remote_messages(), + vec![( + Here.into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(1).into()), + Trap(1), + ]) + )] + ); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// | +/// | +/// | +/// | +/// Parachain(1) ===> Parachain(1) ==> Parachain(1000) +/// ``` +#[test] +fn sending_to_parachain_of_bridged_chain_works() { + let dest = (Parent, Parent, Remote::get(), Parachain(1000)).into(); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Here, 100).into())); + assert_eq!(TheBridge::service(), 1); + let expected = vec![( + (Parent, Parachain(1000)).into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(1).into()), + Trap(1), + ]), + )]; + assert_eq!(take_received_remote_messages(), expected); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// | /\ +/// | || +/// | || +/// | || +/// Parachain(1) ===> Parachain(1) +/// ``` +#[test] +fn sending_to_relay_chain_of_bridged_chain_works() { + let dest = (Parent, Parent, Remote::get()).into(); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Here, 100).into())); + assert_eq!(TheBridge::service(), 1); + let expected = vec![( + Parent.into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(1).into()), + Trap(1), + ]), + )]; + assert_eq!(take_received_remote_messages(), expected); +} diff --git a/xcm/xcm-builder/src/bridging_tests/local_relay_relay.rs b/xcm/xcm-builder/src/bridging_tests/local_relay_relay.rs new file mode 100644 index 000000000000..244458f363fd --- /dev/null +++ b/xcm/xcm-builder/src/bridging_tests/local_relay_relay.rs @@ -0,0 +1,66 @@ +// Copyright 2021 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 . + +//! This test is when we're sending an XCM from a relay-chain which hosts a bridge to another +//! relay-chain. The destination of the XCM is within the global consensus of the +//! remote side of the bridge. + +use super::*; + +parameter_types! { + pub UniversalLocation: Junctions = X1(GlobalConsensus(Local::get())); + pub RemoteUniversalLocation: Junctions = X1(GlobalConsensus(Remote::get())); +} +type TheBridge = + TestBridge>; +type Router = LocalUnpaidExporter, UniversalLocation>; + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) ========> GlobalConsensus(Remote::get()) +/// | +/// ``` +#[test] +fn sending_to_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); + assert_eq!(send_xcm::((Parent, Remote::get()).into(), msg), Ok((Here, 100).into())); + assert_eq!(TheBridge::service(), 1); + assert_eq!( + take_received_remote_messages(), + vec![(Here.into(), Xcm(vec![UniversalOrigin(Local::get().into()), Trap(1)]))] + ); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) ========> GlobalConsensus(Remote::get()) +/// | || +/// | || +/// | || +/// | \/ +/// | Parachain(1000) +/// ``` +#[test] +fn sending_to_parachain_of_bridged_chain_works() { + let dest = (Parent, Remote::get(), Parachain(1000)).into(); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Here, 100).into())); + assert_eq!(TheBridge::service(), 1); + let expected = + vec![(Parachain(1000).into(), Xcm(vec![UniversalOrigin(Local::get().into()), Trap(1)]))]; + assert_eq!(take_received_remote_messages(), expected); +} diff --git a/xcm/xcm-builder/src/bridging_tests/mod.rs b/xcm/xcm-builder/src/bridging_tests/mod.rs new file mode 100644 index 000000000000..6e340ff613d1 --- /dev/null +++ b/xcm/xcm-builder/src/bridging_tests/mod.rs @@ -0,0 +1,181 @@ +// Copyright 2021 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 . + +//! Tests specific to the bridging primitives + +use crate::{mock::*, universal_exports::*}; +use frame_support::{parameter_types, traits::Get}; +use std::{cell::RefCell, marker::PhantomData}; +use xcm::prelude::*; +use xcm_executor::{ + traits::{export_xcm, validate_export}, + XcmExecutor, +}; +use SendError::*; + +mod local_para_para; +mod local_relay_relay; +mod paid_remote_relay_relay; +mod remote_para_para; +mod remote_para_para_via_relay; +mod remote_relay_relay; + +parameter_types! { + pub Local: NetworkId = ByGenesis([0; 32]); + pub Remote: NetworkId = ByGenesis([1; 32]); + pub Price: MultiAssets = MultiAssets::from((Here, 100)); +} + +std::thread_local! { + static BRIDGE_TRAFFIC: RefCell>> = RefCell::new(Vec::new()); +} + +struct TestBridge(PhantomData); +impl TestBridge { + fn service() -> u64 { + BRIDGE_TRAFFIC + .with(|t| t.borrow_mut().drain(..).map(|b| D::dispatch_blob(b).map_or(0, |()| 1)).sum()) + } +} +impl HaulBlob for TestBridge { + fn haul_blob(blob: Vec) { + BRIDGE_TRAFFIC.with(|t| t.borrow_mut().push(blob)); + } +} + +std::thread_local! { + static REMOTE_INCOMING_XCM: RefCell)>> = RefCell::new(Vec::new()); +} +struct TestRemoteIncomingRouter; +impl SendXcm for TestRemoteIncomingRouter { + type Ticket = (MultiLocation, Xcm<()>); + fn validate( + dest: &mut Option, + msg: &mut Option>, + ) -> SendResult<(MultiLocation, Xcm<()>)> { + let pair = (dest.take().unwrap(), msg.take().unwrap()); + Ok((pair, MultiAssets::new())) + } + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { + REMOTE_INCOMING_XCM.with(|q| q.borrow_mut().push(pair)); + Ok(()) + } +} + +fn take_received_remote_messages() -> Vec<(MultiLocation, Xcm<()>)> { + REMOTE_INCOMING_XCM.with(|r| r.replace(vec![])) +} + +/// This is a dummy router which accepts messages destined for `Remote` from `Local` +/// and then executes them for free in a context simulated to be like that of our `Remote`. +struct UnpaidExecutingRouter( + PhantomData<(Local, Remote, RemoteExporter)>, +); + +fn price( + n: NetworkId, + c: u32, + d: &InteriorMultiLocation, + m: &Xcm<()>, +) -> Result { + Ok(validate_export::(n, c, d.clone(), m.clone())?.1) +} + +fn deliver( + n: NetworkId, + c: u32, + d: InteriorMultiLocation, + m: Xcm<()>, +) -> Result<(), SendError> { + export_xcm::(n, c, d, m)?; + Ok(()) +} + +impl, Remote: Get, RemoteExporter: ExportXcm> SendXcm + for UnpaidExecutingRouter +{ + type Ticket = Xcm<()>; + + fn validate( + destination: &mut Option, + message: &mut Option>, + ) -> SendResult> { + let expect_dest = Remote::get().relative_to(&Local::get()); + if destination.as_ref().ok_or(MissingArgument)? != &expect_dest { + return Err(NotApplicable) + } + let message = message.take().ok_or(MissingArgument)?; + Ok((message, MultiAssets::new())) + } + + fn deliver(message: Xcm<()>) -> Result<(), SendError> { + // We now pretend that the message was delivered from `Local` to `Remote`, and execute + // so we need to ensure that the `TestConfig` is set up properly for executing as + // though it is `Remote`. + ExecutorUniversalLocation::set(Remote::get()); + let origin = Local::get().relative_to(&Remote::get()); + AllowUnpaidFrom::set(vec![origin.clone()]); + set_exporter_override(price::, deliver::); + // The we execute it: + let outcome = + XcmExecutor::::execute_xcm(origin, message.into(), 2_000_000_000_000); + match outcome { + Outcome::Complete(..) => Ok(()), + Outcome::Incomplete(..) => Err(Transport("Error executing")), + Outcome::Error(..) => Err(Transport("Unable to execute")), + } + } +} + +/// This is a dummy router which accepts messages destined for `Remote` from `Local` +/// and then executes them in a context simulated to be like that of our `Remote`. Payment is +/// needed. +struct ExecutingRouter(PhantomData<(Local, Remote, RemoteExporter)>); +impl, Remote: Get, RemoteExporter: ExportXcm> SendXcm + for ExecutingRouter +{ + type Ticket = Xcm<()>; + + fn validate( + destination: &mut Option, + message: &mut Option>, + ) -> SendResult> { + let expect_dest = Remote::get().relative_to(&Local::get()); + if destination.as_ref().ok_or(MissingArgument)? != &expect_dest { + return Err(NotApplicable) + } + let message = message.take().ok_or(MissingArgument)?; + Ok((message, MultiAssets::new())) + } + + fn deliver(message: Xcm<()>) -> Result<(), SendError> { + // We now pretend that the message was delivered from `Local` to `Remote`, and execute + // so we need to ensure that the `TestConfig` is set up properly for executing as + // though it is `Remote`. + ExecutorUniversalLocation::set(Remote::get()); + let origin = Local::get().relative_to(&Remote::get()); + AllowPaidFrom::set(vec![origin.clone()]); + set_exporter_override(price::, deliver::); + // The we execute it: + let outcome = + XcmExecutor::::execute_xcm(origin, message.into(), 2_000_000_000_000); + match outcome { + Outcome::Complete(..) => Ok(()), + Outcome::Incomplete(..) => Err(Transport("Error executing")), + Outcome::Error(..) => Err(Transport("Unable to execute")), + } + } +} diff --git a/xcm/xcm-builder/src/bridging_tests/paid_remote_relay_relay.rs b/xcm/xcm-builder/src/bridging_tests/paid_remote_relay_relay.rs new file mode 100644 index 000000000000..cf70b56b4a87 --- /dev/null +++ b/xcm/xcm-builder/src/bridging_tests/paid_remote_relay_relay.rs @@ -0,0 +1,123 @@ +// Copyright 2021 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 . + +//! This test is when we're sending an XCM from a parachain whose relay-chain hosts a bridge to +//! another relay-chain. The destination of the XCM is within the global consensus of the +//! remote side of the bridge. +//! +//! The Relay-chain here requires payment by the parachain for use of the bridge. This is expressed +//! under the standard XCM weight and the weight pricing. + +use super::*; + +parameter_types! { + pub UniversalLocation: Junctions = X2(GlobalConsensus(Local::get()), Parachain(100)); + pub RelayUniversalLocation: Junctions = X1(GlobalConsensus(Local::get())); + pub RemoteUniversalLocation: Junctions = X1(GlobalConsensus(Remote::get())); + pub static BridgeTable: Vec<(NetworkId, MultiLocation, Option)> + = vec![(Remote::get(), MultiLocation::parent(), Some((Parent, 150).into()))]; + // ^^^ 100 to use the bridge (export) and 50 for the remote execution weight (5 instuctions + // x 10 weight each). +} +type TheBridge = + TestBridge>; +type RelayExporter = HaulBlobExporter; +type LocalInnerRouter = ExecutingRouter; +type LocalBridgeRouter = SovereignPaidRemoteExporter< + NetworkExportTable, + LocalInnerRouter, + UniversalLocation, +>; +type LocalRouter = (LocalInnerRouter, LocalBridgeRouter); + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) ========> GlobalConsensus(Remote::get()) +/// /\ | +/// || | +/// || | +/// || | +/// Parachain(100) | +/// ``` +#[test] +fn sending_to_bridged_chain_works() { + let dest: MultiLocation = (Parent, Parent, Remote::get()).into(); + // Routing won't work if we don't have enough funds. + assert_eq!( + send_xcm::(dest.clone(), Xcm(vec![Trap(1)])), + Err(SendError::Transport("Error executing")), + ); + + // Initialize the local relay so that our parachain has funds to pay for export. + add_asset(to_account(Parachain(100)).unwrap(), (Here, 1000)); + + let msg = Xcm(vec![Trap(1)]); + assert_eq!(send_xcm::(dest, msg), Ok((Parent, 150).into())); + assert_eq!(TheBridge::service(), 1); + assert_eq!( + take_received_remote_messages(), + vec![( + Here.into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(100).into()), + Trap(1), + ]) + )] + ); + + // The export cost 50 weight units (and thus 50 units of balance). + assert_eq!(assets(to_account(Parachain(100)).unwrap()), vec![(Here, 850).into()]); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) ========> GlobalConsensus(Remote::get()) +/// /\ | || +/// || | || +/// || | || +/// || | \/ +/// Parachain(100) | Parachain(100) +/// ``` +#[test] +fn sending_to_parachain_of_bridged_chain_works() { + let dest: MultiLocation = (Parent, Parent, Remote::get(), Parachain(100)).into(); + // Routing won't work if we don't have enough funds. + assert_eq!( + send_xcm::(dest.clone(), Xcm(vec![Trap(1)])), + Err(SendError::Transport("Error executing")), + ); + + // Initialize the local relay so that our parachain has funds to pay for export. + add_asset(to_account(Parachain(100)).unwrap(), (Here, 1000)); + + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Parent, 150).into())); + assert_eq!(TheBridge::service(), 1); + let expected = vec![( + Parachain(100).into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(100).into()), + Trap(1), + ]), + )]; + assert_eq!(take_received_remote_messages(), expected); + + // The export cost 50 weight units (and thus 50 units of balance). + assert_eq!(assets(to_account(Parachain(100)).unwrap()), vec![(Here, 850).into()]); +} diff --git a/xcm/xcm-builder/src/bridging_tests/remote_para_para.rs b/xcm/xcm-builder/src/bridging_tests/remote_para_para.rs new file mode 100644 index 000000000000..a79c1efa23ba --- /dev/null +++ b/xcm/xcm-builder/src/bridging_tests/remote_para_para.rs @@ -0,0 +1,120 @@ +// Copyright 2021 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 . + +//! This test is when we're sending an XCM from a parachain whose sibling parachain hosts a +//! bridge to a parachain from another global consensus. The destination of the XCM is within +//! the global consensus of the remote side of the bridge. + +use super::*; + +parameter_types! { + pub UniversalLocation: Junctions = X2(GlobalConsensus(Local::get()), Parachain(1000)); + pub ParaBridgeUniversalLocation: Junctions = X2(GlobalConsensus(Local::get()), Parachain(1)); + pub RemoteParaBridgeUniversalLocation: Junctions = X2(GlobalConsensus(Remote::get()), Parachain(1)); + pub BridgeTable: Vec<(NetworkId, MultiLocation, Option)> + = vec![(Remote::get(), (Parent, Parachain(1)).into(), None)]; +} +type TheBridge = + TestBridge>; +type RelayExporter = HaulBlobExporter; +type LocalInnerRouter = + UnpaidExecutingRouter; +type LocalBridgingRouter = + UnpaidRemoteExporter, LocalInnerRouter, UniversalLocation>; +type LocalRouter = (LocalInnerRouter, LocalBridgingRouter); + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// | +/// | +/// | +/// | +/// Parachain(1000) ===> Parachain(1) ===> Parachain(1) +/// ``` +#[test] +fn sending_to_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); + assert_eq!( + send_xcm::((Parent, Parent, Remote::get(), Parachain(1)).into(), msg), + Ok(MultiAssets::new()) + ); + assert_eq!(TheBridge::service(), 1); + assert_eq!( + take_received_remote_messages(), + vec![( + Here.into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(1000).into()), + Trap(1) + ]) + )] + ); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// | +/// | +/// | +/// | +/// Parachain(1000) ===> Parachain(1) ===> Parachain(1) ===> Parachain(1000) +/// ``` +#[test] +fn sending_to_sibling_of_bridged_chain_works() { + let dest = (Parent, Parent, Remote::get(), Parachain(1000)).into(); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(TheBridge::service(), 1); + let expected = vec![( + (Parent, Parachain(1000)).into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(1000).into()), + Trap(1), + ]), + )]; + assert_eq!(take_received_remote_messages(), expected); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// | /\ +/// | || +/// | || +/// | || +/// Parachain(1000) ===> Parachain(1) ===> Parachain(1) +/// ``` +#[test] +fn sending_to_relay_of_bridged_chain_works() { + let dest = (Parent, Parent, Remote::get()).into(); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(TheBridge::service(), 1); + let expected = vec![( + Parent.into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(1000).into()), + Trap(1), + ]), + )]; + assert_eq!(take_received_remote_messages(), expected); +} diff --git a/xcm/xcm-builder/src/bridging_tests/remote_para_para_via_relay.rs b/xcm/xcm-builder/src/bridging_tests/remote_para_para_via_relay.rs new file mode 100644 index 000000000000..3746e5c7766c --- /dev/null +++ b/xcm/xcm-builder/src/bridging_tests/remote_para_para_via_relay.rs @@ -0,0 +1,102 @@ +// Copyright 2021 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 . + +//! This test is when we're sending an XCM from a relay-chain whose child parachain hosts a +//! bridge to a parachain from another global consensus. The destination of the XCM is within +//! the global consensus of the remote side of the bridge. + +use super::*; + +parameter_types! { + pub UniversalLocation: Junctions = X1(GlobalConsensus(Local::get())); + pub ParaBridgeUniversalLocation: Junctions = X2(GlobalConsensus(Local::get()), Parachain(1)); + pub RemoteParaBridgeUniversalLocation: Junctions = X2(GlobalConsensus(Remote::get()), Parachain(1)); + pub BridgeTable: Vec<(NetworkId, MultiLocation, Option)> + = vec![(Remote::get(), Parachain(1).into(), None)]; +} +type TheBridge = + TestBridge>; +type RelayExporter = HaulBlobExporter; +type LocalInnerRouter = + UnpaidExecutingRouter; +type LocalBridgingRouter = + UnpaidRemoteExporter, LocalInnerRouter, UniversalLocation>; +type LocalRouter = (LocalInnerRouter, LocalBridgingRouter); + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// || | +/// || | +/// || | +/// \/ | +/// Parachain(1) ===> Parachain(1) +/// ``` +#[test] +fn sending_to_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); + assert_eq!( + send_xcm::((Parent, Remote::get(), Parachain(1)).into(), msg), + Ok(MultiAssets::new()) + ); + assert_eq!(TheBridge::service(), 1); + assert_eq!( + take_received_remote_messages(), + vec![(Here.into(), Xcm(vec![UniversalOrigin(Local::get().into()), Trap(1)]))] + ); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// || | +/// || | +/// || | +/// \/ | +/// Parachain(1) ===> Parachain(1) ===> Parachain(1000) +/// ``` +#[test] +fn sending_to_sibling_of_bridged_chain_works() { + let dest = (Parent, Remote::get(), Parachain(1000)).into(); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(TheBridge::service(), 1); + let expected = vec![( + (Parent, Parachain(1000)).into(), + Xcm(vec![UniversalOrigin(Local::get().into()), Trap(1)]), + )]; + assert_eq!(take_received_remote_messages(), expected); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) | GlobalConsensus(Remote::get()) +/// || | /\ +/// || | || +/// || | || +/// \/ | || +/// Parachain(1) ===> Parachain(1) +/// ``` +#[test] +fn sending_to_relay_of_bridged_chain_works() { + let dest = (Parent, Remote::get()).into(); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(TheBridge::service(), 1); + let expected = vec![(Parent.into(), Xcm(vec![UniversalOrigin(Local::get().into()), Trap(1)]))]; + assert_eq!(take_received_remote_messages(), expected); +} diff --git a/xcm/xcm-builder/src/bridging_tests/remote_relay_relay.rs b/xcm/xcm-builder/src/bridging_tests/remote_relay_relay.rs new file mode 100644 index 000000000000..0fed565a53f0 --- /dev/null +++ b/xcm/xcm-builder/src/bridging_tests/remote_relay_relay.rs @@ -0,0 +1,94 @@ +// Copyright 2021 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 . + +//! This test is when we're sending an XCM from a parachain whose relay-chain hosts a bridge to +//! another relay-chain. The destination of the XCM is within the global consensus of the +//! remote side of the bridge. + +use super::*; + +parameter_types! { + pub UniversalLocation: Junctions = X2(GlobalConsensus(Local::get()), Parachain(1000)); + pub RelayUniversalLocation: Junctions = X1(GlobalConsensus(Local::get())); + pub RemoteUniversalLocation: Junctions = X1(GlobalConsensus(Remote::get())); + pub BridgeTable: Vec<(NetworkId, MultiLocation, Option)> + = vec![(Remote::get(), MultiLocation::parent(), None)]; +} +type TheBridge = + TestBridge>; +type RelayExporter = HaulBlobExporter; +type LocalInnerRouter = + UnpaidExecutingRouter; +type LocalBridgeRouter = + UnpaidRemoteExporter, LocalInnerRouter, UniversalLocation>; +type LocalRouter = (LocalInnerRouter, LocalBridgeRouter); + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) ========> GlobalConsensus(Remote::get()) +/// /\ | +/// || | +/// || | +/// || | +/// Parachain(1000) | +/// ``` +#[test] +fn sending_to_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); + assert_eq!( + send_xcm::((Parent, Parent, Remote::get()).into(), msg), + Ok(MultiAssets::new()) + ); + assert_eq!(TheBridge::service(), 1); + assert_eq!( + take_received_remote_messages(), + vec![( + Here.into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(1000).into()), + Trap(1) + ]) + )] + ); +} + +/// ```nocompile +/// local | remote +/// | +/// GlobalConsensus(Local::get()) ========> GlobalConsensus(Remote::get()) +/// /\ | || +/// || | || +/// || | || +/// || | \/ +/// Parachain(1000) | Parachain(1000) +/// ``` +#[test] +fn sending_to_parachain_of_bridged_chain_works() { + let dest = (Parent, Parent, Remote::get(), Parachain(1000)).into(); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(TheBridge::service(), 1); + let expected = vec![( + Parachain(1000).into(), + Xcm(vec![ + UniversalOrigin(Local::get().into()), + DescendOrigin(Parachain(1000).into()), + Trap(1), + ]), + )]; + assert_eq!(take_received_remote_messages(), expected); +} diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index e3473d55d5eb..20f57496e696 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -20,6 +20,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +#[cfg(test)] +mod bridging_tests; #[cfg(test)] mod mock; #[cfg(test)] @@ -45,7 +47,7 @@ pub use origin_conversion::{ mod barriers; pub use barriers::{ AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, - AllowUnpaidExecutionFrom, IsChildSystemParachain, TakeWeightCredit, + AllowUnpaidExecutionFrom, IsChildSystemParachain, TakeWeightCredit, WithComputedOrigin, }; mod currency_adapter; @@ -69,3 +71,9 @@ pub use matches_fungible::{IsAbstract, IsConcrete}; mod filter_asset_location; pub use filter_asset_location::{Case, NativeAsset}; + +mod universal_exports; +pub use universal_exports::{ + ExporterFor, LocalUnpaidExporter, NetworkExportTable, SovereignPaidRemoteExporter, + UnpaidRemoteExporter, +}; diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index a5bb40c87ec0..a40dff5c93af 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -19,11 +19,11 @@ use parity_scale_codec::{Decode, Encode}; use sp_io::hashing::blake2_256; use sp_runtime::traits::{AccountIdConversion, TrailingZeroInput}; use sp_std::{borrow::Borrow, marker::PhantomData}; -use xcm::latest::{Junction::*, Junctions::*, MultiLocation, NetworkId, Parent}; -use xcm_executor::traits::{Convert, InvertLocation}; +use xcm::latest::prelude::*; +use xcm_executor::traits::{Convert, UniversalLocation}; pub struct Account32Hash(PhantomData<(Network, AccountId)>); -impl, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone> +impl>, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone> Convert for Account32Hash { fn convert_ref(location: impl Borrow) -> Result { @@ -107,15 +107,12 @@ impl + Into + AccountIdConversion, AccountId: /// Extracts the `AccountId32` from the passed `location` if the network matches. pub struct AccountId32Aliases(PhantomData<(Network, AccountId)>); -impl, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone> +impl>, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone> Convert for AccountId32Aliases { fn convert(location: MultiLocation) -> Result { let id = match location { - MultiLocation { - parents: 0, - interior: X1(AccountId32 { id, network: NetworkId::Any }), - } => id, + MultiLocation { parents: 0, interior: X1(AccountId32 { id, network: None }) } => id, MultiLocation { parents: 0, interior: X1(AccountId32 { id, network }) } if network == Network::get() => id, @@ -130,15 +127,12 @@ impl, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone } pub struct AccountKey20Aliases(PhantomData<(Network, AccountId)>); -impl, AccountId: From<[u8; 20]> + Into<[u8; 20]> + Clone> +impl>, AccountId: From<[u8; 20]> + Into<[u8; 20]> + Clone> Convert for AccountKey20Aliases { fn convert(location: MultiLocation) -> Result { let key = match location { - MultiLocation { - parents: 0, - interior: X1(AccountKey20 { key, network: NetworkId::Any }), - } => key, + MultiLocation { parents: 0, interior: X1(AccountKey20 { key, network: None }) } => key, MultiLocation { parents: 0, interior: X1(AccountKey20 { key, network }) } if network == Network::get() => key, @@ -153,7 +147,7 @@ impl, AccountId: From<[u8; 20]> + Into<[u8; 20]> + Clone } } -/// Simple location inverter; give it this location's ancestry and it'll figure out the inverted +/// Simple location inverter; give it this location's context and it'll figure out the inverted /// location. /// /// # Example @@ -166,41 +160,30 @@ impl, AccountId: From<[u8; 20]> + Into<[u8; 20]> + Clone /// ``` /// ```rust /// # use frame_support::parameter_types; -/// # use xcm::latest::{MultiLocation, Junction::*, Junctions::{self, *}, NetworkId::Any}; +/// # use xcm::latest::prelude::*; /// # use xcm_builder::LocationInverter; -/// # use xcm_executor::traits::InvertLocation; +/// # use xcm_executor::traits::UniversalLocation; /// # fn main() { /// parameter_types!{ -/// pub Ancestry: MultiLocation = X2( +/// pub Ancestry: InteriorMultiLocation = X2( /// Parachain(1), -/// AccountKey20 { network: Any, key: Default::default() }, -/// ).into(); +/// AccountKey20 { network: None, key: Default::default() }, +/// ); /// } /// -/// let input = MultiLocation::new(2, X2(Parachain(2), AccountId32 { network: Any, id: Default::default() })); +/// let input = MultiLocation::new(2, X2(Parachain(2), AccountId32 { network: None, id: Default::default() })); /// let inverted = LocationInverter::::invert_location(&input); /// assert_eq!(inverted, Ok(MultiLocation::new( /// 2, -/// X2(Parachain(1), AccountKey20 { network: Any, key: Default::default() }), +/// X2(Parachain(1), AccountKey20 { network: None, key: Default::default() }), /// ))); /// # } /// ``` pub struct LocationInverter(PhantomData); -impl> InvertLocation for LocationInverter { - fn ancestry() -> MultiLocation { +impl> UniversalLocation for LocationInverter { + fn universal_location() -> InteriorMultiLocation { Ancestry::get() } - fn invert_location(location: &MultiLocation) -> Result { - let mut ancestry = Ancestry::get(); - let mut junctions = Here; - for _ in 0..location.parent_count() { - junctions = junctions - .pushed_with(ancestry.take_first_interior().unwrap_or(OnlyChild)) - .map_err(|_| ())?; - } - let parents = location.interior().len() as u8; - Ok(MultiLocation::new(parents, junctions)) - } } #[cfg(test)] @@ -208,14 +191,14 @@ mod tests { use super::*; use frame_support::parameter_types; - use xcm::latest::{Junction, NetworkId::Any}; + use xcm::latest::Junction; fn account20() -> Junction { - AccountKey20 { network: Any, key: Default::default() } + AccountKey20 { network: None, key: Default::default() } } fn account32() -> Junction { - AccountId32 { network: Any, id: Default::default() } + AccountId32 { network: None, id: Default::default() } } // Network Topology @@ -227,13 +210,13 @@ mod tests { // Inputs and outputs written as file paths: // // input location (source to target): ../../../para_2/account32_default - // ancestry (root to source): para_1/account20_default/account20_default + // context (root to source): para_1/account20_default/account20_default // => // output (target to source): ../../para_1/account20_default/account20_default #[test] fn inverter_works_in_tree() { parameter_types! { - pub Ancestry: MultiLocation = X3(Parachain(1), account20(), account20()).into(); + pub Ancestry: InteriorMultiLocation = X3(Parachain(1), account20(), account20()); } let input = MultiLocation::new(3, X2(Parachain(2), account32())); @@ -246,9 +229,9 @@ mod tests { // Relay -> Para 1 -> SmartContract -> Account // ^ Target #[test] - fn inverter_uses_ancestry_as_inverted_location() { + fn inverter_uses_context_as_inverted_location() { parameter_types! { - pub Ancestry: MultiLocation = X2(account20(), account20()).into(); + pub Ancestry: InteriorMultiLocation = X2(account20(), account20()); } let input = MultiLocation::grandparent(); @@ -261,9 +244,9 @@ mod tests { // Relay -> Para 1 -> CollectivePallet -> Plurality // ^ Target #[test] - fn inverter_uses_only_child_on_missing_ancestry() { + fn inverter_uses_only_child_on_missing_context() { parameter_types! { - pub Ancestry: MultiLocation = X1(PalletInstance(5)).into(); + pub Ancestry: InteriorMultiLocation = X1(PalletInstance(5)); } let input = MultiLocation::grandparent(); @@ -274,7 +257,7 @@ mod tests { #[test] fn inverter_errors_when_location_is_too_large() { parameter_types! { - pub Ancestry: MultiLocation = Here.into(); + pub Ancestry: InteriorMultiLocation = Here; } let input = MultiLocation { parents: 99, interior: X1(Parachain(88)) }; diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/mock.rs index 74ba7f1fbd74..0d80e7fdbb28 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/mock.rs @@ -37,7 +37,10 @@ pub use sp_std::{ }; pub use xcm::latest::prelude::*; pub use xcm_executor::{ - traits::{ConvertOrigin, FilterAssetLocation, InvertLocation, OnResponse, TransactAsset}, + traits::{ + ConvertOrigin, ExportXcm, FeeManager, FeeReason, FilterAssetLocation, OnResponse, + TransactAsset, UniversalLocation, + }, Assets, Config, }; @@ -101,18 +104,82 @@ impl GetDispatchInfo for TestCall { } thread_local! { - pub static SENT_XCM: RefCell> = RefCell::new(Vec::new()); + pub static SENT_XCM: RefCell)>> = RefCell::new(Vec::new()); + pub static EXPORTED_XCM: RefCell)>> = RefCell::new(Vec::new()); + pub static EXPORTER_OVERRIDE: RefCell) -> Result, + fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result<(), SendError>, + )>> = RefCell::new(None); } pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm)> { SENT_XCM.with(|q| (*q.borrow()).clone()) } -pub struct TestSendXcm; -impl SendXcm for TestSendXcm { - fn send_xcm(dest: impl Into, msg: opaque::Xcm) -> SendResult { - SENT_XCM.with(|q| q.borrow_mut().push((dest.into(), msg))); +pub fn exported_xcm() -> Vec<(NetworkId, u32, InteriorMultiLocation, opaque::Xcm)> { + EXPORTED_XCM.with(|q| (*q.borrow()).clone()) +} +pub fn set_exporter_override( + price: fn(NetworkId, u32, &InteriorMultiLocation, &Xcm<()>) -> Result, + deliver: fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result<(), SendError>, +) { + EXPORTER_OVERRIDE.with(|x| x.replace(Some((price, deliver)))); +} +#[allow(dead_code)] +pub fn clear_exporter_override() { + EXPORTER_OVERRIDE.with(|x| x.replace(None)); +} +pub struct TestMessageSender; +impl SendXcm for TestMessageSender { + type Ticket = (MultiLocation, Xcm<()>); + fn validate( + dest: &mut Option, + msg: &mut Option>, + ) -> SendResult<(MultiLocation, Xcm<()>)> { + let pair = (dest.take().unwrap(), msg.take().unwrap()); + Ok((pair, MultiAssets::new())) + } + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { + SENT_XCM.with(|q| q.borrow_mut().push(pair)); Ok(()) } } +pub struct TestMessageExporter; +impl ExportXcm for TestMessageExporter { + type Ticket = (NetworkId, u32, InteriorMultiLocation, Xcm<()>); + fn validate( + network: NetworkId, + channel: u32, + dest: &mut Option, + msg: &mut Option>, + ) -> SendResult<(NetworkId, u32, InteriorMultiLocation, Xcm<()>)> { + let (d, m) = (dest.take().unwrap(), msg.take().unwrap()); + let r: Result = EXPORTER_OVERRIDE.with(|e| { + if let Some((ref f, _)) = &*e.borrow() { + f(network, channel, &d, &m) + } else { + Ok(MultiAssets::new()) + } + }); + match r { + Ok(price) => Ok(((network, channel, d, m), price)), + Err(e) => { + *dest = Some(d); + *msg = Some(m); + Err(e) + }, + } + } + fn deliver(tuple: (NetworkId, u32, InteriorMultiLocation, Xcm<()>)) -> Result<(), SendError> { + EXPORTER_OVERRIDE.with(|e| { + if let Some((_, ref f)) = &*e.borrow() { + let (network, channel, dest, msg) = tuple; + f(network, channel, dest, msg) + } else { + EXPORTED_XCM.with(|q| q.borrow_mut().push(tuple)); + Ok(()) + } + }) + } +} thread_local! { pub static ASSETS: RefCell> = RefCell::new(BTreeMap::new()); @@ -144,8 +211,8 @@ impl TransactAsset for TestAssetTransactor { } } -pub fn to_account(l: MultiLocation) -> Result { - Ok(match l { +pub fn to_account(l: impl Into) -> Result { + Ok(match l.into() { // Siblings at 2000+id MultiLocation { parents: 1, interior: X1(Parachain(id)) } => 2000 + id as u64, // Accounts are their number @@ -156,7 +223,18 @@ pub fn to_account(l: MultiLocation) -> Result { MultiLocation { parents: 0, interior: Here } => 3000, // Parent at 3001 MultiLocation { parents: 1, interior: Here } => 3001, - _ => return Err(l), + l => { + // Is it a foreign-consensus? + let uni = ExecutorUniversalLocation::get(); + if l.parents as usize != uni.len() { + return Err(l) + } + match l.first_interior() { + Some(GlobalConsensus(Kusama)) => 4000, + Some(GlobalConsensus(Polkadot)) => 4001, + _ => return Err(l), + } + }, }) } @@ -183,6 +261,7 @@ impl ConvertOrigin for TestOriginConverter { thread_local! { pub static IS_RESERVE: RefCell>> = RefCell::new(BTreeMap::new()); pub static IS_TELEPORTER: RefCell>> = RefCell::new(BTreeMap::new()); + pub static UNIVERSAL_ALIASES: RefCell> = RefCell::new(BTreeSet::new()); } pub fn add_reserve(from: MultiLocation, asset: MultiAssetFilter) { IS_RESERVE.with(|r| r.borrow_mut().entry(from).or_default().push(asset)); @@ -191,6 +270,13 @@ pub fn add_reserve(from: MultiLocation, asset: MultiAssetFilter) { pub fn add_teleporter(from: MultiLocation, asset: MultiAssetFilter) { IS_TELEPORTER.with(|r| r.borrow_mut().entry(from).or_default().push(asset)); } +pub fn add_universal_alias(bridge: impl Into, consensus: impl Into) { + UNIVERSAL_ALIASES.with(|r| r.borrow_mut().insert((bridge.into(), consensus.into()))); +} +pub fn clear_universal_aliases() { + UNIVERSAL_ALIASES.with(|r| r.replace(Default::default())); +} + pub struct TestIsReserve; impl FilterAssetLocation for TestIsReserve { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { @@ -206,7 +292,13 @@ impl FilterAssetLocation for TestIsTeleporter { } } -use xcm::latest::Response; +pub struct TestUniversalAliases; +impl Contains<(MultiLocation, Junction)> for TestUniversalAliases { + fn contains(t: &(MultiLocation, Junction)) -> bool { + UNIVERSAL_ALIASES.with(|r| r.borrow().contains(t)) + } +} + pub enum ResponseSlot { Expecting(MultiLocation), Received(Response), @@ -256,7 +348,8 @@ pub fn response(query_id: u64) -> Option { } parameter_types! { - pub TestAncestry: MultiLocation = X1(Parachain(42)).into(); + pub static ExecutorUniversalLocation: InteriorMultiLocation + = (ByGenesis([0; 32]), Parachain(42)).into(); pub UnitWeightCost: Weight = 10; } parameter_types! { @@ -277,15 +370,23 @@ pub type TestBarrier = ( AllowSubscriptionsFrom>, ); +pub struct TestFeeManager; +impl FeeManager for TestFeeManager { + fn is_waived(_: &Option, r: FeeReason) -> bool { + !matches!(r, FeeReason::Export(_)) + } + fn handle_fee(_: MultiAssets) {} +} + pub struct TestConfig; impl Config for TestConfig { type Call = TestCall; - type XcmSender = TestSendXcm; + type XcmSender = TestMessageSender; type AssetTransactor = TestAssetTransactor; type OriginConverter = TestOriginConverter; type IsReserve = TestIsReserve; type IsTeleporter = TestIsTeleporter; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = TestBarrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -295,4 +396,7 @@ impl Config for TestConfig { type SubscriptionService = TestSubscriptionService; type PalletInstancesInfo = TestPalletsInfo; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = TestFeeManager; + type UniversalAliases = TestUniversalAliases; + type MessageExporter = TestMessageExporter; } diff --git a/xcm/xcm-builder/src/origin_conversion.rs b/xcm/xcm-builder/src/origin_conversion.rs index b42c8fcff9ef..e1b15460df40 100644 --- a/xcm/xcm-builder/src/origin_conversion.rs +++ b/xcm/xcm-builder/src/origin_conversion.rs @@ -177,7 +177,7 @@ impl, Origin> ConvertOrigin } pub struct SignedAccountId32AsNative(PhantomData<(Network, Origin)>); -impl, Origin: OriginTrait> ConvertOrigin +impl>, Origin: OriginTrait> ConvertOrigin for SignedAccountId32AsNative where Origin::AccountId: From<[u8; 32]>, @@ -196,15 +196,14 @@ where ( OriginKind::Native, MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { id, network }) }, - ) if matches!(network, NetworkId::Any) || network == Network::get() => - Ok(Origin::signed(id.into())), + ) if matches!(network, None) || network == Network::get() => Ok(Origin::signed(id.into())), (_, origin) => Err(origin), } } } pub struct SignedAccountKey20AsNative(PhantomData<(Network, Origin)>); -impl, Origin: OriginTrait> ConvertOrigin +impl>, Origin: OriginTrait> ConvertOrigin for SignedAccountKey20AsNative where Origin::AccountId: From<[u8; 20]>, @@ -223,8 +222,7 @@ where ( OriginKind::Native, MultiLocation { parents: 0, interior: X1(Junction::AccountKey20 { key, network }) }, - ) if (matches!(network, NetworkId::Any) || network == Network::get()) => - Ok(Origin::signed(key.into())), + ) if (matches!(network, None) || network == Network::get()) => Ok(Origin::signed(key.into())), (_, origin) => Err(origin), } } @@ -265,7 +263,7 @@ where pub struct SignedToAccountId32( PhantomData<(Origin, AccountId, Network)>, ); -impl, Network: Get> +impl, Network: Get>> Convert for SignedToAccountId32 where Origin::PalletsOrigin: From> diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index a3742f656da3..bdca8f02ff99 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -25,7 +25,7 @@ use sp_std::vec::Vec; pub use xcm::latest::prelude::*; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ - traits::{ConvertOrigin, FilterAssetLocation, InvertLocation, OnResponse, TransactAsset}, + traits::{ConvertOrigin, FilterAssetLocation, OnResponse, TransactAsset, UniversalLocation}, Assets, Config, }; diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs index 81513e267511..b9611fad829d 100644 --- a/xcm/xcm-builder/src/tests.rs +++ b/xcm/xcm-builder/src/tests.rs @@ -15,8 +15,7 @@ // along with Polkadot. If not, see . use super::{mock::*, test_utils::*, *}; -use frame_support::{assert_err, weights::constants::WEIGHT_PER_SECOND}; -use xcm::latest::{prelude::*, MaybeErrorCode, PalletInfo, QueryResponseInfo}; +use frame_support::{assert_err, traits::ConstU32, weights::constants::WEIGHT_PER_SECOND}; use xcm_executor::{traits::*, Config, XcmExecutor}; #[test] @@ -27,19 +26,19 @@ fn basic_setup_works() { &Parent.into(), )); - assert_eq!(to_account(X1(Parachain(1)).into()), Ok(1001)); - assert_eq!(to_account(X1(Parachain(50)).into()), Ok(1050)); - assert_eq!(to_account(MultiLocation::new(1, X1(Parachain(1)))), Ok(2001)); - assert_eq!(to_account(MultiLocation::new(1, X1(Parachain(50)))), Ok(2050)); + assert_eq!(to_account(Parachain(1)), Ok(1001)); + assert_eq!(to_account(Parachain(50)), Ok(1050)); + assert_eq!(to_account((Parent, Parachain(1))), Ok(2001)); + assert_eq!(to_account((Parent, Parachain(50))), Ok(2050)); assert_eq!( - to_account(MultiLocation::new(0, X1(AccountIndex64 { index: 1, network: Any }))), + to_account(MultiLocation::new(0, X1(AccountIndex64 { index: 1, network: None }))), Ok(1), ); assert_eq!( - to_account(MultiLocation::new(0, X1(AccountIndex64 { index: 42, network: Any }))), + to_account(MultiLocation::new(0, X1(AccountIndex64 { index: 42, network: None }))), Ok(42), ); - assert_eq!(to_account(Here.into()), Ok(3000)); + assert_eq!(to_account(Here), Ok(3000)); } #[test] @@ -57,15 +56,68 @@ fn take_weight_credit_barrier_should_work() { let mut message = Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); let mut weight_credit = 10; - let r = TakeWeightCredit::should_execute(&Parent.into(), &mut message, 10, &mut weight_credit); + let r = TakeWeightCredit::should_execute( + &Parent.into(), + message.inner_mut(), + 10, + &mut weight_credit, + ); assert_eq!(r, Ok(())); assert_eq!(weight_credit, 0); - let r = TakeWeightCredit::should_execute(&Parent.into(), &mut message, 10, &mut weight_credit); + let r = TakeWeightCredit::should_execute( + &Parent.into(), + message.inner_mut(), + 10, + &mut weight_credit, + ); assert_eq!(r, Err(())); assert_eq!(weight_credit, 0); } +#[test] +fn computed_origin_should_work() { + let mut message = Xcm::<()>(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + DescendOrigin(Parachain(100).into()), + DescendOrigin(PalletInstance(69).into()), + WithdrawAsset((Parent, 100).into()), + BuyExecution { fees: (Parent, 100).into(), weight_limit: Limited(100) }, + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]); + + AllowPaidFrom::set(vec![( + Parent, + Parent, + GlobalConsensus(Kusama), + Parachain(100), + PalletInstance(69), + ) + .into()]); + + let r = AllowTopLevelPaidExecutionFrom::>::should_execute( + &Parent.into(), + message.inner_mut(), + 100, + &mut 0, + ); + assert_eq!(r, Err(())); + + let r = WithComputedOrigin::< + AllowTopLevelPaidExecutionFrom>, + ExecutorUniversalLocation, + ConstU32<2>, + >::should_execute(&Parent.into(), message.inner_mut(), 100, &mut 0); + assert_eq!(r, Err(())); + + let r = WithComputedOrigin::< + AllowTopLevelPaidExecutionFrom>, + ExecutorUniversalLocation, + ConstU32<5>, + >::should_execute(&Parent.into(), message.inner_mut(), 100, &mut 0); + assert_eq!(r, Ok(())); +} + #[test] fn allow_unpaid_should_work() { let mut message = @@ -75,7 +127,7 @@ fn allow_unpaid_should_work() { let r = AllowUnpaidExecutionFrom::>::should_execute( &Parachain(1).into(), - &mut message, + message.inner_mut(), 10, &mut 0, ); @@ -83,7 +135,7 @@ fn allow_unpaid_should_work() { let r = AllowUnpaidExecutionFrom::>::should_execute( &Parent.into(), - &mut message, + message.inner_mut(), 10, &mut 0, ); @@ -99,7 +151,7 @@ fn allow_paid_should_work() { let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parachain(1).into(), - &mut message, + message.inner_mut(), 10, &mut 0, ); @@ -114,7 +166,7 @@ fn allow_paid_should_work() { let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parent.into(), - &mut underpaying_message, + underpaying_message.inner_mut(), 30, &mut 0, ); @@ -129,7 +181,7 @@ fn allow_paid_should_work() { let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parachain(1).into(), - &mut paying_message, + paying_message.inner_mut(), 30, &mut 0, ); @@ -137,7 +189,7 @@ fn allow_paid_should_work() { let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parent.into(), - &mut paying_message, + paying_message.inner_mut(), 30, &mut 0, ); @@ -173,7 +225,7 @@ fn transfer_should_work() { Parachain(1), Xcm(vec![TransferAsset { assets: (Here, 100).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: Any }).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }]), 50, ); @@ -183,6 +235,65 @@ fn transfer_should_work() { assert_eq!(sent_xcm(), vec![]); } +#[test] +fn universal_origin_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into(), X1(Parachain(2)).into()]); + clear_universal_aliases(); + // Parachain 1 may represent Kusama to us + add_universal_alias(Parachain(1), Kusama); + // Parachain 2 may represent Polkadot to us + add_universal_alias(Parachain(2), Polkadot); + + let r = XcmExecutor::::execute_xcm( + Parachain(2), + Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::InvalidLocation)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); + + add_asset(4000, (Parent, 100)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(20)); + assert_eq!(assets(4000), vec![]); +} + +#[test] +fn export_message_should_work() { + // Bridge chain (assumed to be Relay) lets Parachain #1 have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Local parachain #1 issues a transfer asset on Polkadot Relay-chain, transfering 100 Planck to + // Polkadot parachain #2. + let message = + Xcm(vec![TransferAsset { assets: (Here, 100).into(), beneficiary: Parachain(2).into() }]); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExportMessage { network: Polkadot, destination: Here, xcm: message.clone() }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + assert_eq!(exported_xcm(), vec![(Polkadot, 403611790, Here, message)]); +} + #[test] fn basic_asset_trap_should_work() { // we'll let them have message execution for free. @@ -192,12 +303,12 @@ fn basic_asset_trap_should_work() { add_asset(1001, (Here, 1000)); // They want to transfer 100 of them to their sibling parachain #2 but have a problem let r = XcmExecutor::::execute_xcm( - Parachain(1).into(), + Parachain(1), Xcm(vec![ WithdrawAsset((Here, 100).into()), DepositAsset { assets: Wild(AllCounted(0)), // <<< 0 is an error. - beneficiary: AccountIndex64 { index: 3, network: Any }.into(), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), }, ]), 20, @@ -209,12 +320,12 @@ fn basic_asset_trap_should_work() { // Incorrect ticket doesn't work. let old_trapped_assets = TrappedAssets::get(); let r = XcmExecutor::::execute_xcm( - Parachain(1).into(), + Parachain(1), Xcm(vec![ ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(1).into() }, DepositAsset { assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: Any }.into(), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), }, ]), 20, @@ -227,12 +338,12 @@ fn basic_asset_trap_should_work() { // Incorrect origin doesn't work. let old_trapped_assets = TrappedAssets::get(); let r = XcmExecutor::::execute_xcm( - Parachain(2).into(), + Parachain(2), Xcm(vec![ ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, DepositAsset { assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: Any }.into(), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), }, ]), 20, @@ -245,12 +356,12 @@ fn basic_asset_trap_should_work() { // Incorrect assets doesn't work. let old_trapped_assets = TrappedAssets::get(); let r = XcmExecutor::::execute_xcm( - Parachain(1).into(), + Parachain(1), Xcm(vec![ ClaimAsset { assets: (Here, 101).into(), ticket: GeneralIndex(0).into() }, DepositAsset { assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: Any }.into(), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), }, ]), 20, @@ -261,12 +372,12 @@ fn basic_asset_trap_should_work() { assert_eq!(old_trapped_assets, TrappedAssets::get()); let r = XcmExecutor::::execute_xcm( - Parachain(1).into(), + Parachain(1), Xcm(vec![ ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, DepositAsset { assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: Any }.into(), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), }, ]), 20, @@ -277,12 +388,12 @@ fn basic_asset_trap_should_work() { // Same again doesn't work :-) let r = XcmExecutor::::execute_xcm( - Parachain(1).into(), + Parachain(1), Xcm(vec![ ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, DepositAsset { assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: Any }.into(), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), }, ]), 20, @@ -300,42 +411,42 @@ fn errors_should_return_unused_weight() { // First xfer results in an error on the last message only TransferAsset { assets: (Here, 1).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: Any }).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, // Second xfer results in error third message and after TransferAsset { assets: (Here, 2).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: Any }).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, // Third xfer results in error second message and after TransferAsset { assets: (Here, 4).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: Any }).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, ]); // Weight limit of 70 is needed. let limit = ::Weigher::weight(&mut message).unwrap(); assert_eq!(limit, 30); - let r = XcmExecutor::::execute_xcm(Here.into(), message.clone(), limit); + let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); assert_eq!(r, Outcome::Complete(30)); assert_eq!(assets(3), vec![(Here, 7).into()]); assert_eq!(assets(3000), vec![(Here, 4).into()]); assert_eq!(sent_xcm(), vec![]); - let r = XcmExecutor::::execute_xcm(Here.into(), message.clone(), limit); + let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); assert_eq!(r, Outcome::Incomplete(30, XcmError::NotWithdrawable)); assert_eq!(assets(3), vec![(Here, 10).into()]); assert_eq!(assets(3000), vec![(Here, 1).into()]); assert_eq!(sent_xcm(), vec![]); - let r = XcmExecutor::::execute_xcm(Here.into(), message.clone(), limit); + let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); assert_eq!(assets(3), vec![(Here, 11).into()]); assert_eq!(assets(3000), vec![]); assert_eq!(sent_xcm(), vec![]); - let r = XcmExecutor::::execute_xcm(Here.into(), message, limit); + let r = XcmExecutor::::execute_xcm(Here, message, limit); assert_eq!(r, Outcome::Incomplete(10, XcmError::NotWithdrawable)); assert_eq!(assets(3), vec![(Here, 11).into()]); assert_eq!(assets(3000), vec![]); @@ -378,7 +489,7 @@ fn code_registers_should_work() { SetErrorHandler(Xcm(vec![ TransferAsset { assets: (Here, 2).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: Any }).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, // It was handled fine. ClearError, @@ -386,30 +497,30 @@ fn code_registers_should_work() { // Set the appendix - this will always fire. SetAppendix(Xcm(vec![TransferAsset { assets: (Here, 4).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: Any }).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }])), // First xfer always works ok TransferAsset { assets: (Here, 1).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: Any }).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, // Second xfer results in error on the second message - our error handler will fire. TransferAsset { assets: (Here, 8).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: Any }).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, ]); // Weight limit of 70 is needed. let limit = ::Weigher::weight(&mut message).unwrap(); assert_eq!(limit, 70); - let r = XcmExecutor::::execute_xcm(Here.into(), message.clone(), limit); + let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); assert_eq!(r, Outcome::Complete(50)); // We don't pay the 20 weight for the error handler. assert_eq!(assets(3), vec![(Here, 13).into()]); assert_eq!(assets(3000), vec![(Here, 8).into()]); assert_eq!(sent_xcm(), vec![]); - let r = XcmExecutor::::execute_xcm(Here.into(), message, limit); + let r = XcmExecutor::::execute_xcm(Here, message, limit); assert_eq!(r, Outcome::Complete(70)); // We pay the full weight here. assert_eq!(assets(3), vec![(Here, 20).into()]); assert_eq!(assets(3000), vec![(Here, 1).into()]); @@ -422,7 +533,7 @@ fn reserve_transfer_should_work() { // Child parachain #1 owns 1000 tokens held by us in reserve. add_asset(1001, (Here, 1000)); // The remote account owned by gav. - let three: MultiLocation = X1(AccountIndex64 { index: 3, network: Any }).into(); + let three: MultiLocation = X1(AccountIndex64 { index: 3, network: None }).into(); // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 // and let them know to hand it to account #3. @@ -458,7 +569,7 @@ fn reserve_transfer_should_work() { fn simple_version_subscriptions_should_work() { AllowSubsFrom::set(vec![Parent.into()]); - let origin = Parachain(1000).into(); + let origin = Parachain(1000); let message = Xcm::(vec![ SetAppendix(Xcm(vec![])), SubscribeVersion { query_id: 42, max_response_weight: 5000 }, @@ -467,7 +578,7 @@ fn simple_version_subscriptions_should_work() { let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); - let origin = Parachain(1000).into(); + let origin = Parachain(1000); let message = Xcm::(vec![SubscribeVersion { query_id: 42, max_response_weight: 5000 }]); let weight_limit = 10; @@ -482,9 +593,9 @@ fn simple_version_subscriptions_should_work() { #[test] fn version_subscription_instruction_should_work() { - let origin = Parachain(1000).into(); + let origin = Parachain(1000); let message = Xcm::(vec![ - DescendOrigin(X1(AccountIndex64 { index: 1, network: Any })), + DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), SubscribeVersion { query_id: 42, max_response_weight: 5000 }, ]); let weight_limit = 20; @@ -515,13 +626,13 @@ fn version_subscription_instruction_should_work() { fn simple_version_unsubscriptions_should_work() { AllowSubsFrom::set(vec![Parent.into()]); - let origin = Parachain(1000).into(); + let origin = Parachain(1000); let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); let weight_limit = 20; let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); - let origin = Parachain(1000).into(); + let origin = Parachain(1000); let message = Xcm::(vec![UnsubscribeVersion]); let weight_limit = 10; let r = XcmExecutor::::execute_xcm(origin, message.clone(), weight_limit); @@ -536,11 +647,11 @@ fn simple_version_unsubscriptions_should_work() { #[test] fn version_unsubscription_instruction_should_work() { - let origin = Parachain(1000).into(); + let origin = Parachain(1000); // Not allowed to do it when origin has been changed. let message = Xcm::(vec![ - DescendOrigin(X1(AccountIndex64 { index: 1, network: Any })), + DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), UnsubscribeVersion, ]); let weight_limit = 20; @@ -610,7 +721,7 @@ fn transacting_should_refund_weight() { #[test] fn paid_transacting_should_refund_payment_for_unused_weight() { - let one: MultiLocation = X1(AccountIndex64 { index: 1, network: Any }).into(); + let one: MultiLocation = AccountIndex64 { index: 1, network: None }.into(); AllowPaidFrom::set(vec![one.clone()]); add_asset(1, (Parent, 100)); WeightPrice::set((Parent.into(), 1_000_000_000_000)); @@ -646,7 +757,7 @@ fn prepaid_result_of_query_should_get_free_execution() { query_id, response: the_response.clone(), max_weight: 10, - querier: Some(Here.into().into()), + querier: Some(Here.into()), }]); let weight_limit = 10; @@ -666,19 +777,19 @@ fn fungible_multi_asset(location: MultiLocation, amount: u128) -> MultiAsset { #[test] fn weight_trader_tuple_should_work() { - pub const PARA_1: MultiLocation = X1(Parachain(1)).into(); - pub const PARA_2: MultiLocation = X1(Parachain(2)).into(); + let para_1: MultiLocation = Parachain(1).into(); + let para_2: MultiLocation = Parachain(2).into(); parameter_types! { - pub static HereWeightPrice: (AssetId, u128) = (Here.into().into(), WEIGHT_PER_SECOND.into()); - pub static PARA1WeightPrice: (AssetId, u128) = (PARA_1.into(), WEIGHT_PER_SECOND.into()); + pub static HereWeightPrice: (AssetId, u128) = (Here.into(), WEIGHT_PER_SECOND.into()); + pub static Para1WeightPrice: (AssetId, u128) = (Parachain(1).into(), WEIGHT_PER_SECOND.into()); } type Traders = ( // trader one FixedRateOfFungible, // trader two - FixedRateOfFungible, + FixedRateOfFungible, ); let mut traders = Traders::new(); @@ -693,16 +804,16 @@ fn weight_trader_tuple_should_work() { let mut traders = Traders::new(); // trader one failed; trader two buys weight assert_eq!( - traders.buy_weight(5, fungible_multi_asset(PARA_1, 10).into()), - Ok(fungible_multi_asset(PARA_1, 5).into()), + traders.buy_weight(5, fungible_multi_asset(para_1.clone(), 10).into()), + Ok(fungible_multi_asset(para_1.clone(), 5).into()), ); // trader two refunds - assert_eq!(traders.refund_weight(2), Some(fungible_multi_asset(PARA_1, 2))); + assert_eq!(traders.refund_weight(2), Some(fungible_multi_asset(para_1, 2))); let mut traders = Traders::new(); // all traders fails assert_err!( - traders.buy_weight(5, fungible_multi_asset(PARA_2, 10).into()), + traders.buy_weight(5, fungible_multi_asset(para_2, 10).into()), XcmError::TooExpensive, ); // and no refund diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs new file mode 100644 index 000000000000..d88329a4128c --- /dev/null +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -0,0 +1,390 @@ +// Copyright 2021 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 . + +//! Traits and utilities to help with origin mutation and bridging. + +use frame_support::{ensure, traits::Get}; +use parity_scale_codec::{Decode, Encode}; +use sp_std::{convert::TryInto, marker::PhantomData, prelude::*}; +use xcm::prelude::*; +use xcm_executor::traits::{validate_export, ExportXcm}; +use SendError::*; + +fn ensure_is_remote( + universal_local: impl Into, + dest: impl Into, +) -> Result<(NetworkId, InteriorMultiLocation, NetworkId, InteriorMultiLocation), MultiLocation> { + let dest = dest.into(); + let universal_local = universal_local.into(); + let (local_net, local_loc) = match universal_local.clone().split_first() { + (location, Some(GlobalConsensus(network))) => (network, location), + _ => return Err(dest), + }; + let universal_destination: InteriorMultiLocation = universal_local + .into_location() + .appended_with(dest.clone()) + .map_err(|x| x.1)? + .try_into()?; + let (remote_dest, remote_net) = match universal_destination.split_first() { + (d, Some(GlobalConsensus(n))) if n != local_net => (d, n), + _ => return Err(dest), + }; + Ok((remote_net, remote_dest, local_net, local_loc)) +} + +/// Implementation of `SendXcm` which uses the given `ExportXcm` implementation in order to forward +/// the message over a bridge. +/// +/// The actual message forwarded over the bridge is prepended with `UniversalOrigin` and +/// `DescendOrigin` in order to ensure that the message is executed with this Origin. +/// +/// No effort is made to charge for any bridge fees, so this can only be used when it is known +/// that the message sending cannot be abused in any way. +/// +/// This is only useful when the local chain has bridging capabilities. +pub struct LocalUnpaidExporter(PhantomData<(Exporter, Ancestry)>); +impl> SendXcm + for LocalUnpaidExporter +{ + type Ticket = Exporter::Ticket; + + fn validate( + dest: &mut Option, + xcm: &mut Option>, + ) -> SendResult { + let d = dest.take().ok_or(MissingArgument)?; + let devolved = match ensure_is_remote(Ancestry::get(), d) { + Ok(x) => x, + Err(d) => { + *dest = Some(d); + return Err(NotApplicable) + }, + }; + let (network, destination, local_network, local_location) = devolved; + + let inner = xcm.take().ok_or(MissingArgument)?; + let mut message: Xcm<()> = vec![UniversalOrigin(GlobalConsensus(local_network))].into(); + if local_location != Here { + message.inner_mut().push(DescendOrigin(local_location)); + } + message.inner_mut().extend(inner.into_iter()); + validate_export::(network, 0, destination, message) + } + + fn deliver(ticket: Exporter::Ticket) -> Result<(), SendError> { + Exporter::deliver(ticket) + } +} + +pub trait ExporterFor { + /// Return the locally-routable bridge (if any) capable of forwarding `message` to the + /// `remote_location` on the remote `network`, together with the payment which is required. + /// + /// The payment is specified from the local context, not the bridge chain. This is the + /// total amount to withdraw in to Holding and should cover both payment for the execution on + /// the bridge chain as well as payment for the use of the `ExportMessage` instruction. + fn exporter_for( + network: &NetworkId, + remote_location: &InteriorMultiLocation, + message: &Xcm<()>, + ) -> Option<(MultiLocation, Option)>; +} + +#[impl_trait_for_tuples::impl_for_tuples(30)] +impl ExporterFor for Tuple { + fn exporter_for( + network: &NetworkId, + remote_location: &InteriorMultiLocation, + message: &Xcm<()>, + ) -> Option<(MultiLocation, Option)> { + for_tuples!( #( + if let Some(r) = Tuple::exporter_for(network, remote_location, message) { + return Some(r); + } + )* ); + None + } +} + +pub struct NetworkExportTable(sp_std::marker::PhantomData); +impl)>>> ExporterFor + for NetworkExportTable +{ + fn exporter_for( + network: &NetworkId, + _: &InteriorMultiLocation, + _: &Xcm<()>, + ) -> Option<(MultiLocation, Option)> { + T::get().into_iter().find(|(ref j, ..)| j == network).map(|(_, l, p)| (l, p)) + } +} + +/// Implementation of `SendXcm` which wraps the message inside an `ExportMessage` instruction +/// and sends it to a destination known to be able to handle it. +/// +/// The actual message send to the bridge for forwarding is prepended with `UniversalOrigin` +/// and `DescendOrigin` in order to ensure that the message is executed with our Origin. +/// +/// No effort is made to make payment to the bridge for its services, so the bridge location +/// must have been configured with a barrier rule allowing unpaid execution for this message +/// coming from our origin. +/// +/// This is only useful if we have special dispensation by the remote bridges to have the +/// `ExportMessage` instruction executed without payment. +pub struct UnpaidRemoteExporter( + PhantomData<(Bridges, Router, Ancestry)>, +); +impl> SendXcm + for UnpaidRemoteExporter +{ + type Ticket = Router::Ticket; + + fn validate( + dest: &mut Option, + xcm: &mut Option>, + ) -> SendResult { + let d = dest.as_ref().ok_or(MissingArgument)?.clone(); + let devolved = ensure_is_remote(Ancestry::get(), d).map_err(|_| NotApplicable)?; + let (remote_network, remote_location, local_network, local_location) = devolved; + + // Prepend the desired message with instructions which effectively rewrite the origin. + // + // This only works because the remote chain empowers the bridge + // to speak for the local network. + let mut exported: Xcm<()> = vec![UniversalOrigin(GlobalConsensus(local_network))].into(); + if local_location != Here { + exported.inner_mut().push(DescendOrigin(local_location)); + } + exported.inner_mut().extend(xcm.take().ok_or(MissingArgument)?.into_iter()); + + let (bridge, maybe_payment) = + Bridges::exporter_for(&remote_network, &remote_location, &exported) + .ok_or(NotApplicable)?; + ensure!(maybe_payment.is_none(), Unroutable); + + // We then send a normal message to the bridge asking it to export the prepended + // message to the remote chain. This will only work if the bridge will do the message + // export for free. Common-good chains will typically be afforded this. + let message = Xcm(vec![ExportMessage { + network: remote_network, + destination: remote_location, + xcm: exported, + }]); + let (v, mut cost) = validate_send::(bridge, message)?; + if let Some(payment) = maybe_payment { + cost.push(payment); + } + Ok((v, cost)) + } + + fn deliver(validation: Router::Ticket) -> Result<(), SendError> { + Router::deliver(validation) + } +} + +/// Implementation of `SendXcm` which wraps the message inside an `ExportMessage` instruction +/// and sends it to a destination known to be able to handle it. +/// +/// The actual message send to the bridge for forwarding is prepended with `UniversalOrigin` +/// and `DescendOrigin` in order to ensure that the message is executed with this Origin. +/// +/// The `ExportMessage` instruction on the bridge is paid for from the local chain's sovereign +/// account on the bridge. The amount paid is determined through the `ExporterFor` trait. +pub struct SovereignPaidRemoteExporter( + PhantomData<(Bridges, Router, Ancestry)>, +); +impl> SendXcm + for SovereignPaidRemoteExporter +{ + type Ticket = Router::Ticket; + + fn validate( + dest: &mut Option, + xcm: &mut Option>, + ) -> SendResult { + let d = dest.as_ref().ok_or(MissingArgument)?.clone(); + let devolved = ensure_is_remote(Ancestry::get(), d).map_err(|_| NotApplicable)?; + let (remote_network, remote_location, local_network, local_location) = devolved; + + // Prepend the desired message with instructions which effectively rewrite the origin. + // + // This only works because the remote chain empowers the bridge + // to speak for the local network. + let mut exported: Xcm<()> = vec![UniversalOrigin(GlobalConsensus(local_network))].into(); + if local_location != Here { + exported.inner_mut().push(DescendOrigin(local_location)); + } + exported.inner_mut().extend(xcm.take().ok_or(MissingArgument)?.into_iter()); + + let (bridge, maybe_payment) = + Bridges::exporter_for(&remote_network, &remote_location, &exported) + .ok_or(NotApplicable)?; + + let local_from_bridge = + MultiLocation::from(Ancestry::get()).inverted(&bridge).map_err(|_| Unroutable)?; + let export_instruction = + ExportMessage { network: remote_network, destination: remote_location, xcm: exported }; + + let message = Xcm(if let Some(ref payment) = maybe_payment { + let fees = payment + .clone() + .reanchored(&bridge, &Ancestry::get().into()) + .map_err(|_| Unroutable)?; + vec![ + WithdrawAsset(fees.clone().into()), + BuyExecution { fees, weight_limit: Unlimited }, + export_instruction, + RefundSurplus, + DepositAsset { assets: All.into(), beneficiary: local_from_bridge }, + ] + } else { + vec![export_instruction] + }); + + // We then send a normal message to the bridge asking it to export the prepended + // message to the remote chain. This will only work if the bridge will do the message + // export for free. Common-good chains will typically be afforded this. + let (v, mut cost) = validate_send::(bridge, message)?; + if let Some(bridge_payment) = maybe_payment { + cost.push(bridge_payment); + } + Ok((v, cost)) + } + + fn deliver(ticket: Router::Ticket) -> Result<(), SendError> { + Router::deliver(ticket) + } +} + +pub trait DispatchBlob { + /// Dispatches an incoming blob and returns the unexpectable weight consumed by the dispatch. + fn dispatch_blob(blob: Vec) -> Result<(), DispatchBlobError>; +} + +pub trait HaulBlob { + /// Sends a blob over some point-to-point link. This will generally be implemented by a bridge. + fn haul_blob(blob: Vec); +} + +#[derive(Clone, Encode, Decode)] +pub struct BridgeMessage { + /// The message destination as a *Universal Location*. This means it begins with a + /// `GlobalConsensus` junction describing the network under which global consensus happens. + /// If this does not match our global consensus then it's a fatal error. + universal_dest: VersionedInteriorMultiLocation, + message: VersionedXcm<()>, +} + +pub enum DispatchBlobError { + Unbridgable, + InvalidEncoding, + UnsupportedLocationVersion, + UnsupportedXcmVersion, + RoutingError, + NonUniversalDestination, + WrongGlobal, +} + +pub struct BridgeBlobDispatcher(PhantomData<(Router, OurPlace)>); +impl> DispatchBlob + for BridgeBlobDispatcher +{ + fn dispatch_blob(blob: Vec) -> Result<(), DispatchBlobError> { + let our_universal = OurPlace::get(); + let our_global = + our_universal.global_consensus().map_err(|()| DispatchBlobError::Unbridgable)?; + let BridgeMessage { universal_dest, message } = + Decode::decode(&mut &blob[..]).map_err(|_| DispatchBlobError::InvalidEncoding)?; + let universal_dest: InteriorMultiLocation = universal_dest + .try_into() + .map_err(|_| DispatchBlobError::UnsupportedLocationVersion)?; + // `universal_dest` is the desired destination within the universe: first we need to check + // we're in the right global consensus. + let intended_global = universal_dest + .global_consensus() + .map_err(|()| DispatchBlobError::NonUniversalDestination)?; + ensure!(intended_global == our_global, DispatchBlobError::WrongGlobal); + let dest = universal_dest.relative_to(&our_universal); + let message: Xcm<()> = + message.try_into().map_err(|_| DispatchBlobError::UnsupportedXcmVersion)?; + send_xcm::(dest, message).map_err(|_| DispatchBlobError::RoutingError)?; + Ok(()) + } +} + +pub struct HaulBlobExporter( + PhantomData<(Bridge, BridgedNetwork, Price)>, +); +impl, Price: Get> ExportXcm + for HaulBlobExporter +{ + type Ticket = Vec; + + fn validate( + network: NetworkId, + _channel: u32, + destination: &mut Option, + message: &mut Option>, + ) -> Result<(Vec, MultiAssets), SendError> { + let bridged_network = BridgedNetwork::get(); + ensure!(&network == &bridged_network, SendError::NotApplicable); + // We don't/can't use the `channel` for this adapter. + let dest = destination.take().ok_or(SendError::MissingArgument)?; + let universal_dest = match dest.pushed_front_with(GlobalConsensus(bridged_network)) { + Ok(d) => d.into(), + Err((dest, _)) => { + *destination = Some(dest); + return Err(SendError::NotApplicable) + }, + }; + let message = VersionedXcm::from(message.take().ok_or(SendError::MissingArgument)?); + let blob = BridgeMessage { universal_dest, message }.encode(); + Ok((blob, Price::get())) + } + + fn deliver(blob: Vec) -> Result<(), SendError> { + Bridge::haul_blob(blob); + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn ensure_is_remote_works() { + // A Kusama parachain is remote from the Polkadot Relay. + let x = ensure_is_remote(Polkadot, (Parent, Kusama, Parachain(1000))); + assert_eq!(x, Ok((Kusama, Parachain(1000).into(), Polkadot, Here))); + + // Polkadot Relay is remote from a Kusama parachain. + let x = ensure_is_remote((Kusama, Parachain(1000)), (Parent, Parent, Polkadot)); + assert_eq!(x, Ok((Polkadot, Here, Kusama, Parachain(1000).into()))); + + // Our own parachain is local. + let x = ensure_is_remote(Polkadot, Parachain(1000)); + assert_eq!(x, Err(Parachain(1000).into())); + + // Polkadot's parachain is not remote if we are Polkadot. + let x = ensure_is_remote(Polkadot, (Parent, Polkadot, Parachain(1000))); + assert_eq!(x, Err((Parent, Polkadot, Parachain(1000)).into())); + + // If we don't have a consensus ancestor, then we cannot determine remoteness. + let x = ensure_is_remote((), (Parent, Polkadot, Parachain(1000))); + assert_eq!(x, Err((Parent, Polkadot, Parachain(1000)).into())); + } +} diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index d2b2152aedb7..b749f070a147 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -47,8 +47,16 @@ pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm)> { } pub struct TestSendXcm; impl SendXcm for TestSendXcm { - fn send_xcm(dest: impl Into, msg: opaque::Xcm) -> SendResult { - SENT_XCM.with(|q| q.borrow_mut().push((dest.into(), msg))); + type Ticket = (MultiLocation, Xcm<()>); + fn validate( + dest: &mut Option, + msg: &mut Option>, + ) -> SendResult<(MultiLocation, Xcm<()>)> { + let pair = (dest.take().unwrap(), msg.take().unwrap()); + Ok((pair, MultiAssets::new())) + } + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { + SENT_XCM.with(|q| q.borrow_mut().push(pair)); Ok(()) } } @@ -116,7 +124,7 @@ impl configuration::Config for Runtime { parameter_types! { pub const KsmLocation: MultiLocation = MultiLocation::here(); pub const KusamaNetwork: NetworkId = NetworkId::Kusama; - pub Ancestry: MultiLocation = Here.into(); + pub Ancestry: InteriorMultiLocation = Here; pub CheckAccount: AccountId = XcmPallet::check_account(); } @@ -151,8 +159,8 @@ pub type Barrier = ( ); parameter_types! { - pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = - (MultiAssetFilter::Wild(WildMultiAsset::AllOf { id: Concrete(MultiLocation::here()), fun: WildFungible }), X1(Parachain(1000)).into()); + pub KusamaForStatemine: (MultiAssetFilter, MultiLocation) = + (Wild(AllOf { id: Concrete(Here.into()), fun: WildFungible }), Parachain(1000).into()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 4; } @@ -176,6 +184,9 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index e3c0469df55c..6932c006546a 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -47,7 +47,7 @@ fn withdraw_and_deposit_works() { let amount = REGISTER_AMOUNT; let weight = 3 * BaseXcmWeight::get(); let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID).into(), + Parachain(PARA_ID), Xcm(vec![ WithdrawAsset((Here, amount).into()), buy_execution(), @@ -88,7 +88,7 @@ fn report_holding_works() { max_weight: 1_000_000_000, }; let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID).into(), + Parachain(PARA_ID), Xcm(vec![ WithdrawAsset((Here, amount).into()), buy_execution(), @@ -114,7 +114,7 @@ fn report_holding_works() { // now do a successful transfer let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID).into(), + Parachain(PARA_ID), Xcm(vec![ WithdrawAsset((Here, amount).into()), buy_execution(), @@ -142,7 +142,7 @@ fn report_holding_works() { query_id: response_info.query_id, response: Response::Assets(vec![].into()), max_weight: response_info.max_weight, - querier: Some(Here.into().into()), + querier: Some(Here.into()), }]), )] ); @@ -170,14 +170,14 @@ fn teleport_to_statemine_works() { buy_execution(), // unchecked mock value DepositAsset { assets: AllCounted(1).into(), - beneficiary: (1, Parachain(PARA_ID)).into(), + beneficiary: (Parent, Parachain(PARA_ID)).into(), }, ]; let weight = 3 * BaseXcmWeight::get(); // teleports are allowed to community chains, even in the absence of trust from their side. let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID).into(), + Parachain(PARA_ID), Xcm(vec![ WithdrawAsset((Here, amount).into()), buy_execution(), @@ -203,7 +203,7 @@ fn teleport_to_statemine_works() { // teleports are allowed from statemine to kusama. let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID).into(), + Parachain(PARA_ID), Xcm(vec![ WithdrawAsset((Here, amount).into()), buy_execution(), @@ -258,12 +258,12 @@ fn reserve_based_transfer_works() { buy_execution(), // unchecked mock value DepositAsset { assets: AllCounted(1).into(), - beneficiary: (1, Parachain(PARA_ID)).into(), + beneficiary: (Parent, Parachain(PARA_ID)).into(), }, ]; let weight = 3 * BaseXcmWeight::get(); let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID).into(), + Parachain(PARA_ID), Xcm(vec![ WithdrawAsset((Here, amount).into()), buy_execution(), diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index 9c11c9c2485c..7b5d6f4a5855 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -210,20 +210,20 @@ impl Assets { } /// Mutate the assets to be interpreted as the same assets from the perspective of a `target` - /// chain. The local chain's `ancestry` is provided. + /// chain. The local chain's `context` is provided. /// /// Any assets which were unable to be reanchored are introduced into `failed_bin`. pub fn reanchor( &mut self, target: &MultiLocation, - ancestry: &MultiLocation, + context: &MultiLocation, mut maybe_failed_bin: Option<&mut Self>, ) { let mut fungible = Default::default(); mem::swap(&mut self.fungible, &mut fungible); self.fungible = fungible .into_iter() - .filter_map(|(mut id, amount)| match id.reanchor(target, ancestry) { + .filter_map(|(mut id, amount)| match id.reanchor(target, context) { Ok(()) => Some((id, amount)), Err(()) => { maybe_failed_bin.as_mut().map(|f| f.fungible.insert(id, amount)); @@ -235,7 +235,7 @@ impl Assets { mem::swap(&mut self.non_fungible, &mut non_fungible); self.non_fungible = non_fungible .into_iter() - .filter_map(|(mut class, inst)| match class.reanchor(target, ancestry) { + .filter_map(|(mut class, inst)| match class.reanchor(target, context) { Ok(()) => Some((class, inst)), Err(()) => { maybe_failed_bin.as_mut().map(|f| f.non_fungible.insert((class, inst))); diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index aff5a129d633..83f7bbb49312 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -15,15 +15,16 @@ // along with Polkadot. If not, see . use crate::traits::{ - ClaimAssets, ConvertOrigin, DropAssets, FilterAssetLocation, InvertLocation, OnResponse, - ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, + ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, FilterAssetLocation, OnResponse, + ShouldExecute, TransactAsset, UniversalLocation, VersionChangeNotifier, WeightBounds, + WeightTrader, }; use frame_support::{ dispatch::{Dispatchable, Parameter}, - traits::{Get, PalletsInfoAccess}, + traits::{Contains, Get, PalletsInfoAccess}, weights::{GetDispatchInfo, PostDispatchInfo}, }; -use xcm::latest::SendXcm; +use xcm::latest::{Junction, MultiLocation, SendXcm}; /// The trait to parameterize the `XcmExecutor`. pub trait Config { @@ -46,7 +47,7 @@ pub trait Config { type IsTeleporter: FilterAssetLocation; /// Means of inverting a location. - type LocationInverter: InvertLocation; + type LocationInverter: UniversalLocation; /// Whether we should execute the given XCM at all. type Barrier: ShouldExecute; @@ -78,4 +79,14 @@ pub trait Config { /// NOTE: In the worse case, the Holding Register may contain up to twice as many assets as this /// and any benchmarks should take that into account. type MaxAssetsIntoHolding: Get; + + /// Configure the fees. + type FeeManager: FeeManager; + + /// The method of exporting a message. + type MessageExporter: ExportXcm; + + /// The origin locations and specific universal junctions to which they are allowed to elevate + /// themselves. + type UniversalAliases: Contains<(MultiLocation, Junction)>; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index af5d585750ce..3276fdb1e841 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -19,23 +19,20 @@ use frame_support::{ dispatch::{Dispatchable, Weight}, ensure, - traits::{Get, PalletsInfoAccess}, + traits::{Contains, Get, PalletsInfoAccess}, weights::GetDispatchInfo, }; -use parity_scale_codec::Encode; +use parity_scale_codec::{Decode, Encode}; +use sp_io::hashing::blake2_128; use sp_runtime::traits::Saturating; use sp_std::{marker::PhantomData, prelude::*}; -use xcm::latest::{ - Error as XcmError, ExecuteXcm, - Instruction::{self, *}, - MaybeErrorCode, MultiAsset, MultiAssets, MultiLocation, Outcome, PalletInfo, QueryResponseInfo, - Response, SendXcm, Xcm, -}; +use xcm::latest::prelude::*; pub mod traits; use traits::{ - ClaimAssets, ConvertOrigin, DropAssets, FilterAssetLocation, InvertLocation, OnResponse, - ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, + validate_export, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, FeeReason, + FilterAssetLocation, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, + VersionChangeNotifier, WeightBounds, WeightTrader, }; mod assets; @@ -67,60 +64,46 @@ pub struct XcmExecutor { _config: PhantomData, } +pub struct WeighedMessage(Weight, Xcm); +impl PreparedMessage for WeighedMessage { + fn weight_of(&self) -> Weight { + self.0 + } +} + impl ExecuteXcm for XcmExecutor { - fn execute_xcm_in_credit( + type Prepared = WeighedMessage; + fn prepare(mut message: Xcm) -> Result> { + match Config::Weigher::weight(&mut message) { + Ok(weight) => Ok(WeighedMessage(weight, message)), + Err(_) => Err(message), + } + } + fn execute( origin: impl Into, - mut message: Xcm, - weight_limit: Weight, + WeighedMessage(xcm_weight, mut message): WeighedMessage, mut weight_credit: Weight, ) -> Outcome { let origin = origin.into(); log::trace!( target: "xcm::execute_xcm_in_credit", - "origin: {:?}, message: {:?}, weight_limit: {:?}, weight_credit: {:?}", + "origin: {:?}, message: {:?}, weight_credit: {:?}", origin, message, - weight_limit, weight_credit, ); - let xcm_weight = match Config::Weigher::weight(&mut message) { - Ok(x) => x, - Err(()) => { - log::debug!( - target: "xcm::execute_xcm_in_credit", - "Weight not computable! (origin: {:?}, message: {:?}, weight_limit: {:?}, weight_credit: {:?})", - origin, - message, - weight_limit, - weight_credit, - ); - return Outcome::Error(XcmError::WeightNotComputable) - }, - }; - if xcm_weight > weight_limit { + if let Err(e) = Config::Barrier::should_execute( + &origin, + message.inner_mut(), + xcm_weight, + &mut weight_credit, + ) { log::debug!( target: "xcm::execute_xcm_in_credit", - "Weight limit reached! weight > weight_limit: {:?} > {:?}. (origin: {:?}, message: {:?}, weight_limit: {:?}, weight_credit: {:?})", - xcm_weight, - weight_limit, - origin, - message, - weight_limit, - weight_credit, - ); - return Outcome::Error(XcmError::WeightLimitReached(xcm_weight)) - } - - if let Err(e) = - Config::Barrier::should_execute(&origin, &mut message, xcm_weight, &mut weight_credit) - { - log::debug!( - target: "xcm::execute_xcm_in_credit", - "Barrier blocked execution! Error: {:?}. (origin: {:?}, message: {:?}, weight_limit: {:?}, weight_credit: {:?})", + "Barrier blocked execution! Error: {:?}. (origin: {:?}, message: {:?}, weight_credit: {:?})", e, origin, message, - weight_limit, weight_credit, ); return Outcome::Error(XcmError::Barrier) @@ -240,6 +223,22 @@ impl XcmExecutor { } } + /// Send an XCM, charging fees from Holding as needed. + fn send( + &mut self, + dest: MultiLocation, + msg: Xcm<()>, + reason: FeeReason, + ) -> Result<(), XcmError> { + let (ticket, fee) = validate_send::(dest, msg)?; + if !Config::FeeManager::is_waived(&self.origin, reason) { + let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; + Config::FeeManager::handle_fee(paid.into()); + } + Config::XcmSender::deliver(ticket)?; + Ok(()) + } + /// Remove the registered error handler and return it. Do not refund its weight. fn take_error_handler(&mut self) -> Xcm { let mut r = Xcm::(vec![]); @@ -332,11 +331,12 @@ impl XcmExecutor { for asset in assets.inner() { Config::AssetTransactor::beam_asset(asset, origin, &dest)?; } - let ancestry = Config::LocationInverter::ancestry(); - assets.reanchor(&dest, &ancestry).map_err(|()| XcmError::MultiLocationFull)?; + let context = Config::LocationInverter::universal_location().into(); + assets.reanchor(&dest, &context).map_err(|()| XcmError::MultiLocationFull)?; let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); - Config::XcmSender::send_xcm(dest, Xcm(message)).map_err(Into::into) + self.send(dest, Xcm(message), FeeReason::TransferReserveAsset)?; + Ok(()) }, ReceiveTeleportedAsset(assets) => { let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); @@ -416,10 +416,11 @@ impl XcmExecutor { ReportError(response_info) => { // Report the given result by sending a QueryResponse XCM to a previously given outcome // destination if one was registered. - Self::respond( + self.respond( self.origin.clone(), Response::ExecutionResult(self.error), response_info, + FeeReason::Report, ) }, DepositAsset { assets, beneficiary } => { @@ -439,7 +440,8 @@ impl XcmExecutor { let assets = Self::reanchored(deposited, &dest, None); let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); - Config::XcmSender::send_xcm(dest, Xcm(message)).map_err(Into::into) + self.send(dest, Xcm(message), FeeReason::DepositReserveAsset)?; + Ok(()) }, InitiateReserveWithdraw { assets, reserve, xcm } => { // Note that here we are able to place any assets which could not be reanchored @@ -451,7 +453,8 @@ impl XcmExecutor { ); let mut message = vec![WithdrawAsset(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); - Config::XcmSender::send_xcm(reserve, Xcm(message)).map_err(Into::into) + self.send(reserve, Xcm(message), FeeReason::InitiateReserveWithdraw)?; + Ok(()) }, InitiateTeleport { assets, dest, xcm } => { // We must do this first in order to resolve wildcards. @@ -464,14 +467,20 @@ impl XcmExecutor { let assets = Self::reanchored(assets, &dest, None); let mut message = vec![ReceiveTeleportedAsset(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); - Config::XcmSender::send_xcm(dest, Xcm(message)).map_err(Into::into) + self.send(dest, Xcm(message), FeeReason::InitiateTeleport)?; + Ok(()) }, ReportHolding { response_info, assets } => { // Note that we pass `None` as `maybe_failed_bin` since no assets were ever removed // from Holding. let assets = Self::reanchored(self.holding.min(&assets), &response_info.destination, None); - Self::respond(self.origin.clone(), Response::Assets(assets), response_info) + self.respond( + self.origin.clone(), + Response::Assets(assets), + response_info, + FeeReason::Report, + ) }, BuyExecution { fees, weight_limit } => { // There is no need to buy any weight is `weight_limit` is `Unlimited` since it @@ -562,7 +571,8 @@ impl XcmExecutor { let querier = Self::to_querier(self.origin.clone(), &destination)?; let instruction = QueryResponse { query_id, response, max_weight, querier }; let message = Xcm(vec![instruction]); - Config::XcmSender::send_xcm(destination, message).map_err(Into::into) + self.send(destination, message, FeeReason::QueryPallet)?; + Ok(()) }, ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => { let pallet = Config::PalletInstancesInfo::infos() @@ -577,15 +587,44 @@ impl XcmExecutor { ensure!(minor >= min_crate_minor, XcmError::VersionIncompatible); Ok(()) }, - ReportTransactStatus(response_info) => Self::respond( + ReportTransactStatus(response_info) => self.respond( self.origin.clone(), Response::DispatchResult(self.transact_status.clone()), response_info, + FeeReason::Report, ), ClearTransactStatus => { self.transact_status = Default::default(); Ok(()) }, + UniversalOrigin(new_global) => { + let universal_location = Config::LocationInverter::universal_location(); + ensure!(universal_location.first() != Some(&new_global), XcmError::InvalidLocation); + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin_xform = (origin, new_global); + let ok = Config::UniversalAliases::contains(&origin_xform); + ensure!(ok, XcmError::InvalidLocation); + let (_, new_global) = origin_xform; + let new_origin = X1(new_global).relative_to(&universal_location); + self.origin = Some(new_origin); + Ok(()) + }, + ExportMessage { network, destination, xcm } => { + let hash = (&self.origin, &destination).using_encoded(blake2_128); + let channel = u32::decode(&mut hash.as_ref()).unwrap_or(0); + // Hash identifies the lane on the exporter which we use. We use the pairwise + // combination of the origin and destination to ensure origin/destination pairs will + // generally have their own lanes. + let (ticket, fee) = + validate_export::(network, channel, destination, xcm)?; + if !Config::FeeManager::is_waived(&self.origin, FeeReason::Export(network)) { + let paid = + self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; + Config::FeeManager::handle_fee(paid.into()); + } + Config::MessageExporter::deliver(ticket)?; + Ok(()) + }, ExchangeAsset { .. } => Err(XcmError::Unimplemented), HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), @@ -601,7 +640,7 @@ impl XcmExecutor { Ok(match local_querier { None => None, Some(q) => Some( - q.reanchored(&destination, &Config::LocationInverter::ancestry()) + q.reanchored(&destination, &Config::LocationInverter::universal_location().into()) .map_err(|_| XcmError::ReanchorFailed)?, ), }) @@ -611,15 +650,23 @@ impl XcmExecutor { /// /// The `local_querier` argument is the querier (if any) specified from the *local* perspective. fn respond( + &mut self, local_querier: Option, response: Response, info: QueryResponseInfo, + fee_reason: FeeReason, ) -> Result<(), XcmError> { let querier = Self::to_querier(local_querier, &info.destination)?; let QueryResponseInfo { destination, query_id, max_weight } = info; let instruction = QueryResponse { query_id, response, max_weight, querier }; let message = Xcm(vec![instruction]); - Config::XcmSender::send_xcm(destination, message).map_err(Into::into) + let (ticket, fee) = validate_send::(destination, message)?; + if !Config::FeeManager::is_waived(&self.origin, fee_reason) { + let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; + Config::FeeManager::handle_fee(paid.into()); + } + Config::XcmSender::deliver(ticket)?; + Ok(()) } /// NOTE: Any assets which were unable to be reanchored are introduced into `failed_bin`. @@ -628,7 +675,8 @@ impl XcmExecutor { dest: &MultiLocation, maybe_failed_bin: Option<&mut Assets>, ) -> MultiAssets { - assets.reanchor(dest, &Config::LocationInverter::ancestry(), maybe_failed_bin); + let context = Config::LocationInverter::universal_location().into(); + assets.reanchor(dest, &context, maybe_failed_bin); assets.into_assets_iter().collect::>().into() } } diff --git a/xcm/xcm-executor/src/traits/conversion.rs b/xcm/xcm-executor/src/traits/conversion.rs index d8c50037662d..b14aedc37b64 100644 --- a/xcm/xcm-executor/src/traits/conversion.rs +++ b/xcm/xcm-executor/src/traits/conversion.rs @@ -16,7 +16,7 @@ use parity_scale_codec::{Decode, Encode}; use sp_std::{borrow::Borrow, convert::TryFrom, prelude::*, result::Result}; -use xcm::latest::{MultiLocation, OriginKind}; +use xcm::latest::prelude::*; /// Generic third-party conversion trait. Use this when you don't want to force the user to use default /// implementations of `From` and `Into` for the types you wish to convert between. @@ -204,9 +204,25 @@ impl ConvertOrigin for Tuple { } } -/// Means of inverting a location: given a location which describes a `target` interpreted from the -/// `source`, this will provide the corresponding location which describes the `source`. -pub trait InvertLocation { - fn ancestry() -> MultiLocation; - fn invert_location(l: &MultiLocation) -> Result; +/// Means of wotking with a relative location. +pub trait UniversalLocation { + /// Return the location of the local consensus system from the point of view of the location + /// `l`. + /// + /// Given a target `location`, the result provides the location which represents the local + /// consensus system from the targets perspective. + fn invert_location(location: &MultiLocation) -> Result { + let mut context = Self::universal_location(); + let mut junctions = Here; + for _ in 0..location.parent_count() { + junctions = junctions + .pushed_with(context.take_first().unwrap_or(OnlyChild)) + .map_err(|_| ())?; + } + let parents = location.interior().len() as u8; + Ok(MultiLocation::new(parents, junctions)) + } + + /// Return the location of the local consensus system within the known Universe. + fn universal_location() -> InteriorMultiLocation; } diff --git a/xcm/xcm-executor/src/traits/export.rs b/xcm/xcm-executor/src/traits/export.rs new file mode 100644 index 000000000000..65823b8b3c14 --- /dev/null +++ b/xcm/xcm-executor/src/traits/export.rs @@ -0,0 +1,117 @@ +// Copyright 2020 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 . + +use xcm::latest::prelude::*; + +pub trait ExportXcm { + type Ticket; + + /// Check whether the given `_message` is deliverable to the given `_destination` and if so + /// determine the cost which will be paid by this chain to do so, returning a `Validated` token + /// which can be used to enact delivery. + /// + /// The `destination` and `message` must be `Some` (or else an error will be returned) and they + /// may only be consumed if the `Err` is not `NotApplicable`. + /// + /// If it is not a destination which can be reached with this type but possibly could by others, + /// then this *MUST* return `NotApplicable`. Any other error will cause the tuple + /// implementation to exit early without trying other type fields. + fn validate( + network: NetworkId, + channel: u32, + destination: &mut Option, + message: &mut Option>, + ) -> SendResult; + + /// Actually carry out the delivery operation for a previously validated message sending. + /// + /// The implementation should do everything possible to ensure that this function is infallible + /// if called immediately after `validate`. Returning an error here would result in a price + /// paid without the service being delivered. + fn deliver(ticket: Self::Ticket) -> Result<(), SendError>; +} + +#[impl_trait_for_tuples::impl_for_tuples(30)] +impl ExportXcm for Tuple { + for_tuples! { type Ticket = (#( Option ),* ); } + + fn validate( + network: NetworkId, + channel: u32, + destination: &mut Option, + message: &mut Option>, + ) -> SendResult { + let mut maybe_cost: Option = None; + let one_ticket: Self::Ticket = (for_tuples! { #( + if maybe_cost.is_some() { + None + } else { + match Tuple::validate(network, channel, destination, message) { + Err(SendError::NotApplicable) => None, + Err(e) => { return Err(e) }, + Ok((v, c)) => { + maybe_cost = Some(c); + Some(v) + }, + } + } + ),* }); + if let Some(cost) = maybe_cost { + Ok((one_ticket, cost)) + } else { + Err(SendError::NotApplicable) + } + } + + fn deliver(one_ticket: Self::Ticket) -> Result<(), SendError> { + for_tuples!( #( + if let Some(validated) = one_ticket.Tuple.take() { + return Tuple::deliver(validated); + } + )* ); + Err(SendError::Unroutable) + } +} + +/// Convenience function for using a `SendXcm` implementation. Just interprets the `dest` and wraps +/// both in `Some` before passing them as as mutable references into `T::send_xcm`. +pub fn validate_export( + network: NetworkId, + channel: u32, + dest: InteriorMultiLocation, + msg: Xcm<()>, +) -> SendResult { + T::validate(network, channel, &mut Some(dest), &mut Some(msg)) +} + +/// Convenience function for using a `SendXcm` implementation. Just interprets the `dest` and wraps +/// both in `Some` before passing them as as mutable references into `T::send_xcm`. +/// +/// Returns either `Ok` with the price of the delivery, or `Err` with the reason why the message +/// could not be sent. +/// +/// Generally you'll want to validate and get the price first to ensure that the sender can pay it +/// before actually doing the delivery. +pub fn export_xcm( + network: NetworkId, + channel: u32, + dest: InteriorMultiLocation, + msg: Xcm<()>, +) -> Result { + let (ticket, price) = T::validate(network, channel, &mut Some(dest), &mut Some(msg))?; + T::deliver(ticket)?; + Ok(price) +} diff --git a/xcm/xcm-executor/src/traits/fee_manager.rs b/xcm/xcm-executor/src/traits/fee_manager.rs new file mode 100644 index 000000000000..583f2242188b --- /dev/null +++ b/xcm/xcm-executor/src/traits/fee_manager.rs @@ -0,0 +1,52 @@ +// Copyright 2022 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 . + +use xcm::prelude::*; + +/// Handle stuff to do with taking fees in certain XCM instructions. +pub trait FeeManager { + /// Determine if a fee which would normally payable should be waived. + fn is_waived(origin: &Option, r: FeeReason) -> bool; + + /// Do something with the fee which has been paid. Doing nothing here silently burns the + /// fees. + fn handle_fee(fee: MultiAssets); +} + +/// Context under which a fee is paid. +pub enum FeeReason { + /// When a reporting instruction is called. + Report, + /// When the `TransferReserveAsset` instruction is called. + TransferReserveAsset, + /// When the `DepositReserveAsset` instruction is called. + DepositReserveAsset, + /// When the `InitiateReserveWithdraw` instruction is called. + InitiateReserveWithdraw, + /// When the `InitiateTeleport` instruction is called. + InitiateTeleport, + /// When the `QueryPallet` instruction is called. + QueryPallet, + /// When the `ExportMessage` instruction is called (and includes the network ID). + Export(NetworkId), +} + +impl FeeManager for () { + fn is_waived(_: &Option, _: FeeReason) -> bool { + true + } + fn handle_fee(_: MultiAssets) {} +} diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index 1312771e719b..a08dc9b9a3f0 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -17,9 +17,15 @@ //! Various traits used in configuring the executor. mod conversion; -pub use conversion::{Convert, ConvertOrigin, Decoded, Encoded, Identity, InvertLocation, JustTry}; +pub use conversion::{ + Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry, UniversalLocation, +}; mod drop_assets; pub use drop_assets::{ClaimAssets, DropAssets}; +mod export; +pub use export::{export_xcm, validate_export, ExportXcm}; +mod fee_manager; +pub use fee_manager::{FeeManager, FeeReason}; mod filter_asset_location; pub use filter_asset_location::FilterAssetLocation; mod matches_fungible; diff --git a/xcm/xcm-executor/src/traits/should_execute.rs b/xcm/xcm-executor/src/traits/should_execute.rs index 5f94db0066b4..2bf781cee559 100644 --- a/xcm/xcm-executor/src/traits/should_execute.rs +++ b/xcm/xcm-executor/src/traits/should_execute.rs @@ -16,7 +16,7 @@ use frame_support::weights::Weight; use sp_std::result::Result; -use xcm::latest::{MultiLocation, Xcm}; +use xcm::latest::{Instruction, MultiLocation}; /// Trait to determine whether the execution engine should actually execute a given XCM. /// @@ -26,14 +26,14 @@ pub trait ShouldExecute { /// Returns `true` if the given `message` may be executed. /// /// - `origin`: The origin (sender) of the message. - /// - `message`: The message itself. + /// - `instructions`: The message itself. /// - `max_weight`: The (possibly over-) estimation of the weight of execution of the message. /// - `weight_credit`: The pre-established amount of weight that the system has determined this /// message may utilize in its execution. Typically non-zero only because of prior fee /// payment, but could in principle be due to other factors. fn should_execute( origin: &MultiLocation, - message: &mut Xcm, + instructions: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, ) -> Result<(), ()>; @@ -43,21 +43,21 @@ pub trait ShouldExecute { impl ShouldExecute for Tuple { fn should_execute( origin: &MultiLocation, - message: &mut Xcm, + instructions: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, ) -> Result<(), ()> { for_tuples!( #( - match Tuple::should_execute(origin, message, max_weight, weight_credit) { + match Tuple::should_execute(origin, instructions, max_weight, weight_credit) { Ok(()) => return Ok(()), _ => (), } )* ); log::trace!( target: "xcm::should_execute", - "did not pass barrier: origin: {:?}, message: {:?}, max_weight: {:?}, weight_credit: {:?}", + "did not pass barrier: origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", origin, - message, + instructions, max_weight, weight_credit, ); diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index 0deb3a7f2227..da359f7c7958 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -206,8 +206,8 @@ mod tests { Relay::execute_with(|| { assert_ok!(RelayChainPalletXcm::reserve_transfer_assets( relay_chain::Origin::signed(ALICE), - Box::new(X1(Parachain(1)).into().into()), - Box::new(X1(AccountId32 { network: Any, id: ALICE.into() }).into().into()), + Box::new(Parachain(1).into()), + Box::new(AccountId32 { network: None, id: ALICE.into() }.into()), Box::new((Here, withdraw_amount).into()), 0, )); diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index fa13a731050a..da94f067fa70 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -104,7 +104,7 @@ parameter_types! { parameter_types! { pub const KsmLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub Ancestry: MultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); + pub Ancestry: InteriorMultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); } pub type LocationToAccountId = ( @@ -149,7 +149,10 @@ impl Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); + type FeeManager = (); type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type MessageExporter = (); + type UniversalAliases = Nothing; } #[frame_support::pallet] @@ -224,7 +227,7 @@ pub mod mock_msg_queue { let hash = Encode::using_encoded(&xcm, T::Hashing::hash); let (result, event) = match Xcm::::try_from(xcm) { Ok(xcm) => { - let location = (1, Parachain(sender.into())); + let location = (Parent, Parachain(sender.into())); match T::XcmExecutor::execute_xcm(location, xcm, max_weight) { Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 8ad503cc6417..57980c8fb840 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -94,29 +94,29 @@ impl configuration::Config for Runtime { } parameter_types! { - pub const KsmLocation: MultiLocation = Here.into(); - pub const KusamaNetwork: NetworkId = NetworkId::Kusama; - pub const AnyNetwork: NetworkId = NetworkId::Any; - pub Ancestry: MultiLocation = Here.into(); + pub const TokenLocation: MultiLocation = Here.into_location(); + pub RelayNetwork: NetworkId = ByGenesis([0; 32]); + pub const AnyNetwork: Option = None; + pub Ancestry: InteriorMultiLocation = Here; pub UnitWeightCost: Weight = 1_000; } pub type SovereignAccountOf = - (ChildParachainConvertsVia, AccountId32Aliases); + (ChildParachainConvertsVia, AccountId32Aliases); pub type LocalAssetTransactor = - XcmCurrencyAdapter, SovereignAccountOf, AccountId, ()>; + XcmCurrencyAdapter, SovereignAccountOf, AccountId, ()>; type LocalOriginConverter = ( SovereignSignedViaLocation, ChildParachainAsNative, - SignedAccountId32AsNative, + SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, ); parameter_types! { pub const BaseXcmWeight: Weight = 1_000; - pub KsmPerSecond: (AssetId, u128) = (Concrete(KsmLocation::get()), 1); + pub KsmPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -141,10 +141,13 @@ impl Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); + type FeeManager = (); type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type MessageExporter = (); + type UniversalAliases = Nothing; } -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { type Event = Event; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index e8cd56632ac1..e3ae354daf30 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -104,7 +104,7 @@ parameter_types! { parameter_types! { pub const KsmLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub Ancestry: MultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); + pub Ancestry: InteriorMultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); } pub type LocationToAccountId = ( @@ -149,7 +149,10 @@ impl Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); + type FeeManager = (); type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type MessageExporter = (); + type UniversalAliases = Nothing; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 8ad503cc6417..25fd22955341 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -94,29 +94,29 @@ impl configuration::Config for Runtime { } parameter_types! { - pub const KsmLocation: MultiLocation = Here.into(); - pub const KusamaNetwork: NetworkId = NetworkId::Kusama; - pub const AnyNetwork: NetworkId = NetworkId::Any; - pub Ancestry: MultiLocation = Here.into(); - pub UnitWeightCost: Weight = 1_000; + pub const TokenLocation: MultiLocation = Here.into_location(); + pub const ThisNetwork: NetworkId = NetworkId::ByGenesis([0; 32]); + pub const AnyNetwork: Option = None; + pub const Ancestry: InteriorMultiLocation = Here; + pub const UnitWeightCost: Weight = 1_000; } pub type SovereignAccountOf = - (ChildParachainConvertsVia, AccountId32Aliases); + (ChildParachainConvertsVia, AccountId32Aliases); pub type LocalAssetTransactor = - XcmCurrencyAdapter, SovereignAccountOf, AccountId, ()>; + XcmCurrencyAdapter, SovereignAccountOf, AccountId, ()>; type LocalOriginConverter = ( SovereignSignedViaLocation, ChildParachainAsNative, - SignedAccountId32AsNative, + SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, ); parameter_types! { pub const BaseXcmWeight: Weight = 1_000; - pub KsmPerSecond: (AssetId, u128) = (Concrete(KsmLocation::get()), 1); + pub KsmPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -141,10 +141,13 @@ impl Config for XcmConfig { type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); + type FeeManager = (); type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type MessageExporter = (); + type UniversalAliases = Nothing; } -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { type Event = Event; diff --git a/xcm/xcm-simulator/src/lib.rs b/xcm/xcm-simulator/src/lib.rs index 5e563e153dba..05effd284ec3 100644 --- a/xcm/xcm-simulator/src/lib.rs +++ b/xcm/xcm-simulator/src/lib.rs @@ -296,45 +296,63 @@ macro_rules! decl_test_network { pub struct ParachainXcmRouter($crate::PhantomData); impl> $crate::SendXcm for ParachainXcmRouter { - fn send_xcm(destination: impl Into<$crate::MultiLocation>, message: $crate::Xcm<()>) -> $crate::SendResult { + type Ticket = ($crate::ParaId, $crate::MultiLocation, $crate::Xcm<()>); + fn validate( + destination: &mut Option<$crate::MultiLocation>, + message: &mut Option<$crate::Xcm<()>>, + ) -> $crate::SendResult<($crate::ParaId, $crate::MultiLocation, $crate::Xcm<()>)> { use $crate::{UmpSink, XcmpMessageHandlerT}; - let destination = destination.into(); - match destination.interior() { - $crate::Junctions::Here if destination.parent_count() == 1 => { - $crate::PARA_MESSAGE_BUS.with( - |b| b.borrow_mut().push_back((T::get(), destination, message))); - Ok(()) - }, + let d = destination.take().ok_or($crate::SendError::MissingArgument)?; + match (d.interior(), d.parent_count()) { + ($crate::Junctions::Here, 1) => {}, $( - $crate::X1($crate::Parachain(id)) if *id == $para_id && destination.parent_count() == 1 => { - $crate::PARA_MESSAGE_BUS.with( - |b| b.borrow_mut().push_back((T::get(), destination, message))); - Ok(()) - }, + ($crate::X1($crate::Parachain(id)), 1) if id == &$para_id => {} )* - _ => Err($crate::SendError::CannotReachDestination(destination, message)), + _ => { + *destination = Some(d); + return Err($crate::SendError::NotApplicable) + }, } + let m = message.take().ok_or($crate::SendError::MissingArgument)?; + Ok(((T::get(), d, m), $crate::MultiAssets::new())) + } + fn deliver( + triple: ($crate::ParaId, $crate::MultiLocation, $crate::Xcm<()>), + ) -> Result<(), $crate::SendError> { + $crate::PARA_MESSAGE_BUS.with(|b| b.borrow_mut().push_back(triple)); + Ok(()) } } /// XCM router for relay chain. pub struct RelayChainXcmRouter; impl $crate::SendXcm for RelayChainXcmRouter { - fn send_xcm(destination: impl Into<$crate::MultiLocation>, message: $crate::Xcm<()>) -> $crate::SendResult { + type Ticket = ($crate::MultiLocation, $crate::Xcm<()>); + fn validate( + destination: &mut Option<$crate::MultiLocation>, + message: &mut Option<$crate::Xcm<()>>, + ) -> $crate::SendResult<($crate::MultiLocation, $crate::Xcm<()>)> { use $crate::DmpMessageHandlerT; - let destination = destination.into(); - match destination.interior() { + let d = destination.take().ok_or($crate::SendError::MissingArgument)?; + match (d.interior(), d.parent_count()) { $( - $crate::X1($crate::Parachain(id)) if *id == $para_id && destination.parent_count() == 0 => { - $crate::RELAY_MESSAGE_BUS.with( - |b| b.borrow_mut().push_back((destination, message))); - Ok(()) - }, + ($crate::X1($crate::Parachain(id)), 0) if id == &$para_id => {}, )* - _ => Err($crate::SendError::Unroutable), + _ => { + *destination = Some(d); + return Err($crate::SendError::NotApplicable) + }, } + let m = message.take().ok_or($crate::SendError::MissingArgument)?; + Ok(((d, m), $crate::MultiAssets::new())) + } + fn deliver( + pair: ($crate::MultiLocation, $crate::Xcm<()>), + ) -> Result<(), $crate::SendError> { + $crate::RELAY_MESSAGE_BUS.with(|b| b.borrow_mut().push_back(pair)); + Ok(()) } } }; From 2578af85c9bc6c9429f4cc4ffb03f304efc23a3c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 19 Feb 2022 13:17:29 +0100 Subject: [PATCH 061/231] Bump Substrate --- Cargo.lock | 326 ++++++++++++++++++++++++++--------------------------- 1 file changed, 163 insertions(+), 163 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4800cc27d51..39a3dc3d91b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -439,7 +439,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "beefy-primitives", "fnv", @@ -468,7 +468,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -491,12 +491,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -1889,7 +1889,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", ] @@ -1907,7 +1907,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -1929,7 +1929,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "Inflector", "chrono", @@ -1956,7 +1956,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -1970,7 +1970,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -1998,7 +1998,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "bitflags", "frame-metadata", @@ -2027,7 +2027,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.2", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro2", "quote", @@ -2061,7 +2061,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2084,7 +2084,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -2095,7 +2095,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "log", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -2127,7 +2127,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "sp-api", @@ -2136,7 +2136,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "sp-api", @@ -2332,7 +2332,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "chrono", "frame-election-provider-support", @@ -4752,7 +4752,7 @@ checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -4766,7 +4766,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -4782,7 +4782,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -4797,7 +4797,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -4821,7 +4821,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4841,7 +4841,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-election-provider-support", "frame-support", @@ -4861,7 +4861,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -4876,7 +4876,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "beefy-primitives", "frame-support", @@ -4892,7 +4892,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -4917,7 +4917,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5001,7 +5001,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5018,7 +5018,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5034,7 +5034,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5057,7 +5057,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5075,7 +5075,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5090,7 +5090,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5113,7 +5113,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5129,7 +5129,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5149,7 +5149,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5166,7 +5166,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5183,7 +5183,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5201,7 +5201,7 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5217,7 +5217,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5234,7 +5234,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5249,7 +5249,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5263,7 +5263,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5280,7 +5280,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5303,7 +5303,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5319,7 +5319,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5334,7 +5334,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5348,7 +5348,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5364,7 +5364,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5385,7 +5385,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5401,7 +5401,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5415,7 +5415,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5438,7 +5438,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -5449,7 +5449,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "sp-arithmetic", @@ -5458,7 +5458,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5472,7 +5472,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5490,7 +5490,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5509,7 +5509,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5526,7 +5526,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5543,7 +5543,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5554,7 +5554,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5571,7 +5571,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5587,7 +5587,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -7990,7 +7990,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "env_logger 0.9.0", "jsonrpsee 0.8.0", @@ -8337,7 +8337,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "sp-core", @@ -8348,7 +8348,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -8375,7 +8375,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "futures-timer", @@ -8398,7 +8398,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8414,7 +8414,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.0", @@ -8431,7 +8431,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -8442,7 +8442,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "chrono", "clap", @@ -8480,7 +8480,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "fnv", "futures 0.3.21", @@ -8508,7 +8508,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "hash-db", "kvdb", @@ -8533,7 +8533,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -8557,7 +8557,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "fork-tree", @@ -8600,7 +8600,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -8624,7 +8624,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8637,7 +8637,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -8662,7 +8662,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "sc-client-api", "sp-authorship", @@ -8673,11 +8673,10 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "lazy_static", "libsecp256k1", - "log", "lru 0.6.6", "parity-scale-codec", "parking_lot 0.11.2", @@ -8695,13 +8694,14 @@ dependencies = [ "sp-trie", "sp-version", "sp-wasm-interface", + "tracing", "wasmi", ] [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "environmental", "parity-scale-codec", @@ -8718,7 +8718,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "parity-scale-codec", @@ -8734,7 +8734,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "cfg-if 1.0.0", "libc", @@ -8752,7 +8752,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ahash", "async-trait", @@ -8791,7 +8791,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "finality-grandpa", "futures 0.3.21", @@ -8815,7 +8815,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ansi_term", "futures 0.3.21", @@ -8832,7 +8832,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "hex", @@ -8847,7 +8847,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-std", "async-trait", @@ -8897,7 +8897,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ahash", "futures 0.3.21", @@ -8914,7 +8914,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "bytes 1.1.0", "fnv", @@ -8942,7 +8942,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "libp2p", @@ -8955,7 +8955,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8964,7 +8964,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "hash-db", @@ -8995,7 +8995,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9020,7 +9020,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9037,7 +9037,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "directories", @@ -9101,7 +9101,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "parity-scale-codec", @@ -9115,7 +9115,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -9136,7 +9136,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "chrono", "futures 0.3.21", @@ -9154,7 +9154,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ansi_term", "atty", @@ -9185,7 +9185,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -9196,7 +9196,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "futures-timer", @@ -9223,7 +9223,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "log", @@ -9236,7 +9236,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "futures-timer", @@ -9685,7 +9685,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "hash-db", "log", @@ -9702,7 +9702,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "blake2 0.10.2", "proc-macro-crate 1.1.2", @@ -9714,7 +9714,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -9727,7 +9727,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "integer-sqrt", "num-traits", @@ -9742,7 +9742,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -9755,7 +9755,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "parity-scale-codec", @@ -9767,7 +9767,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "sp-api", @@ -9779,7 +9779,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "log", @@ -9797,7 +9797,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -9816,7 +9816,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "merlin", @@ -9839,7 +9839,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -9851,7 +9851,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -9863,7 +9863,7 @@ dependencies = [ [[package]] name = "sp-core" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "base58", "bitflags", @@ -9908,7 +9908,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "blake2 0.10.2", "byteorder", @@ -9922,7 +9922,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro2", "quote", @@ -9933,7 +9933,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "kvdb", "parking_lot 0.11.2", @@ -9942,7 +9942,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro2", "quote", @@ -9952,7 +9952,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.11.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "environmental", "parity-scale-codec", @@ -9963,7 +9963,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "finality-grandpa", "log", @@ -9981,7 +9981,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -9995,7 +9995,7 @@ dependencies = [ [[package]] name = "sp-io" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "hash-db", @@ -10019,7 +10019,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "lazy_static", "sp-core", @@ -10030,7 +10030,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.11.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -10047,7 +10047,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "thiserror", "zstd", @@ -10056,7 +10056,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -10071,7 +10071,7 @@ dependencies = [ [[package]] name = "sp-npos-elections-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -10082,7 +10082,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "sp-api", "sp-core", @@ -10092,7 +10092,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "backtrace", "lazy_static", @@ -10102,7 +10102,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "rustc-hash", "serde", @@ -10112,7 +10112,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "either", "hash256-std-hasher", @@ -10134,7 +10134,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10151,7 +10151,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "Inflector", "proc-macro-crate 1.1.2", @@ -10163,7 +10163,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "serde", "serde_json", @@ -10172,7 +10172,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -10186,7 +10186,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -10197,7 +10197,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.11.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "hash-db", "log", @@ -10220,12 +10220,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" [[package]] name = "sp-storage" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10238,7 +10238,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "sp-core", @@ -10251,7 +10251,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures-timer", @@ -10267,7 +10267,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "sp-std", @@ -10279,7 +10279,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "sp-api", "sp-runtime", @@ -10288,7 +10288,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "log", @@ -10304,7 +10304,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "hash-db", "memory-db", @@ -10319,7 +10319,7 @@ dependencies = [ [[package]] name = "sp-version" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10336,7 +10336,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10347,7 +10347,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-trait-for-tuples", "log", @@ -10515,7 +10515,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "platforms", ] @@ -10523,7 +10523,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.21", @@ -10545,7 +10545,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-std", "futures-util", @@ -10559,7 +10559,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -10585,7 +10585,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "substrate-test-utils-derive", @@ -10595,7 +10595,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -10606,7 +10606,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ansi_term", "build-helper", @@ -11201,7 +11201,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "clap", "jsonrpsee 0.4.1", From 768535fb73f5f0d7e99370e139a07e56cabc58dd Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sun, 20 Feb 2022 19:47:55 +0100 Subject: [PATCH 062/231] XCM v3: `ExchangeAsset` and Remote-locking (#4945) * Asset Exchange and Locks * Make sure XCM typers impl MaxEncodedLen * Basic implementation for locks * Bump Substrate * Missing files * Use new API * Introduce instruction * Big refactor * Docs * Remove deprecated struct * Remove deprecated struct * Repot XCM builder tests * ExchangeAsset test * Exchange tests * Locking tests * Locking tests * Fixes and tests * Fixes * Formatting * Spelling --- Cargo.lock | 327 ++-- .../bin/rialto-parachain/runtime/src/lib.rs | 2 + runtime/kusama/src/xcm_config.rs | 7 + runtime/polkadot/src/xcm_config.rs | 7 + runtime/rococo/src/xcm_config.rs | 13 +- runtime/test-runtime/src/lib.rs | 5 + runtime/test-runtime/src/xcm_config.rs | 2 + runtime/westend/src/weights/xcm/mod.rs | 21 +- runtime/westend/src/xcm_config.rs | 7 + xcm/Cargo.toml | 2 +- xcm/pallet-xcm-benchmarks/Cargo.toml | 1 + .../src/fungible/benchmarking.rs | 12 +- .../src/fungible/mock.rs | 2 + .../src/generic/benchmarking.rs | 53 +- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 2 + xcm/pallet-xcm/Cargo.toml | 4 +- xcm/pallet-xcm/src/lib.rs | 1724 ++++++++++------- xcm/pallet-xcm/src/mock.rs | 7 + xcm/src/lib.rs | 586 +++--- xcm/src/v1/junction.rs | 4 +- xcm/src/v1/mod.rs | 30 +- xcm/src/v1/multiasset.rs | 54 +- xcm/src/v2/mod.rs | 4 +- xcm/src/v3/junction.rs | 143 +- xcm/src/v3/junctions.rs | 77 +- xcm/src/v3/mod.rs | 207 +- xcm/src/v3/multiasset.rs | 181 +- xcm/src/v3/multilocation.rs | 19 +- xcm/src/v3/traits.rs | 29 +- xcm/xcm-builder/Cargo.toml | 2 +- xcm/xcm-builder/src/currency_adapter.rs | 9 +- xcm/xcm-builder/src/fungibles_adapter.rs | 2 +- xcm/xcm-builder/src/lib.rs | 6 - xcm/xcm-builder/src/matches_fungible.rs | 6 +- xcm/xcm-builder/src/tests.rs | 1282 ------------ xcm/xcm-builder/src/tests/assets.rs | 427 ++++ xcm/xcm-builder/src/tests/barriers.rs | 162 ++ xcm/xcm-builder/src/tests/basic.rs | 99 + .../bridging}/local_para_para.rs | 0 .../bridging}/local_relay_relay.rs | 0 .../{bridging_tests => tests/bridging}/mod.rs | 4 +- .../bridging}/paid_remote_relay_relay.rs | 8 +- .../bridging}/remote_para_para.rs | 0 .../bridging}/remote_para_para_via_relay.rs | 0 .../bridging}/remote_relay_relay.rs | 0 xcm/xcm-builder/src/tests/expecting.rs | 157 ++ xcm/xcm-builder/src/tests/locking.rs | 235 +++ xcm/xcm-builder/src/{ => tests}/mock.rs | 223 ++- xcm/xcm-builder/src/tests/mod.rs | 35 + xcm/xcm-builder/src/tests/origins.rs | 76 + xcm/xcm-builder/src/tests/querying.rs | 120 ++ xcm/xcm-builder/src/tests/transacting.rs | 186 ++ .../src/tests/version_subscriptions.rs | 129 ++ xcm/xcm-builder/src/tests/weight.rs | 139 ++ xcm/xcm-builder/src/weight.rs | 56 - xcm/xcm-builder/tests/mock/mod.rs | 7 + xcm/xcm-executor/src/assets.rs | 54 +- xcm/xcm-executor/src/config.rs | 12 +- xcm/xcm-executor/src/lib.rs | 262 ++- xcm/xcm-executor/src/traits/asset_exchange.rs | 58 + xcm/xcm-executor/src/traits/asset_lock.rs | 151 ++ xcm/xcm-executor/src/traits/fee_manager.rs | 11 +- xcm/xcm-executor/src/traits/mod.rs | 4 + xcm/xcm-simulator/example/src/parachain.rs | 7 + xcm/xcm-simulator/example/src/relay_chain.rs | 7 + xcm/xcm-simulator/fuzzer/src/parachain.rs | 7 + xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 7 + 67 files changed, 4784 insertions(+), 2698 deletions(-) delete mode 100644 xcm/xcm-builder/src/tests.rs create mode 100644 xcm/xcm-builder/src/tests/assets.rs create mode 100644 xcm/xcm-builder/src/tests/barriers.rs create mode 100644 xcm/xcm-builder/src/tests/basic.rs rename xcm/xcm-builder/src/{bridging_tests => tests/bridging}/local_para_para.rs (100%) rename xcm/xcm-builder/src/{bridging_tests => tests/bridging}/local_relay_relay.rs (100%) rename xcm/xcm-builder/src/{bridging_tests => tests/bridging}/mod.rs (98%) rename xcm/xcm-builder/src/{bridging_tests => tests/bridging}/paid_remote_relay_relay.rs (94%) rename xcm/xcm-builder/src/{bridging_tests => tests/bridging}/remote_para_para.rs (100%) rename xcm/xcm-builder/src/{bridging_tests => tests/bridging}/remote_para_para_via_relay.rs (100%) rename xcm/xcm-builder/src/{bridging_tests => tests/bridging}/remote_relay_relay.rs (100%) create mode 100644 xcm/xcm-builder/src/tests/expecting.rs create mode 100644 xcm/xcm-builder/src/tests/locking.rs rename xcm/xcm-builder/src/{ => tests}/mock.rs (65%) create mode 100644 xcm/xcm-builder/src/tests/mod.rs create mode 100644 xcm/xcm-builder/src/tests/origins.rs create mode 100644 xcm/xcm-builder/src/tests/querying.rs create mode 100644 xcm/xcm-builder/src/tests/transacting.rs create mode 100644 xcm/xcm-builder/src/tests/version_subscriptions.rs create mode 100644 xcm/xcm-builder/src/tests/weight.rs create mode 100644 xcm/xcm-executor/src/traits/asset_exchange.rs create mode 100644 xcm/xcm-executor/src/traits/asset_lock.rs diff --git a/Cargo.lock b/Cargo.lock index a4800cc27d51..7c464bfaa6bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -439,7 +439,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "beefy-primitives", "fnv", @@ -468,7 +468,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -491,12 +491,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -1889,7 +1889,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", ] @@ -1907,7 +1907,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -1929,7 +1929,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "Inflector", "chrono", @@ -1956,7 +1956,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -1970,7 +1970,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -1998,7 +1998,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "bitflags", "frame-metadata", @@ -2027,7 +2027,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.2", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro2", "quote", @@ -2061,7 +2061,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2084,7 +2084,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -2095,7 +2095,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "log", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -2127,7 +2127,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "sp-api", @@ -2136,7 +2136,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "sp-api", @@ -2332,7 +2332,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "chrono", "frame-election-provider-support", @@ -4752,7 +4752,7 @@ checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -4766,7 +4766,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -4782,7 +4782,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -4797,7 +4797,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -4821,7 +4821,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4841,7 +4841,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-election-provider-support", "frame-support", @@ -4861,7 +4861,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -4876,7 +4876,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "beefy-primitives", "frame-support", @@ -4892,7 +4892,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -4917,7 +4917,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5001,7 +5001,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5018,7 +5018,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5034,7 +5034,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5057,7 +5057,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5075,7 +5075,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5090,7 +5090,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5113,7 +5113,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5129,7 +5129,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5149,7 +5149,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5166,7 +5166,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5183,7 +5183,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5201,7 +5201,7 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5217,7 +5217,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5234,7 +5234,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5249,7 +5249,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5263,7 +5263,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5280,7 +5280,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5303,7 +5303,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5319,7 +5319,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5334,7 +5334,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5348,7 +5348,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5364,7 +5364,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5385,7 +5385,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5401,7 +5401,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5415,7 +5415,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5438,7 +5438,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -5449,7 +5449,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "sp-arithmetic", @@ -5458,7 +5458,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5472,7 +5472,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5490,7 +5490,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5509,7 +5509,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-support", "frame-system", @@ -5526,7 +5526,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5543,7 +5543,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5554,7 +5554,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5571,7 +5571,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5587,7 +5587,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-benchmarking", "frame-support", @@ -5605,6 +5605,7 @@ version = "0.9.17" dependencies = [ "frame-support", "frame-system", + "impl-trait-for-tuples", "log", "pallet-balances", "parity-scale-codec", @@ -7990,7 +7991,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "env_logger 0.9.0", "jsonrpsee 0.8.0", @@ -8337,7 +8338,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "sp-core", @@ -8348,7 +8349,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -8375,7 +8376,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "futures-timer", @@ -8398,7 +8399,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8414,7 +8415,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.0", @@ -8431,7 +8432,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -8442,7 +8443,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "chrono", "clap", @@ -8480,7 +8481,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "fnv", "futures 0.3.21", @@ -8508,7 +8509,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "hash-db", "kvdb", @@ -8533,7 +8534,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -8557,7 +8558,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "fork-tree", @@ -8600,7 +8601,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -8624,7 +8625,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8637,7 +8638,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -8662,7 +8663,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "sc-client-api", "sp-authorship", @@ -8673,11 +8674,10 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "lazy_static", "libsecp256k1", - "log", "lru 0.6.6", "parity-scale-codec", "parking_lot 0.11.2", @@ -8695,13 +8695,14 @@ dependencies = [ "sp-trie", "sp-version", "sp-wasm-interface", + "tracing", "wasmi", ] [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "environmental", "parity-scale-codec", @@ -8718,7 +8719,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "parity-scale-codec", @@ -8734,7 +8735,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "cfg-if 1.0.0", "libc", @@ -8752,7 +8753,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ahash", "async-trait", @@ -8791,7 +8792,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "finality-grandpa", "futures 0.3.21", @@ -8815,7 +8816,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ansi_term", "futures 0.3.21", @@ -8832,7 +8833,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "hex", @@ -8847,7 +8848,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-std", "async-trait", @@ -8897,7 +8898,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ahash", "futures 0.3.21", @@ -8914,7 +8915,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "bytes 1.1.0", "fnv", @@ -8942,7 +8943,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "libp2p", @@ -8955,7 +8956,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8964,7 +8965,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "hash-db", @@ -8995,7 +8996,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9020,7 +9021,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9037,7 +9038,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "directories", @@ -9101,7 +9102,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "parity-scale-codec", @@ -9115,7 +9116,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -9136,7 +9137,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "chrono", "futures 0.3.21", @@ -9154,7 +9155,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ansi_term", "atty", @@ -9185,7 +9186,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -9196,7 +9197,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "futures-timer", @@ -9223,7 +9224,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "log", @@ -9236,7 +9237,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "futures-timer", @@ -9685,7 +9686,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "hash-db", "log", @@ -9702,7 +9703,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "blake2 0.10.2", "proc-macro-crate 1.1.2", @@ -9714,7 +9715,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -9727,7 +9728,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "integer-sqrt", "num-traits", @@ -9742,7 +9743,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -9755,7 +9756,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "parity-scale-codec", @@ -9767,7 +9768,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "sp-api", @@ -9779,7 +9780,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "log", @@ -9797,7 +9798,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -9816,7 +9817,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "merlin", @@ -9839,7 +9840,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -9851,7 +9852,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -9863,7 +9864,7 @@ dependencies = [ [[package]] name = "sp-core" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "base58", "bitflags", @@ -9908,7 +9909,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "blake2 0.10.2", "byteorder", @@ -9922,7 +9923,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro2", "quote", @@ -9933,7 +9934,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "kvdb", "parking_lot 0.11.2", @@ -9942,7 +9943,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro2", "quote", @@ -9952,7 +9953,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.11.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "environmental", "parity-scale-codec", @@ -9963,7 +9964,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "finality-grandpa", "log", @@ -9981,7 +9982,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -9995,7 +9996,7 @@ dependencies = [ [[package]] name = "sp-io" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "hash-db", @@ -10019,7 +10020,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "lazy_static", "sp-core", @@ -10030,7 +10031,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.11.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -10047,7 +10048,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "thiserror", "zstd", @@ -10056,7 +10057,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -10071,7 +10072,7 @@ dependencies = [ [[package]] name = "sp-npos-elections-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -10082,7 +10083,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "sp-api", "sp-core", @@ -10092,7 +10093,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "backtrace", "lazy_static", @@ -10102,7 +10103,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "rustc-hash", "serde", @@ -10112,7 +10113,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "either", "hash256-std-hasher", @@ -10134,7 +10135,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10151,7 +10152,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "Inflector", "proc-macro-crate 1.1.2", @@ -10163,7 +10164,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "serde", "serde_json", @@ -10172,7 +10173,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -10186,7 +10187,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "scale-info", @@ -10197,7 +10198,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.11.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "hash-db", "log", @@ -10220,12 +10221,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" [[package]] name = "sp-storage" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10238,7 +10239,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "log", "sp-core", @@ -10251,7 +10252,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures-timer", @@ -10267,7 +10268,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "sp-std", @@ -10279,7 +10280,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "sp-api", "sp-runtime", @@ -10288,7 +10289,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "log", @@ -10304,7 +10305,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "hash-db", "memory-db", @@ -10319,7 +10320,7 @@ dependencies = [ [[package]] name = "sp-version" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10336,7 +10337,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10347,7 +10348,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "impl-trait-for-tuples", "log", @@ -10515,7 +10516,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "platforms", ] @@ -10523,7 +10524,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.21", @@ -10545,7 +10546,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-std", "futures-util", @@ -10559,7 +10560,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "async-trait", "futures 0.3.21", @@ -10585,7 +10586,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "futures 0.3.21", "substrate-test-utils-derive", @@ -10595,7 +10596,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "proc-macro-crate 1.1.2", "proc-macro2", @@ -10606,7 +10607,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "ansi_term", "build-helper", @@ -11201,7 +11202,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#5cdbaa3e1caac94fa3ede30f9fb08fd1f031b3d4" +source = "git+https://github.com/paritytech/substrate?branch=master#f72fe056844a375f16449555d6e20e57dcd16aa6" dependencies = [ "clap", "jsonrpsee 0.4.1", diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index 71e3244a754b..7660597892b0 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -378,6 +378,8 @@ impl Config for XcmConfig { type Trader = UsingComponents, RelayLocation, AccountId, Balances, ()>; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index b7bd88054501..aab416f7f33d 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -150,6 +150,8 @@ impl xcm_executor::Config for XcmConfig { UsingComponents>; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; @@ -195,4 +197,9 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = SovereignAccountOf; + type MaxLockers = frame_support::traits::ConstU32<8>; } diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 772c949fcea5..7f67563bf319 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -142,6 +142,8 @@ impl xcm_executor::Config for XcmConfig { UsingComponents>; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; @@ -187,4 +189,9 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = SovereignAccountOf; + type MaxLockers = frame_support::traits::ConstU32<8>; } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index c7de71c778d9..f0c3d81d99ff 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -43,7 +43,7 @@ parameter_types! { pub CheckAccount: AccountId = XcmPallet::check_account(); } -pub type SovereignAccountOf = +pub type LocationConverter = (ChildParachainConvertsVia, AccountId32Aliases); pub type LocalAssetTransactor = XcmCurrencyAdapter< @@ -52,7 +52,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< // Use this currency when it is a fungible asset matching the given location or name: IsConcrete, // We can convert the MultiLocations with our converter above: - SovereignAccountOf, + LocationConverter, // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, // It's a native asset so we keep track of the teleports to maintain total issuance. @@ -60,7 +60,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< >; type LocalOriginConverter = ( - SovereignSignedViaLocation, + SovereignSignedViaLocation, ChildParachainAsNative, SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, @@ -135,6 +135,8 @@ impl xcm_executor::Config for XcmConfig { UsingComponents>; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; @@ -175,4 +177,9 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = IsConcrete; + type TrustedLockers = (); + type SovereignAccountOf = LocationConverter; + type MaxLockers = frame_support::traits::ConstU32<8>; } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 7227b0758c89..ca95251ea074 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -543,6 +543,11 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = (); + type MaxLockers = frame_support::traits::ConstU32<8>; } impl parachains_hrmp::Config for Runtime { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index a68f3f9a5159..c6643bc7aeab 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -100,6 +100,8 @@ impl xcm_executor::Config for XcmConfig { type Trader = DummyWeightTrader; type ResponseHandler = super::Xcm; type AssetTrap = super::Xcm; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = super::Xcm; type SubscriptionService = super::Xcm; type PalletInstancesInfo = (); diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 6be429bfd7cf..77fba4396aaa 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -140,7 +140,7 @@ impl XcmWeightInfo for WestendXcmWeight { ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> Weight { + fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { Weight::MAX // todo fix } fn initiate_reserve_withdraw( @@ -218,9 +218,24 @@ impl XcmWeightInfo for WestendXcmWeight { XcmGeneric::::clear_transact_status() } fn universal_origin(_: &Junction) -> Weight { - 10_000_000_000 + Weight::MAX // todo fix } fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { - 10_000_000_000 + Weight::MAX // todo fix + } + fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { + Weight::MAX // todo fix + } + fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { + Weight::MAX // todo fix + } + fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { + Weight::MAX // todo fix + } + fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { + Weight::MAX // todo fix + } + fn set_fees_mode(_: &bool) -> Weight { + Weight::MAX // todo fix } } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 2bb915f90100..4fe04bd8c056 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -114,6 +114,8 @@ impl xcm_executor::Config for XcmConfig { UsingComponents>; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; @@ -147,4 +149,9 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = IsConcrete; + type TrustedLockers = (); + type SovereignAccountOf = LocationConverter; + type MaxLockers = frame_support::traits::ConstU32<8>; } diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index 560df741b1b5..e332b3dfd959 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] impl-trait-for-tuples = "0.2.2" -parity-scale-codec = { version = "2.3.1", default-features = false, features = [ "derive" ] } +parity-scale-codec = { version = "2.3.1", default-features = false, features = [ "derive", "max-encoded-len" ] } scale-info = { version = "1.0", default-features = false, features = ["derive"] } derivative = {version = "2.2.0", default-features = false, features = [ "use_core" ] } log = { version = "0.4.14", default-features = false } diff --git a/xcm/pallet-xcm-benchmarks/Cargo.toml b/xcm/pallet-xcm-benchmarks/Cargo.toml index 0cc3c4bb0202..9d0ee0c3d5e2 100644 --- a/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -14,6 +14,7 @@ frame-support = { default-features = false, branch = "master", git = "https://gi frame-system = { default-features = false, branch = "master", git = "https://github.com/paritytech/substrate" } sp-runtime = { default-features = false, branch = "master", git = "https://github.com/paritytech/substrate" } sp-std = { default-features = false, branch = "master", git = "https://github.com/paritytech/substrate" } +sp-io = { default-features = false, branch = "master", git = "https://github.com/paritytech/substrate" } xcm-executor = { path = "../xcm-executor", default-features = false, features = ["runtime-benchmarks"] } frame-benchmarking = { default-features = false, branch = "master", git = "https://github.com/paritytech/substrate" } xcm = { path = "..", default-features = false, features = ["runtime-benchmarks"] } diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 14bbe676fa66..916da48c4a96 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -49,7 +49,7 @@ benchmarks_instance_pallet! { assert!(!T::TransactAsset::balance(&sender_account).is_zero()); let mut executor = new_executor::(sender_location); - executor.holding = worst_case_holding.into(); + executor.set_holding(worst_case_holding.into()); let instruction = Instruction::>::WithdrawAsset(vec![asset.clone()].into()); let xcm = Xcm(vec![instruction]); }: { @@ -57,7 +57,7 @@ benchmarks_instance_pallet! { } verify { // check one of the assets of origin. assert!(T::TransactAsset::balance(&sender_account).is_zero()); - assert!(executor.holding.ensure_contains(&vec![asset].into()).is_ok()); + assert!(executor.holding().ensure_contains(&vec![asset].into()).is_ok()); } transfer_asset { @@ -135,7 +135,7 @@ benchmarks_instance_pallet! { ) })?; } verify { - assert!(executor.holding.ensure_contains(&assets).is_ok()); + assert!(executor.holding().ensure_contains(&assets).is_ok()); } deposit_asset { @@ -151,7 +151,7 @@ benchmarks_instance_pallet! { assert!(T::TransactAsset::balance(&dest_account).is_zero()); let mut executor = new_executor::(Default::default()); - executor.holding = holding.into(); + executor.set_holding(holding.into()); let instruction = Instruction::>::DepositAsset { assets: asset.into(), beneficiary: dest_location, @@ -177,7 +177,7 @@ benchmarks_instance_pallet! { assert!(T::TransactAsset::balance(&dest_account).is_zero()); let mut executor = new_executor::(Default::default()); - executor.holding = holding.into(); + executor.set_holding(holding.into()); let instruction = Instruction::>::DepositReserveAsset { assets: asset.into(), dest: dest_location, @@ -202,7 +202,7 @@ benchmarks_instance_pallet! { assert!(T::CheckedAccount::get().map_or(true, |c| T::TransactAsset::balance(&c).is_zero())); let mut executor = new_executor::(Default::default()); - executor.holding = holding.into(); + executor.set_holding(holding.into()); let instruction = Instruction::>::InitiateTeleport { assets: asset.into(), dest: T::valid_destination()?, diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index f139e3c0f779..0b1182b5f0bf 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -144,6 +144,8 @@ impl xcm_executor::Config for XcmConfig { type Trader = xcm_builder::FixedRateOfFungible; type ResponseHandler = DevNull; type AssetTrap = (); + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = AllPalletsWithSystem; diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index a55cd27b9113..adc2d98a1bb0 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -19,6 +19,7 @@ use crate::{new_executor, XcmCallOf}; use codec::Encode; use frame_benchmarking::{benchmarks, BenchmarkError}; use frame_support::dispatch::GetDispatchInfo; +use sp_io::hashing::blake2_256; use sp_std::vec; use xcm::{ latest::{prelude::*, MaybeErrorCode, MultiAssets}, @@ -31,7 +32,7 @@ benchmarks! { let holding = T::worst_case_holding(0); let mut executor = new_executor::(Default::default()); - executor.holding = holding.clone().into(); + executor.set_holding(holding.clone().into()); let instruction = Instruction::>::ReportHolding { response_info: QueryResponseInfo { @@ -57,7 +58,7 @@ benchmarks! { let holding = T::worst_case_holding(0).into(); let mut executor = new_executor::(Default::default()); - executor.holding = holding; + executor.set_holding(holding); let fee_asset = Concrete(Here.into()); @@ -79,7 +80,7 @@ benchmarks! { const MAX_ASSETS: u32 = 100; // TODO when executor has a built in limit, use it here. #4426 let mut executor = new_executor::(Default::default()); let assets = (0..MAX_ASSETS).map(|i| MultiAsset { - id: Abstract(i.encode()), + id: Abstract(i.using_encoded(blake2_256)), fun: Fungible(i as u128), }).collect::>(); @@ -90,7 +91,7 @@ benchmarks! { }: { executor.execute(xcm).map_err(|_| BenchmarkError::Skip)?; } verify { - assert_eq!(executor.holding, multiassets.into()); + assert_eq!(executor.holding(), &multiassets.into()); } query_response { @@ -136,17 +137,17 @@ benchmarks! { refund_surplus { let holding = T::worst_case_holding(0).into(); let mut executor = new_executor::(Default::default()); - executor.holding = holding; - executor.total_surplus = 1337; - executor.total_refunded = 0; + executor.set_holding(holding); + executor.set_total_surplus(1337); + executor.set_total_refunded(0); let instruction = Instruction::>::RefundSurplus; let xcm = Xcm(vec![instruction]); } : { let result = executor.execute(xcm)?; } verify { - assert_eq!(executor.total_surplus, 1337); - assert_eq!(executor.total_refunded, 1337); + assert_eq!(executor.total_surplus(), &1337); + assert_eq!(executor.total_refunded(), &1337); } set_error_handler { @@ -156,7 +157,7 @@ benchmarks! { } : { executor.execute(xcm)?; } verify { - assert_eq!(executor.error_handler, Xcm(vec![])); + assert_eq!(executor.error_handler(), &Xcm(vec![])); } set_appendix { @@ -167,18 +168,18 @@ benchmarks! { } : { executor.execute(xcm)?; } verify { - assert_eq!(executor.appendix, Xcm(vec![])); + assert_eq!(executor.appendix(), &Xcm(vec![])); } clear_error { let mut executor = new_executor::(Default::default()); - executor.error = Some((5u32, XcmError::Overflow)); + executor.set_error(Some((5u32, XcmError::Overflow))); let instruction = Instruction::>::ClearError; let xcm = Xcm(vec![instruction]); } : { executor.execute(xcm)?; } verify { - assert!(executor.error.is_none()) + assert!(executor.error().is_none()) } descend_origin { @@ -190,8 +191,8 @@ benchmarks! { executor.execute(xcm)?; } verify { assert_eq!( - executor.origin, - Some(MultiLocation { + executor.origin(), + &Some(MultiLocation { parents: 0, interior: who, }), @@ -205,12 +206,12 @@ benchmarks! { } : { executor.execute(xcm)?; } verify { - assert_eq!(executor.origin, None); + assert_eq!(executor.origin(), &None); } report_error { let mut executor = new_executor::(Default::default()); - executor.error = Some((0u32, XcmError::Unimplemented)); + executor.set_error(Some((0u32, XcmError::Unimplemented))); let query_id = Default::default(); let destination = T::valid_destination().map_err(|_| BenchmarkError::Skip)?; let max_weight = Default::default(); @@ -244,7 +245,7 @@ benchmarks! { } :{ executor.execute(xcm)?; } verify { - assert!(executor.holding.ensure_contains(&assets).is_ok()); + assert!(executor.holding().ensure_contains(&assets).is_ok()); } trap { @@ -303,7 +304,7 @@ benchmarks! { let assets_filter = MultiAssetFilter::Definite(holding.clone()); let reserve = T::valid_destination().map_err(|_| BenchmarkError::Skip)?; let mut executor = new_executor::(Default::default()); - executor.holding = holding.into(); + executor.set_holding(holding.into()); let instruction = Instruction::InitiateReserveWithdraw { assets: assets_filter, reserve, xcm: Xcm(vec![]) }; let xcm = Xcm(vec![instruction]); }: { @@ -318,14 +319,14 @@ benchmarks! { let assets = holding.clone(); let mut executor = new_executor::(Default::default()); - executor.holding = holding.into(); + executor.set_holding(holding.into()); let instruction = Instruction::BurnAsset(assets.into()); let xcm = Xcm(vec![instruction]); }: { executor.execute(xcm)?; } verify { - assert!(executor.holding.is_empty()); + assert!(executor.holding().is_empty()); } expect_asset { @@ -333,7 +334,7 @@ benchmarks! { let assets = holding.clone(); let mut executor = new_executor::(Default::default()); - executor.holding = holding.into(); + executor.set_holding(holding.into()); let instruction = Instruction::ExpectAsset(assets.into()); let xcm = Xcm(vec![instruction]); @@ -361,7 +362,7 @@ benchmarks! { expect_error { let mut executor = new_executor::(Default::default()); - executor.error = Some((3u32, XcmError::Overflow)); + executor.set_error(Some((3u32, XcmError::Overflow))); let instruction = Instruction::ExpectError(None); let xcm = Xcm(vec![instruction]); @@ -415,7 +416,7 @@ benchmarks! { let max_weight = Default::default(); let mut executor = new_executor::(Default::default()); - executor.transact_status = MaybeErrorCode::Error(b"MyError".to_vec()); + executor.set_transact_status(b"MyError".to_vec().into()); let instruction = Instruction::ReportTransactStatus(QueryResponseInfo { query_id, @@ -431,14 +432,14 @@ benchmarks! { clear_transact_status { let mut executor = new_executor::(Default::default()); - executor.transact_status = MaybeErrorCode::Error(b"MyError".to_vec()); + executor.set_transact_status(MaybeErrorCode::Error(b"MyError".to_vec())); let instruction = Instruction::ClearTransactStatus; let xcm = Xcm(vec![instruction]); }: { executor.execute(xcm)?; } verify { - assert_eq!(executor.transact_status, MaybeErrorCode::Success); + assert_eq!(executor.transact_status(), &MaybeErrorCode::Success); } impl_benchmark_test_suite!( diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 12b40dce0a29..052714204989 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -112,6 +112,8 @@ impl xcm_executor::Config for XcmConfig { type Trader = xcm_builder::FixedRateOfFungible; type ResponseHandler = DevNull; type AssetTrap = TestAssetTrap; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; type PalletInstancesInfo = AllPalletsWithSystem; diff --git a/xcm/pallet-xcm/Cargo.toml b/xcm/pallet-xcm/Cargo.toml index b497f3a10f11..0fa47e063806 100644 --- a/xcm/pallet-xcm/Cargo.toml +++ b/xcm/pallet-xcm/Cargo.toml @@ -9,8 +9,10 @@ codec = { package = "parity-scale-codec", version = "2.0.0", default-features = scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true, features = ["derive"] } log = { version = "0.4.14", default-features = false } +impl-trait-for-tuples = "0.2.2" sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -22,7 +24,6 @@ xcm-executor = { path = "../xcm-executor", default-features = false } [dev-dependencies] pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } polkadot-runtime-parachains = { path = "../../runtime/parachains" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } xcm-builder = { path = "../xcm-builder" } polkadot-parachain = { path = "../../parachain" } @@ -33,6 +34,7 @@ std = [ "scale-info/std", "serde", "sp-std/std", + "sp-io/std", "sp-core/std", "sp-runtime/std", "frame-support/std", diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 171320203e27..e7f8c82630a7 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -24,10 +24,12 @@ mod mock; mod tests; use codec::{Decode, Encode, EncodeLike}; -use frame_support::traits::{Contains, EnsureOrigin, Get, OriginTrait}; +use frame_support::traits::{ + Contains, Currency, Defensive, EnsureOrigin, Get, LockableCurrency, OriginTrait, +}; use scale_info::TypeInfo; use sp_runtime::{ - traits::{BadOrigin, Saturating}, + traits::{BadOrigin, Saturating, Zero}, RuntimeDebug, }; use sp_std::{ @@ -39,29 +41,35 @@ use sp_std::{ vec, }; use xcm::{latest::QueryResponseInfo, prelude::*}; -use xcm_executor::traits::ConvertOrigin; +use xcm_executor::traits::{Convert, ConvertOrigin}; -use frame_support::PalletId; +use frame_support::{ + dispatch::{Dispatchable, GetDispatchInfo}, + pallet_prelude::*, + traits::WithdrawReasons, + PalletId, +}; +use frame_system::pallet_prelude::*; pub use pallet::*; +use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash}; +use xcm_executor::{ + traits::{ + ClaimAssets, DropAssets, MatchesFungible, OnResponse, UniversalLocation, + VersionChangeNotifier, WeightBounds, + }, + Assets, +}; #[frame_support::pallet] pub mod pallet { use super::*; use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo}, - pallet_prelude::*, parameter_types, }; - use frame_system::{pallet_prelude::*, Config as SysConfig}; + use frame_system::Config as SysConfig; use sp_core::H256; - use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash}; - use xcm_executor::{ - traits::{ - ClaimAssets, DropAssets, OnResponse, UniversalLocation, VersionChangeNotifier, - WeightBounds, - }, - Assets, - }; + use xcm_executor::traits::{MatchesFungible, UniversalLocation, WeightBounds}; parameter_types! { /// An implementation of `Get` which just returns the latest XCM version which we can @@ -74,12 +82,64 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(_); + /// A trait for querying whether a type can be said to "contain" a single pair-value. + pub trait ContainsPair { + /// Return `true` if this "contains" the pair-value `a, b`. + fn contains(a: &A, b: &B) -> bool; + } + + impl ContainsPair for frame_support::traits::Everything { + fn contains(_: &A, _: &B) -> bool { + true + } + } + + impl ContainsPair for frame_support::traits::Nothing { + fn contains(_: &A, _: &B) -> bool { + false + } + } + + #[impl_trait_for_tuples::impl_for_tuples(0, 30)] + impl ContainsPair for Tuple { + fn contains(a: &A, b: &B) -> bool { + for_tuples!( #( + if Tuple::contains(a, b) { return true } + )* ); + false + } + } + + /// Create a type which implements the `Contains` trait for a particular type with syntax similar + /// to `matches!`. + #[macro_export] + macro_rules! match_type { + ( pub type $n:ident: impl ContainsPair<$a:ty, $b:ty> = { $phead:pat_param $( | $ptail:pat )* } ; ) => { + pub struct $n; + impl $crate::traits::ContainsPair<$a, $b> for $n { + fn contains(a: &$a, b: &$b) -> bool { + matches!((a, b), $phead $( | $ptail )* ) + } + } + } + } + + pub type BalanceOf = + <::Currency as Currency<::AccountId>>::Balance; + #[pallet::config] /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. type Event: From> + IsType<::Event>; + /// A lockable currency. + // TODO: We should really use a trait which can handle multiple currencies. + type Currency: LockableCurrency; + + /// The `MultiAsset` matcher for `Currency`. + type CurrencyMatcher: MatchesFungible>; + /// Required origin for sending XCM messages. If successful, it resolves to `MultiLocation` /// which exists as an interior location within this chain's XCM context. type SendXcmOrigin: EnsureOrigin<::Origin, Success = MultiLocation>; @@ -124,10 +184,17 @@ pub mod pallet { /// The latest supported version that we advertise. Generally just set it to /// `pallet_xcm::CurrentXcmVersion`. type AdvertisedXcmVersion: Get; - } - /// The maximum number of distinct assets allowed to be transferred in a single helper extrinsic. - const MAX_ASSETS_FOR_TRANSFER: usize = 2; + /// The assets which we consider a given origin is trusted if they claim to have placed a + /// lock. + type TrustedLockers: ContainsPair; + + /// How to get an `AccountId` value from a `MultiLocation`, useful for handling asset locks. + type SovereignAccountOf: Convert; + + /// The maximum number of local XCM locks that a single account may have. + type MaxLockers: Get; + } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] @@ -199,8 +266,10 @@ pub mod pallet { AssetsTrapped(H256, MultiLocation, VersionedMultiAssets), /// An XCM version change notification message has been attempted to be sent. /// - /// \[ destination, result \] - VersionChangeNotified(MultiLocation, XcmVersion), + /// The cost of sending it (borne by the chain) is included. + /// + /// \[ destination, result, cost \] + VersionChangeNotified(MultiLocation, XcmVersion, MultiAssets), /// The supported version of a location has been changed. This might be through an /// automatic notification or a manual intervention. /// @@ -232,6 +301,23 @@ pub mod pallet { /// /// \[ origin location, id, expected querier, maybe actual querier \] InvalidQuerier(MultiLocation, QueryId, MultiLocation, Option), + /// A remote has requested XCM version change notification from us and we have honored it. + /// A version information message is sent to them and its cost is included. + /// + /// \[ destination location, cost \] + VersionNotifyStarted(MultiLocation, MultiAssets), + /// We have requested that a remote chain sends us XCM version change notifications. + /// + /// \[ destination location, cost \] + VersionNotifyRequested(MultiLocation, MultiAssets), + /// We have requested that a remote chain stops sending us XCM version change notifications. + /// + /// \[ destination location, cost \] + VersionNotifyUnrequested(MultiLocation, MultiAssets), + /// Fees were paid from a location for an operation (often for using `SendXcm`). + /// + /// \[ paying location, fees \] + FeesPaid(MultiLocation, MultiAssets), } #[pallet::origin] @@ -279,6 +365,30 @@ pub mod pallet { NoSubscription, /// The location is invalid since it already has a subscription from us. AlreadySubscribed, + /// Invalid asset for the operation. + InvalidAsset, + /// The owner does not own (all) of the asset that they wish to do the operation on. + LowBalance, + /// The asset owner has too many locks on the asset. + TooManyLocks, + /// The given account is not an identifiable sovereign account for any location. + AccountNotSovereign, + /// The operation required fees to be paid which the initiator could not meet. + FeesNotMet, + /// A remote lock with the corresponding data could not be found. + LockNotFound, + /// The unlock operation cannot succeed because there are still users of the lock. + InUse, + } + + impl From for Error { + fn from(e: SendError) -> Self { + match e { + SendError::Fees => Error::::FeesNotMet, + SendError::NotApplicable => Error::::Unreachable, + _ => Error::::SendFailure, + } + } } /// The status of a query. @@ -409,6 +519,37 @@ pub mod pallet { pub(super) type CurrentMigration = StorageValue<_, VersionMigrationStage, OptionQuery>; + #[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, TypeInfo, MaxEncodedLen)] + pub struct RemoteLockedFungibleRecord { + pub amount: u128, + pub owner: VersionedMultiLocation, + pub locker: VersionedMultiLocation, + pub users: u32, + } + + /// Fungible assets which we know are locked on a remote chain. + #[pallet::storage] + pub(super) type RemoteLockedFungibles = StorageNMap< + _, + ( + NMapKey, + NMapKey, + NMapKey, + ), + RemoteLockedFungibleRecord, + OptionQuery, + >; + + /// Fungible assets which we know are locked on this chain. + #[pallet::storage] + pub(super) type LockedFungibles = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + BoundedVec<(BalanceOf, VersionedMultiLocation), T::MaxLockers>, + OptionQuery, + >; + #[pallet::genesis_config] pub struct GenesisConfig { /// The default version to encode outgoing XCM messages with. @@ -556,10 +697,7 @@ pub mod pallet { let dest = MultiLocation::try_from(*dest).map_err(|()| Error::::BadVersion)?; let message: Xcm<()> = (*message).try_into().map_err(|()| Error::::BadVersion)?; - Self::send_xcm(interior, dest.clone(), message.clone()).map_err(|e| match e { - SendError::NotApplicable => Error::::Unreachable, - _ => Error::::SendFailure, - })?; + Self::send_xcm(interior, dest.clone(), message.clone()).map_err(Error::::from)?; Self::deposit_event(Event::Sent(origin_location, dest, message)); Ok(()) } @@ -861,758 +999,954 @@ pub mod pallet { ) } } +} - impl Pallet { - fn do_reserve_transfer_assets( - origin: OriginFor, - dest: Box, - beneficiary: Box, - assets: Box, - fee_asset_item: u32, - maybe_weight_limit: Option, - ) -> DispatchResult { - let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?; - let dest = (*dest).try_into().map_err(|()| Error::::BadVersion)?; - let beneficiary: MultiLocation = - (*beneficiary).try_into().map_err(|()| Error::::BadVersion)?; - let assets: MultiAssets = (*assets).try_into().map_err(|()| Error::::BadVersion)?; - - ensure!(assets.len() <= MAX_ASSETS_FOR_TRANSFER, Error::::TooManyAssets); - let value = (origin_location, assets.drain()); - ensure!(T::XcmReserveTransferFilter::contains(&value), Error::::Filtered); - let (origin_location, assets) = value; - let ancestry = T::LocationInverter::universal_location().into(); - let fees = assets - .get(fee_asset_item as usize) - .ok_or(Error::::Empty)? - .clone() - .reanchored(&dest, &ancestry) - .map_err(|_| Error::::CannotReanchor)?; - let max_assets = assets.len() as u32; - let assets: MultiAssets = assets.into(); - let weight_limit = match maybe_weight_limit { - Some(weight_limit) => weight_limit, - None => { - let beneficiary = beneficiary.clone(); - let fees = fees.clone(); - let mut remote_message = Xcm(vec![ - ReserveAssetDeposited(assets.clone()), - ClearOrigin, - BuyExecution { fees, weight_limit: Limited(0) }, - DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, - ]); - // use local weight for remote message and hope for the best. - let remote_weight = T::Weigher::weight(&mut remote_message) - .map_err(|()| Error::::UnweighableMessage)?; - Limited(remote_weight) - }, - }; - let xcm = Xcm(vec![ - BuyExecution { fees, weight_limit }, - DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, - ]); - let mut message = Xcm(vec![TransferReserveAsset { assets, dest, xcm }]); - let weight = - T::Weigher::weight(&mut message).map_err(|()| Error::::UnweighableMessage)?; - let outcome = - T::XcmExecutor::execute_xcm_in_credit(origin_location, message, weight, weight); - Self::deposit_event(Event::Attempted(outcome)); - Ok(()) - } - - fn do_teleport_assets( - origin: OriginFor, - dest: Box, - beneficiary: Box, - assets: Box, - fee_asset_item: u32, - maybe_weight_limit: Option, - ) -> DispatchResult { - let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?; - let dest = (*dest).try_into().map_err(|()| Error::::BadVersion)?; - let beneficiary: MultiLocation = - (*beneficiary).try_into().map_err(|()| Error::::BadVersion)?; - let assets: MultiAssets = (*assets).try_into().map_err(|()| Error::::BadVersion)?; - - ensure!(assets.len() <= MAX_ASSETS_FOR_TRANSFER, Error::::TooManyAssets); - let value = (origin_location, assets.drain()); - ensure!(T::XcmTeleportFilter::contains(&value), Error::::Filtered); - let (origin_location, assets) = value; - let ancestry = T::LocationInverter::universal_location().into(); - let fees = assets - .get(fee_asset_item as usize) - .ok_or(Error::::Empty)? - .clone() - .reanchored(&dest, &ancestry) - .map_err(|_| Error::::CannotReanchor)?; - let max_assets = assets.len() as u32; - let assets: MultiAssets = assets.into(); - let weight_limit = match maybe_weight_limit { - Some(weight_limit) => weight_limit, - None => { - let beneficiary = beneficiary.clone(); - let fees = fees.clone(); - let mut remote_message = Xcm(vec![ - ReceiveTeleportedAsset(assets.clone()), - ClearOrigin, - BuyExecution { fees, weight_limit: Limited(0) }, - DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, - ]); - // use local weight for remote message and hope for the best. - let remote_weight = T::Weigher::weight(&mut remote_message) - .map_err(|()| Error::::UnweighableMessage)?; - Limited(remote_weight) - }, - }; - let xcm = Xcm(vec![ - BuyExecution { fees, weight_limit }, - DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, - ]); - let mut message = - Xcm(vec![WithdrawAsset(assets), InitiateTeleport { assets: Wild(All), dest, xcm }]); - let weight = - T::Weigher::weight(&mut message).map_err(|()| Error::::UnweighableMessage)?; - let outcome = - T::XcmExecutor::execute_xcm_in_credit(origin_location, message, weight, weight); - Self::deposit_event(Event::Attempted(outcome)); - Ok(()) - } +/// The maximum number of distinct assets allowed to be transferred in a single helper extrinsic. +const MAX_ASSETS_FOR_TRANSFER: usize = 2; + +impl Pallet { + fn do_reserve_transfer_assets( + origin: OriginFor, + dest: Box, + beneficiary: Box, + assets: Box, + fee_asset_item: u32, + maybe_weight_limit: Option, + ) -> DispatchResult { + let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let dest = (*dest).try_into().map_err(|()| Error::::BadVersion)?; + let beneficiary: MultiLocation = + (*beneficiary).try_into().map_err(|()| Error::::BadVersion)?; + let assets: MultiAssets = (*assets).try_into().map_err(|()| Error::::BadVersion)?; + + ensure!(assets.len() <= MAX_ASSETS_FOR_TRANSFER, Error::::TooManyAssets); + let value = (origin_location, assets.into_inner()); + ensure!(T::XcmReserveTransferFilter::contains(&value), Error::::Filtered); + let (origin_location, assets) = value; + let ancestry = T::LocationInverter::universal_location().into(); + let fees = assets + .get(fee_asset_item as usize) + .ok_or(Error::::Empty)? + .clone() + .reanchored(&dest, &ancestry) + .map_err(|_| Error::::CannotReanchor)?; + let max_assets = assets.len() as u32; + let assets: MultiAssets = assets.into(); + let weight_limit = match maybe_weight_limit { + Some(weight_limit) => weight_limit, + None => { + let beneficiary = beneficiary.clone(); + let fees = fees.clone(); + let mut remote_message = Xcm(vec![ + ReserveAssetDeposited(assets.clone()), + ClearOrigin, + BuyExecution { fees, weight_limit: Limited(0) }, + DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, + ]); + // use local weight for remote message and hope for the best. + let remote_weight = T::Weigher::weight(&mut remote_message) + .map_err(|()| Error::::UnweighableMessage)?; + Limited(remote_weight) + }, + }; + let xcm = Xcm(vec![ + BuyExecution { fees, weight_limit }, + DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, + ]); + let mut message = Xcm(vec![TransferReserveAsset { assets, dest, xcm }]); + let weight = + T::Weigher::weight(&mut message).map_err(|()| Error::::UnweighableMessage)?; + let outcome = + T::XcmExecutor::execute_xcm_in_credit(origin_location, message, weight, weight); + Self::deposit_event(Event::Attempted(outcome)); + Ok(()) + } - /// Will always make progress, and will do its best not to use much more than `weight_cutoff` - /// in doing so. - pub(crate) fn check_xcm_version_change( - mut stage: VersionMigrationStage, - weight_cutoff: Weight, - ) -> (Weight, Option) { - let mut weight_used = 0; + fn do_teleport_assets( + origin: OriginFor, + dest: Box, + beneficiary: Box, + assets: Box, + fee_asset_item: u32, + maybe_weight_limit: Option, + ) -> DispatchResult { + let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let dest = (*dest).try_into().map_err(|()| Error::::BadVersion)?; + let beneficiary: MultiLocation = + (*beneficiary).try_into().map_err(|()| Error::::BadVersion)?; + let assets: MultiAssets = (*assets).try_into().map_err(|()| Error::::BadVersion)?; + + ensure!(assets.len() <= MAX_ASSETS_FOR_TRANSFER, Error::::TooManyAssets); + let value = (origin_location, assets.into_inner()); + ensure!(T::XcmTeleportFilter::contains(&value), Error::::Filtered); + let (origin_location, assets) = value; + let ancestry = T::LocationInverter::universal_location().into(); + let fees = assets + .get(fee_asset_item as usize) + .ok_or(Error::::Empty)? + .clone() + .reanchored(&dest, &ancestry) + .map_err(|_| Error::::CannotReanchor)?; + let max_assets = assets.len() as u32; + let assets: MultiAssets = assets.into(); + let weight_limit = match maybe_weight_limit { + Some(weight_limit) => weight_limit, + None => { + let beneficiary = beneficiary.clone(); + let fees = fees.clone(); + let mut remote_message = Xcm(vec![ + ReceiveTeleportedAsset(assets.clone()), + ClearOrigin, + BuyExecution { fees, weight_limit: Limited(0) }, + DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, + ]); + // use local weight for remote message and hope for the best. + let remote_weight = T::Weigher::weight(&mut remote_message) + .map_err(|()| Error::::UnweighableMessage)?; + Limited(remote_weight) + }, + }; + let xcm = Xcm(vec![ + BuyExecution { fees, weight_limit }, + DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, + ]); + let mut message = + Xcm(vec![WithdrawAsset(assets), InitiateTeleport { assets: Wild(All), dest, xcm }]); + let weight = + T::Weigher::weight(&mut message).map_err(|()| Error::::UnweighableMessage)?; + let outcome = + T::XcmExecutor::execute_xcm_in_credit(origin_location, message, weight, weight); + Self::deposit_event(Event::Attempted(outcome)); + Ok(()) + } - // TODO: Correct weights for the components of this: - let todo_sv_migrate_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write; - let todo_vn_migrate_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write; - let todo_vnt_already_notified_weight: Weight = T::DbWeight::get().read; - let todo_vnt_notify_weight: Weight = - T::DbWeight::get().read + T::DbWeight::get().write * 3; - let todo_vnt_migrate_weight: Weight = - T::DbWeight::get().read + T::DbWeight::get().write; - let todo_vnt_migrate_fail_weight: Weight = - T::DbWeight::get().read + T::DbWeight::get().write; - let todo_vnt_notify_migrate_weight: Weight = - T::DbWeight::get().read + T::DbWeight::get().write * 3; - - use VersionMigrationStage::*; - - if stage == MigrateSupportedVersion { - // We assume that supported XCM version only ever increases, so just cycle through lower - // XCM versioned from the current. - for v in 0..XCM_VERSION { - for (old_key, value) in SupportedVersion::::drain_prefix(v) { - if let Ok(new_key) = old_key.into_latest() { - SupportedVersion::::insert(XCM_VERSION, new_key, value); - } - weight_used.saturating_accrue(todo_sv_migrate_weight); - if weight_used >= weight_cutoff { - return (weight_used, Some(stage)) - } + /// Will always make progress, and will do its best not to use much more than `weight_cutoff` + /// in doing so. + pub(crate) fn check_xcm_version_change( + mut stage: VersionMigrationStage, + weight_cutoff: Weight, + ) -> (Weight, Option) { + let mut weight_used = 0; + + // TODO: Correct weights for the components of this: + let todo_sv_migrate_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write; + let todo_vn_migrate_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write; + let todo_vnt_already_notified_weight: Weight = T::DbWeight::get().read; + let todo_vnt_notify_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write * 3; + let todo_vnt_migrate_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write; + let todo_vnt_migrate_fail_weight: Weight = + T::DbWeight::get().read + T::DbWeight::get().write; + let todo_vnt_notify_migrate_weight: Weight = + T::DbWeight::get().read + T::DbWeight::get().write * 3; + + use VersionMigrationStage::*; + + if stage == MigrateSupportedVersion { + // We assume that supported XCM version only ever increases, so just cycle through lower + // XCM versioned from the current. + for v in 0..XCM_VERSION { + for (old_key, value) in SupportedVersion::::drain_prefix(v) { + if let Ok(new_key) = old_key.into_latest() { + SupportedVersion::::insert(XCM_VERSION, new_key, value); + } + weight_used.saturating_accrue(todo_sv_migrate_weight); + if weight_used >= weight_cutoff { + return (weight_used, Some(stage)) } } - stage = MigrateVersionNotifiers; } - if stage == MigrateVersionNotifiers { - for v in 0..XCM_VERSION { - for (old_key, value) in VersionNotifiers::::drain_prefix(v) { - if let Ok(new_key) = old_key.into_latest() { - VersionNotifiers::::insert(XCM_VERSION, new_key, value); - } - weight_used.saturating_accrue(todo_vn_migrate_weight); - if weight_used >= weight_cutoff { - return (weight_used, Some(stage)) - } + stage = MigrateVersionNotifiers; + } + if stage == MigrateVersionNotifiers { + for v in 0..XCM_VERSION { + for (old_key, value) in VersionNotifiers::::drain_prefix(v) { + if let Ok(new_key) = old_key.into_latest() { + VersionNotifiers::::insert(XCM_VERSION, new_key, value); + } + weight_used.saturating_accrue(todo_vn_migrate_weight); + if weight_used >= weight_cutoff { + return (weight_used, Some(stage)) } } - stage = NotifyCurrentTargets(None); } + stage = NotifyCurrentTargets(None); + } - let xcm_version = T::AdvertisedXcmVersion::get(); + let xcm_version = T::AdvertisedXcmVersion::get(); - if let NotifyCurrentTargets(maybe_last_raw_key) = stage { - let mut iter = match maybe_last_raw_key { - Some(k) => VersionNotifyTargets::::iter_prefix_from(XCM_VERSION, k), - None => VersionNotifyTargets::::iter_prefix(XCM_VERSION), + if let NotifyCurrentTargets(maybe_last_raw_key) = stage { + let mut iter = match maybe_last_raw_key { + Some(k) => VersionNotifyTargets::::iter_prefix_from(XCM_VERSION, k), + None => VersionNotifyTargets::::iter_prefix(XCM_VERSION), + }; + while let Some((key, value)) = iter.next() { + let (query_id, max_weight, target_xcm_version) = value; + let new_key: MultiLocation = match key.clone().try_into() { + Ok(k) if target_xcm_version != xcm_version => k, + _ => { + // We don't early return here since we need to be certain that we + // make some progress. + weight_used.saturating_accrue(todo_vnt_already_notified_weight); + continue + }, }; - while let Some((key, value)) = iter.next() { + let response = Response::Version(xcm_version); + let message = + Xcm(vec![QueryResponse { query_id, response, max_weight, querier: None }]); + let event = match send_xcm::(new_key.clone(), message) { + Ok(cost) => { + let value = (query_id, max_weight, xcm_version); + VersionNotifyTargets::::insert(XCM_VERSION, key, value); + Event::VersionChangeNotified(new_key, xcm_version, cost) + }, + Err(e) => { + VersionNotifyTargets::::remove(XCM_VERSION, key); + Event::NotifyTargetSendFail(new_key, query_id, e.into()) + }, + }; + Self::deposit_event(event); + weight_used.saturating_accrue(todo_vnt_notify_weight); + if weight_used >= weight_cutoff { + let last = Some(iter.last_raw_key().into()); + return (weight_used, Some(NotifyCurrentTargets(last))) + } + } + stage = MigrateAndNotifyOldTargets; + } + if stage == MigrateAndNotifyOldTargets { + for v in 0..XCM_VERSION { + for (old_key, value) in VersionNotifyTargets::::drain_prefix(v) { let (query_id, max_weight, target_xcm_version) = value; - let new_key: MultiLocation = match key.clone().try_into() { - Ok(k) if target_xcm_version != xcm_version => k, - _ => { - // We don't early return here since we need to be certain that we - // make some progress. - weight_used.saturating_accrue(todo_vnt_already_notified_weight); + let new_key = match MultiLocation::try_from(old_key.clone()) { + Ok(k) => k, + Err(()) => { + Self::deposit_event(Event::NotifyTargetMigrationFail(old_key, value.0)); + weight_used.saturating_accrue(todo_vnt_migrate_fail_weight); + if weight_used >= weight_cutoff { + return (weight_used, Some(stage)) + } continue }, }; - let response = Response::Version(xcm_version); - let message = - Xcm(vec![QueryResponse { query_id, response, max_weight, querier: None }]); - let event = match send_xcm::(new_key.clone(), message) { - Ok(_cost) => { - // TODO: consider charging for cost. - let value = (query_id, max_weight, xcm_version); - VersionNotifyTargets::::insert(XCM_VERSION, key, value); - Event::VersionChangeNotified(new_key, xcm_version) - }, - Err(e) => { - VersionNotifyTargets::::remove(XCM_VERSION, key); - Event::NotifyTargetSendFail(new_key, query_id, e.into()) - }, - }; - Self::deposit_event(event); - weight_used.saturating_accrue(todo_vnt_notify_weight); - if weight_used >= weight_cutoff { - let last = Some(iter.last_raw_key().into()); - return (weight_used, Some(NotifyCurrentTargets(last))) - } - } - stage = MigrateAndNotifyOldTargets; - } - if stage == MigrateAndNotifyOldTargets { - for v in 0..XCM_VERSION { - for (old_key, value) in VersionNotifyTargets::::drain_prefix(v) { - let (query_id, max_weight, target_xcm_version) = value; - let new_key = match MultiLocation::try_from(old_key.clone()) { - Ok(k) => k, - Err(()) => { - Self::deposit_event(Event::NotifyTargetMigrationFail( - old_key, value.0, - )); - weight_used.saturating_accrue(todo_vnt_migrate_fail_weight); - if weight_used >= weight_cutoff { - return (weight_used, Some(stage)) - } - continue + + let versioned_key = LatestVersionedMultiLocation(&new_key); + if target_xcm_version == xcm_version { + VersionNotifyTargets::::insert(XCM_VERSION, versioned_key, value); + weight_used.saturating_accrue(todo_vnt_migrate_weight); + } else { + // Need to notify target. + let response = Response::Version(xcm_version); + let message = Xcm(vec![QueryResponse { + query_id, + response, + max_weight, + querier: None, + }]); + let event = match send_xcm::(new_key.clone(), message) { + Ok(cost) => { + VersionNotifyTargets::::insert( + XCM_VERSION, + versioned_key, + (query_id, max_weight, xcm_version), + ); + Event::VersionChangeNotified(new_key, xcm_version, cost) }, + Err(e) => Event::NotifyTargetSendFail(new_key, query_id, e.into()), }; - - let versioned_key = LatestVersionedMultiLocation(&new_key); - if target_xcm_version == xcm_version { - VersionNotifyTargets::::insert(XCM_VERSION, versioned_key, value); - weight_used.saturating_accrue(todo_vnt_migrate_weight); - } else { - // Need to notify target. - let response = Response::Version(xcm_version); - let message = Xcm(vec![QueryResponse { - query_id, - response, - max_weight, - querier: None, - }]); - let event = match send_xcm::(new_key.clone(), message) { - Ok(_cost) => { - // TODO: consider accounting for cost. - VersionNotifyTargets::::insert( - XCM_VERSION, - versioned_key, - (query_id, max_weight, xcm_version), - ); - Event::VersionChangeNotified(new_key, xcm_version) - }, - Err(e) => Event::NotifyTargetSendFail(new_key, query_id, e.into()), - }; - Self::deposit_event(event); - weight_used.saturating_accrue(todo_vnt_notify_migrate_weight); - } - if weight_used >= weight_cutoff { - return (weight_used, Some(stage)) - } + Self::deposit_event(event); + weight_used.saturating_accrue(todo_vnt_notify_migrate_weight); + } + if weight_used >= weight_cutoff { + return (weight_used, Some(stage)) } } } - (weight_used, None) } + (weight_used, None) + } - /// Request that `dest` informs us of its version. - pub fn request_version_notify(dest: impl Into) -> XcmResult { - let dest = dest.into(); - let versioned_dest = VersionedMultiLocation::from(dest.clone()); - let already = VersionNotifiers::::contains_key(XCM_VERSION, &versioned_dest); - ensure!(!already, XcmError::InvalidLocation); - let query_id = QueryCounter::::mutate(|q| { - let r = *q; - q.saturating_inc(); - r - }); - // TODO #3735: Correct weight. - let instruction = SubscribeVersion { query_id, max_response_weight: 0 }; - send_xcm::(dest, Xcm(vec![instruction]))?; - VersionNotifiers::::insert(XCM_VERSION, &versioned_dest, query_id); - let query_status = - QueryStatus::VersionNotifier { origin: versioned_dest, is_active: false }; - Queries::::insert(query_id, query_status); - Ok(()) - } + /// Request that `dest` informs us of its version. + pub fn request_version_notify(dest: impl Into) -> XcmResult { + let dest = dest.into(); + let versioned_dest = VersionedMultiLocation::from(dest.clone()); + let already = VersionNotifiers::::contains_key(XCM_VERSION, &versioned_dest); + ensure!(!already, XcmError::InvalidLocation); + let query_id = QueryCounter::::mutate(|q| { + let r = *q; + q.saturating_inc(); + r + }); + // TODO #3735: Correct weight. + let instruction = SubscribeVersion { query_id, max_response_weight: 0 }; + let cost = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; + Self::deposit_event(Event::VersionNotifyRequested(dest, cost)); + VersionNotifiers::::insert(XCM_VERSION, &versioned_dest, query_id); + let query_status = + QueryStatus::VersionNotifier { origin: versioned_dest, is_active: false }; + Queries::::insert(query_id, query_status); + Ok(()) + } - /// Request that `dest` ceases informing us of its version. - pub fn unrequest_version_notify(dest: impl Into) -> XcmResult { - let dest = dest.into(); - let versioned_dest = LatestVersionedMultiLocation(&dest); - let query_id = VersionNotifiers::::take(XCM_VERSION, versioned_dest) - .ok_or(XcmError::InvalidLocation)?; - send_xcm::(dest.clone(), Xcm(vec![UnsubscribeVersion]))?; - Queries::::remove(query_id); - Ok(()) - } + /// Request that `dest` ceases informing us of its version. + pub fn unrequest_version_notify(dest: impl Into) -> XcmResult { + let dest = dest.into(); + let versioned_dest = LatestVersionedMultiLocation(&dest); + let query_id = VersionNotifiers::::take(XCM_VERSION, versioned_dest) + .ok_or(XcmError::InvalidLocation)?; + let cost = send_xcm::(dest.clone(), Xcm(vec![UnsubscribeVersion]))?; + Self::deposit_event(Event::VersionNotifyUnrequested(dest, cost)); + Queries::::remove(query_id); + Ok(()) + } - /// Relay an XCM `message` from a given `interior` location in this context to a given `dest` - /// location. A `dest` of `Here` is not handled. The overall price of the delivery is - /// returned. - pub fn send_xcm( - interior: impl Into, - dest: impl Into, - mut message: Xcm<()>, - ) -> Result { - let interior = interior.into(); - let dest = dest.into(); - if interior != Junctions::Here { - message.0.insert(0, DescendOrigin(interior)) - }; - log::trace!(target: "xcm::send_xcm", "dest: {:?}, message: {:?}", &dest, &message); - send_xcm::(dest, message) + /// Relay an XCM `message` from a given `interior` location in this context to a given `dest` + /// location. The `fee_payer` is charged for the delivery unless `None` in which case fees + /// are not charged (and instead borne by the chain). + pub fn send_xcm( + interior: impl Into, + dest: impl Into, + mut message: Xcm<()>, + ) -> Result<(), SendError> { + let interior = interior.into(); + let dest = dest.into(); + let maybe_fee_payer = if interior != Junctions::Here { + message.0.insert(0, DescendOrigin(interior.clone())); + Some(interior.into()) + } else { + None + }; + log::trace!(target: "xcm::send_xcm", "dest: {:?}, message: {:?}", &dest, &message); + let (ticket, price) = validate_send::(dest, message)?; + if let Some(fee_payer) = maybe_fee_payer { + Self::charge_fees(fee_payer, price).map_err(|_| SendError::Fees)?; } + T::XcmRouter::deliver(ticket)?; + Ok(()) + } - pub fn check_account() -> T::AccountId { - const ID: PalletId = PalletId(*b"py/xcmch"); - AccountIdConversion::::into_account(&ID) - } + pub fn check_account() -> T::AccountId { + const ID: PalletId = PalletId(*b"py/xcmch"); + AccountIdConversion::::into_account(&ID) + } - /// Create a new expectation of a query response with the querier being here. - fn do_new_query( - responder: impl Into, - maybe_notify: Option<(u8, u8)>, - timeout: T::BlockNumber, - match_querier: impl Into, - ) -> u64 { - QueryCounter::::mutate(|q| { - let r = *q; - q.saturating_inc(); - Queries::::insert( - r, - QueryStatus::Pending { - responder: responder.into().into(), - maybe_match_querier: Some(match_querier.into().into()), - maybe_notify, - timeout, - }, - ); - r - }) - } + /// Create a new expectation of a query response with the querier being here. + fn do_new_query( + responder: impl Into, + maybe_notify: Option<(u8, u8)>, + timeout: T::BlockNumber, + match_querier: impl Into, + ) -> u64 { + QueryCounter::::mutate(|q| { + let r = *q; + q.saturating_inc(); + Queries::::insert( + r, + QueryStatus::Pending { + responder: responder.into().into(), + maybe_match_querier: Some(match_querier.into().into()), + maybe_notify, + timeout, + }, + ); + r + }) + } - /// 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::LocationInverter::invert_location(&responder) - .map_err(|()| XcmError::MultiLocationNotInvertible)?; - let query_id = Self::new_query(responder, timeout, Here); - let response_info = QueryResponseInfo { destination, query_id, max_weight: 0 }; - 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. + /// + /// - `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::LocationInverter::invert_location(&responder) + .map_err(|()| XcmError::MultiLocationNotInvertible)?; + let query_id = Self::new_query(responder, timeout, Here); + let response_info = QueryResponseInfo { destination, query_id, max_weight: 0 }; + 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. - /// - /// - `message`: The message whose outcome should be reported. - /// - `responder`: The origin from which a response should be expected. - /// - `notify`: A dispatchable function which will be called once the outcome of `message` - /// is known. It may be a dispatchable in any pallet of the local chain, but other than - /// the usual origin, it must accept exactly two arguments: `query_id: QueryId` and - /// `outcome: Response`, and in that order. It should expect that the origin is - /// `Origin::Response` and will contain the responder's location. - /// - `timeout`: The block number after which it is permissible for `notify` not to be - /// called even if a response is received. - /// - /// `report_outcome_notify` may return an error if the `responder` is not invertible. - /// - /// It is assumed that the querier of the response will be `Here`. - /// - /// NOTE: `notify` gets called as part of handling an incoming message, so it should be - /// lightweight. Its weight is estimated during this function and stored ready for - /// weighing `ReportOutcome` on the way back. If it turns out to be heavier once it returns - /// then reporting the outcome will fail. Futhermore if the estimate is too high, then it - /// may be put in the overweight queue and need to be manually executed. - pub fn report_outcome_notify( - message: &mut Xcm<()>, - responder: impl Into, - notify: impl Into<::Call>, - timeout: T::BlockNumber, - ) -> Result<(), XcmError> { - let responder = responder.into(); - let destination = T::LocationInverter::invert_location(&responder) - .map_err(|()| XcmError::MultiLocationNotInvertible)?; - let notify: ::Call = notify.into(); - let max_weight = notify.get_dispatch_info().weight; - let query_id = Self::new_notify_query(responder, notify, timeout, Here); - let response_info = QueryResponseInfo { destination, query_id, max_weight }; - let report_error = Xcm(vec![ReportError(response_info)]); - message.0.insert(0, SetAppendix(report_error)); - Ok(()) - } + /// Consume `message` and return another which is equivalent to it except that it reports + /// back the outcome and dispatches `notify` on this chain. + /// + /// - `message`: The message whose outcome should be reported. + /// - `responder`: The origin from which a response should be expected. + /// - `notify`: A dispatchable function which will be called once the outcome of `message` + /// is known. It may be a dispatchable in any pallet of the local chain, but other than + /// the usual origin, it must accept exactly two arguments: `query_id: QueryId` and + /// `outcome: Response`, and in that order. It should expect that the origin is + /// `Origin::Response` and will contain the responder's location. + /// - `timeout`: The block number after which it is permissible for `notify` not to be + /// called even if a response is received. + /// + /// `report_outcome_notify` may return an error if the `responder` is not invertible. + /// + /// It is assumed that the querier of the response will be `Here`. + /// + /// NOTE: `notify` gets called as part of handling an incoming message, so it should be + /// lightweight. Its weight is estimated during this function and stored ready for + /// weighing `ReportOutcome` on the way back. If it turns out to be heavier once it returns + /// then reporting the outcome will fail. Futhermore if the estimate is too high, then it + /// may be put in the overweight queue and need to be manually executed. + pub fn report_outcome_notify( + message: &mut Xcm<()>, + responder: impl Into, + notify: impl Into<::Call>, + timeout: T::BlockNumber, + ) -> Result<(), XcmError> { + let responder = responder.into(); + let destination = T::LocationInverter::invert_location(&responder) + .map_err(|()| XcmError::MultiLocationNotInvertible)?; + let notify: ::Call = notify.into(); + let max_weight = notify.get_dispatch_info().weight; + let query_id = Self::new_notify_query(responder, notify, timeout, Here); + let response_info = QueryResponseInfo { destination, query_id, max_weight }; + let report_error = Xcm(vec![ReportError(response_info)]); + message.0.insert(0, SetAppendix(report_error)); + 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. + 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( - responder: impl Into, - notify: impl Into<::Call>, - timeout: T::BlockNumber, - match_querier: impl Into, - ) -> u64 { - let notify = - notify.into().using_encoded(|mut bytes| Decode::decode(&mut bytes)).expect( - "decode input is output of Call encode; Call guaranteed to have two enums; qed", - ); - Self::do_new_query(responder, Some(notify), 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( + responder: impl Into, + notify: impl Into<::Call>, + timeout: T::BlockNumber, + match_querier: impl Into, + ) -> u64 { + let notify = notify.into().using_encoded(|mut bytes| Decode::decode(&mut bytes)).expect( + "decode input is output of Call encode; Call guaranteed to have two enums; qed", + ); + 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 } + } - /// 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)) + /// 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) { + log::trace!( + target: "xcm::pallet_xcm::note_unknown_version", + "XCM version is unknown for destination: {:?}", + dest, + ); + let versioned_dest = VersionedMultiLocation::from(dest.clone()); + VersionDiscoveryQueue::::mutate(|q| { + if let Some(index) = q.iter().position(|i| &i.0 == &versioned_dest) { + // exists - just bump the count. + q[index].1.saturating_inc(); } else { - None + let _ = q.try_push((versioned_dest, 1)); } + }); + } + + /// Withdraw given `assets` from the given `location` and pay as XCM fees. + /// + /// Fails if: + /// - the `assets` are not known on this chain; + /// - the `assets` cannot be withdrawn with that location as the Origin. + fn charge_fees(location: MultiLocation, assets: MultiAssets) -> DispatchResult { + T::XcmExecutor::charge_fees(location.clone(), assets.clone()) + .map_err(|_| Error::::FeesNotMet)?; + Self::deposit_event(Event::FeesPaid(location, assets)); + Ok(()) + } +} + +pub struct LockTicket { + sovereign_account: T::AccountId, + amount: BalanceOf, + unlocker: MultiLocation, + item_index: Option, +} + +impl xcm_executor::traits::Enact for LockTicket { + fn enact(self) -> Result<(), xcm_executor::traits::LockError> { + use xcm_executor::traits::LockError::UnexpectedState; + let mut locks = LockedFungibles::::get(&self.sovereign_account).unwrap_or_default(); + match self.item_index { + Some(index) => { + ensure!(locks.len() > index, UnexpectedState); + ensure!(locks[index].1.try_as::<_>() == Ok(&self.unlocker), UnexpectedState); + locks[index].0 = locks[index].0.max(self.amount); + }, + None => { + locks + .try_push((self.amount, self.unlocker.clone().into())) + .map_err(|()| UnexpectedState)?; + }, } + LockedFungibles::::insert(&self.sovereign_account, locks); + T::Currency::extend_lock( + *b"py/xcmlk", + &self.sovereign_account, + self.amount, + WithdrawReasons::all(), + ); + Ok(()) + } +} - /// 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) { - log::trace!( - target: "xcm::pallet_xcm::note_unknown_version", - "XCM version is unknown for destination: {:?}", - dest, - ); - let versioned_dest = VersionedMultiLocation::from(dest.clone()); - VersionDiscoveryQueue::::mutate(|q| { - if let Some(index) = q.iter().position(|i| &i.0 == &versioned_dest) { - // exists - just bump the count. - q[index].1.saturating_inc(); - } else { - let _ = q.try_push((versioned_dest, 1)); +pub struct UnlockTicket { + sovereign_account: T::AccountId, + amount: BalanceOf, + unlocker: MultiLocation, +} + +impl xcm_executor::traits::Enact for UnlockTicket { + fn enact(self) -> Result<(), xcm_executor::traits::LockError> { + use xcm_executor::traits::LockError::UnexpectedState; + let mut locks = + LockedFungibles::::get(&self.sovereign_account).ok_or(UnexpectedState)?; + let mut maybe_remove_index = None; + let mut locked = BalanceOf::::zero(); + let mut found = false; + // We could just as well do with with an into_iter, filter_map and collect, however this way + // avoids making an allocation. + for (i, x) in locks.iter_mut().enumerate() { + if x.1.try_as::<_>().defensive() == Ok(&self.unlocker) { + x.0 = x.0.saturating_sub(self.amount); + if x.0.is_zero() { + maybe_remove_index = Some(i); } - }); + found = true; + } + locked = locked.max(x.0); + } + ensure!(found, UnexpectedState); + if let Some(remove_index) = maybe_remove_index { + locks.swap_remove(remove_index); } + LockedFungibles::::insert(&self.sovereign_account, locks); + let reasons = WithdrawReasons::all(); + T::Currency::set_lock(*b"py/xcmlk", &self.sovereign_account, locked, reasons); + Ok(()) } +} - impl WrapVersion for Pallet { - fn wrap_version( - dest: &MultiLocation, - xcm: impl Into>, - ) -> Result, ()> { - SupportedVersion::::get(XCM_VERSION, LatestVersionedMultiLocation(dest)) - .or_else(|| { - Self::note_unknown_version(dest); - SafeXcmVersion::::get() - }) - .ok_or_else(|| { - log::trace!( - target: "xcm::pallet_xcm::wrap_version", - "Could not determine a version to wrap XCM for destination: {:?}", - dest, - ); - () - }) - .and_then(|v| xcm.into().into_version(v.min(XCM_VERSION))) +pub struct ReduceTicket { + key: (u32, T::AccountId, VersionedAssetId), + amount: u128, + locker: VersionedMultiLocation, + owner: VersionedMultiLocation, +} + +impl xcm_executor::traits::Enact for ReduceTicket { + fn enact(self) -> Result<(), xcm_executor::traits::LockError> { + use xcm_executor::traits::LockError::UnexpectedState; + let mut record = RemoteLockedFungibles::::get(&self.key).ok_or(UnexpectedState)?; + ensure!(self.locker == record.locker && self.owner == record.owner, UnexpectedState); + ensure!(record.users == 0, UnexpectedState); + record.amount = record.amount.checked_sub(self.amount).ok_or(UnexpectedState)?; + if record.amount == 0 { + RemoteLockedFungibles::::remove(&self.key); + } else { + RemoteLockedFungibles::::insert(&self.key, &record); } + Ok(()) } +} - impl VersionChangeNotifier for Pallet { - /// Start notifying `location` should the XCM version of this chain change. - /// - /// When it does, this type should ensure a `QueryResponse` message is sent with the given - /// `query_id` & `max_weight` and with a `response` of `Response::Version`. This should happen - /// until/unless `stop` is called with the correct `query_id`. - /// - /// If the `location` has an ongoing notification and when this function is called, then an - /// error should be returned. - fn start(dest: &MultiLocation, query_id: QueryId, max_weight: u64) -> XcmResult { - let versioned_dest = LatestVersionedMultiLocation(dest); - let already = VersionNotifyTargets::::contains_key(XCM_VERSION, versioned_dest); - ensure!(!already, XcmError::InvalidLocation); - - let xcm_version = T::AdvertisedXcmVersion::get(); - let response = Response::Version(xcm_version); - let instruction = QueryResponse { query_id, response, max_weight, querier: None }; - send_xcm::(dest.clone(), Xcm(vec![instruction]))?; - - let value = (query_id, max_weight, xcm_version); - VersionNotifyTargets::::insert(XCM_VERSION, versioned_dest, value); - Ok(()) - } +impl xcm_executor::traits::AssetLock for Pallet { + type LockTicket = LockTicket; + type UnlockTicket = UnlockTicket; + type ReduceTicket = ReduceTicket; + + fn prepare_lock( + unlocker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result, xcm_executor::traits::LockError> { + use xcm_executor::traits::LockError::*; + let sovereign_account = T::SovereignAccountOf::convert_ref(&owner).map_err(|_| BadOwner)?; + let amount = T::CurrencyMatcher::matches_fungible(&asset).ok_or(UnknownAsset)?; + ensure!(T::Currency::free_balance(&sovereign_account) >= amount, AssetNotOwned); + let locks = LockedFungibles::::get(&sovereign_account).unwrap_or_default(); + let item_index = locks.iter().position(|x| x.1.try_as::<_>() == Ok(&unlocker)); + ensure!(item_index.is_some() || locks.len() < T::MaxLockers::get() as usize, NoResources); + Ok(LockTicket { sovereign_account, amount, unlocker, item_index }) + } - /// Stop notifying `location` should the XCM change. This is a no-op if there was never a - /// subscription. - fn stop(dest: &MultiLocation) -> XcmResult { - VersionNotifyTargets::::remove(XCM_VERSION, LatestVersionedMultiLocation(dest)); - Ok(()) - } + fn prepare_unlock( + unlocker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result, xcm_executor::traits::LockError> { + use xcm_executor::traits::LockError::*; + let sovereign_account = T::SovereignAccountOf::convert_ref(&owner).map_err(|_| BadOwner)?; + let amount = T::CurrencyMatcher::matches_fungible(&asset).ok_or(UnknownAsset)?; + ensure!(T::Currency::free_balance(&sovereign_account) >= amount, AssetNotOwned); + let locks = LockedFungibles::::get(&sovereign_account).unwrap_or_default(); + let item_index = + locks.iter().position(|x| x.1.try_as::<_>() == Ok(&unlocker)).ok_or(NotLocked)?; + ensure!(locks[item_index].0 >= amount, NotLocked); + Ok(UnlockTicket { sovereign_account, amount, unlocker }) + } - /// Return true if a location is subscribed to XCM version changes. - fn is_subscribed(dest: &MultiLocation) -> bool { - let versioned_dest = LatestVersionedMultiLocation(dest); - VersionNotifyTargets::::contains_key(XCM_VERSION, versioned_dest) + fn note_unlockable( + locker: MultiLocation, + asset: MultiAsset, + mut owner: MultiLocation, + ) -> Result<(), xcm_executor::traits::LockError> { + use xcm_executor::traits::LockError::*; + ensure!(T::TrustedLockers::contains(&locker, &asset), NotTrusted); + let amount = match asset.fun { + Fungible(a) => a, + NonFungible(_) => return Err(Unimplemented), + }; + owner.remove_network_id(); + let account = T::SovereignAccountOf::convert_ref(&owner).map_err(|_| BadOwner)?; + let locker = locker.into(); + let owner = owner.into(); + let id: VersionedAssetId = asset.id.into(); + let key = (XCM_VERSION, account, id); + let mut record = RemoteLockedFungibleRecord { amount, owner, locker, users: 0 }; + if let Some(old) = RemoteLockedFungibles::::get(&key) { + // Make sure that the new record wouldn't clobber any old data. + ensure!(old.locker == record.locker && old.owner == record.owner, WouldClobber); + record.users = old.users; + record.amount = record.amount.max(old.amount); } + RemoteLockedFungibles::::insert(&key, record); + Ok(()) } - impl DropAssets for Pallet { - fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight { - if assets.is_empty() { - return 0 - } - let versioned = VersionedMultiAssets::from(MultiAssets::from(assets)); - let hash = BlakeTwo256::hash_of(&(&origin, &versioned)); - AssetTraps::::mutate(hash, |n| *n += 1); - Self::deposit_event(Event::AssetsTrapped(hash, origin.clone(), versioned)); - // TODO #3735: Put the real weight in there. - 0 + fn prepare_reduce_unlockable( + locker: MultiLocation, + asset: MultiAsset, + mut owner: MultiLocation, + ) -> Result { + use xcm_executor::traits::LockError::*; + let amount = match asset.fun { + Fungible(a) => a, + NonFungible(_) => return Err(Unimplemented), + }; + owner.remove_network_id(); + let sovereign_account = T::SovereignAccountOf::convert_ref(&owner).map_err(|_| BadOwner)?; + let locker = locker.into(); + let owner = owner.into(); + let id: VersionedAssetId = asset.id.into(); + let key = (XCM_VERSION, sovereign_account, id); + + let record = RemoteLockedFungibles::::get(&key).ok_or(NotLocked)?; + // Make sure that the record contains what we expect and there's enough to unlock. + ensure!(locker == record.locker && owner == record.owner, WouldClobber); + ensure!(record.users == 0, InUse); + ensure!(record.amount >= amount, NotEnoughLocked); + Ok(ReduceTicket { key, amount, locker, owner }) + } +} + +impl WrapVersion for Pallet { + fn wrap_version( + dest: &MultiLocation, + xcm: impl Into>, + ) -> Result, ()> { + SupportedVersion::::get(XCM_VERSION, LatestVersionedMultiLocation(dest)) + .or_else(|| { + Self::note_unknown_version(dest); + SafeXcmVersion::::get() + }) + .ok_or_else(|| { + log::trace!( + target: "xcm::pallet_xcm::wrap_version", + "Could not determine a version to wrap XCM for destination: {:?}", + dest, + ); + () + }) + .and_then(|v| xcm.into().into_version(v.min(XCM_VERSION))) + } +} + +impl VersionChangeNotifier for Pallet { + /// Start notifying `location` should the XCM version of this chain change. + /// + /// When it does, this type should ensure a `QueryResponse` message is sent with the given + /// `query_id` & `max_weight` and with a `response` of `Response::Version`. This should happen + /// until/unless `stop` is called with the correct `query_id`. + /// + /// If the `location` has an ongoing notification and when this function is called, then an + /// error should be returned. + fn start(dest: &MultiLocation, query_id: QueryId, max_weight: u64) -> XcmResult { + let versioned_dest = LatestVersionedMultiLocation(dest); + let already = VersionNotifyTargets::::contains_key(XCM_VERSION, versioned_dest); + ensure!(!already, XcmError::InvalidLocation); + + let xcm_version = T::AdvertisedXcmVersion::get(); + let response = Response::Version(xcm_version); + let instruction = QueryResponse { query_id, response, max_weight, querier: None }; + let cost = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; + Self::deposit_event(Event::::VersionNotifyStarted(dest.clone(), cost)); + + let value = (query_id, max_weight, xcm_version); + VersionNotifyTargets::::insert(XCM_VERSION, versioned_dest, value); + Ok(()) + } + + /// Stop notifying `location` should the XCM change. This is a no-op if there was never a + /// subscription. + fn stop(dest: &MultiLocation) -> XcmResult { + VersionNotifyTargets::::remove(XCM_VERSION, LatestVersionedMultiLocation(dest)); + Ok(()) + } + + /// Return true if a location is subscribed to XCM version changes. + fn is_subscribed(dest: &MultiLocation) -> bool { + let versioned_dest = LatestVersionedMultiLocation(dest); + VersionNotifyTargets::::contains_key(XCM_VERSION, versioned_dest) + } +} + +impl DropAssets for Pallet { + fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight { + if assets.is_empty() { + return 0 } + let versioned = VersionedMultiAssets::from(MultiAssets::from(assets)); + let hash = BlakeTwo256::hash_of(&(&origin, &versioned)); + AssetTraps::::mutate(hash, |n| *n += 1); + Self::deposit_event(Event::AssetsTrapped(hash, origin.clone(), versioned)); + // TODO #3735: Put the real weight in there. + 0 } +} - impl ClaimAssets for Pallet { - fn claim_assets( - origin: &MultiLocation, - ticket: &MultiLocation, - assets: &MultiAssets, - ) -> bool { - let mut versioned = VersionedMultiAssets::from(assets.clone()); - match (ticket.parents, &ticket.interior) { - (0, X1(GeneralIndex(i))) => - versioned = match versioned.into_version(*i as u32) { - Ok(v) => v, - Err(()) => return false, - }, - (0, Here) => (), - _ => return false, - }; - let hash = BlakeTwo256::hash_of(&(origin, versioned)); - match AssetTraps::::get(hash) { - 0 => return false, - 1 => AssetTraps::::remove(hash), - n => AssetTraps::::insert(hash, n - 1), - } - return true +impl ClaimAssets for Pallet { + fn claim_assets(origin: &MultiLocation, ticket: &MultiLocation, assets: &MultiAssets) -> bool { + let mut versioned = VersionedMultiAssets::from(assets.clone()); + match (ticket.parents, &ticket.interior) { + (0, X1(GeneralIndex(i))) => + versioned = match versioned.into_version(*i as u32) { + Ok(v) => v, + Err(()) => return false, + }, + (0, Here) => (), + _ => return false, + }; + let hash = BlakeTwo256::hash_of(&(origin, versioned)); + match AssetTraps::::get(hash) { + 0 => return false, + 1 => AssetTraps::::remove(hash), + n => AssetTraps::::insert(hash, n - 1), } + return true } +} - impl OnResponse for Pallet { - fn expecting_response( - origin: &MultiLocation, - query_id: QueryId, - querier: Option<&MultiLocation>, - ) -> bool { - match Queries::::get(query_id) { - Some(QueryStatus::Pending { responder, maybe_match_querier, .. }) => - MultiLocation::try_from(responder).map_or(false, |r| origin == &r) && - maybe_match_querier.map_or(true, |match_querier| { - MultiLocation::try_from(match_querier).map_or(false, |match_querier| { - querier.map_or(false, |q| q == &match_querier) - }) - }), - Some(QueryStatus::VersionNotifier { origin: r, .. }) => - MultiLocation::try_from(r).map_or(false, |r| origin == &r), - _ => false, - } +impl OnResponse for Pallet { + fn expecting_response( + origin: &MultiLocation, + query_id: QueryId, + querier: Option<&MultiLocation>, + ) -> bool { + match Queries::::get(query_id) { + Some(QueryStatus::Pending { responder, maybe_match_querier, .. }) => + MultiLocation::try_from(responder).map_or(false, |r| origin == &r) && + maybe_match_querier.map_or(true, |match_querier| { + MultiLocation::try_from(match_querier).map_or(false, |match_querier| { + querier.map_or(false, |q| q == &match_querier) + }) + }), + Some(QueryStatus::VersionNotifier { origin: r, .. }) => + MultiLocation::try_from(r).map_or(false, |r| origin == &r), + _ => false, } + } - fn on_response( - origin: &MultiLocation, - query_id: QueryId, - querier: Option<&MultiLocation>, - response: Response, - max_weight: Weight, - ) -> Weight { - match (response, Queries::::get(query_id)) { - ( - Response::Version(v), - Some(QueryStatus::VersionNotifier { origin: expected_origin, is_active }), - ) => { - let origin: MultiLocation = match expected_origin.try_into() { - Ok(o) if &o == origin => o, - Ok(o) => { - Self::deposit_event(Event::InvalidResponder( - origin.clone(), - query_id, - Some(o), - )); - return 0 - }, - _ => { - Self::deposit_event(Event::InvalidResponder( - origin.clone(), - query_id, - None, - )); - // TODO #3735: Correct weight for this. - return 0 - }, - }; - // TODO #3735: Check max_weight is correct. - if !is_active { - Queries::::insert( + fn on_response( + origin: &MultiLocation, + query_id: QueryId, + querier: Option<&MultiLocation>, + response: Response, + max_weight: Weight, + ) -> Weight { + match (response, Queries::::get(query_id)) { + ( + Response::Version(v), + Some(QueryStatus::VersionNotifier { origin: expected_origin, is_active }), + ) => { + let origin: MultiLocation = match expected_origin.try_into() { + Ok(o) if &o == origin => o, + Ok(o) => { + Self::deposit_event(Event::InvalidResponder( + origin.clone(), query_id, - QueryStatus::VersionNotifier { - origin: origin.clone().into(), - is_active: true, - }, - ); - } - // We're being notified of a version change. - SupportedVersion::::insert( - XCM_VERSION, - LatestVersionedMultiLocation(&origin), - v, + Some(o), + )); + return 0 + }, + _ => { + Self::deposit_event(Event::InvalidResponder( + origin.clone(), + query_id, + None, + )); + // TODO #3735: Correct weight for this. + return 0 + }, + }; + // TODO #3735: Check max_weight is correct. + if !is_active { + Queries::::insert( + query_id, + QueryStatus::VersionNotifier { + origin: origin.clone().into(), + is_active: true, + }, ); - Self::deposit_event(Event::SupportedVersionChanged(origin, v)); - 0 - }, - ( - response, - Some(QueryStatus::Pending { - responder, maybe_notify, maybe_match_querier, .. - }), - ) => { - if let Some(match_querier) = maybe_match_querier { - let match_querier = match MultiLocation::try_from(match_querier) { - Ok(mq) => mq, - Err(_) => { - Self::deposit_event(Event::InvalidQuerierVersion( - origin.clone(), - query_id, - )); - return 0 - }, - }; - if querier.map_or(true, |q| q != &match_querier) { - Self::deposit_event(Event::InvalidQuerier( - origin.clone(), - query_id, - match_querier, - querier.cloned(), - )); - return 0 - } - } - let responder = match MultiLocation::try_from(responder) { - Ok(r) => r, + } + // We're being notified of a version change. + SupportedVersion::::insert( + XCM_VERSION, + LatestVersionedMultiLocation(&origin), + v, + ); + Self::deposit_event(Event::SupportedVersionChanged(origin, v)); + 0 + }, + ( + response, + Some(QueryStatus::Pending { responder, maybe_notify, maybe_match_querier, .. }), + ) => { + if let Some(match_querier) = maybe_match_querier { + let match_querier = match MultiLocation::try_from(match_querier) { + Ok(mq) => mq, Err(_) => { - Self::deposit_event(Event::InvalidResponderVersion( + Self::deposit_event(Event::InvalidQuerierVersion( origin.clone(), query_id, )); return 0 }, }; - if origin != &responder { - Self::deposit_event(Event::InvalidResponder( + if querier.map_or(true, |q| q != &match_querier) { + Self::deposit_event(Event::InvalidQuerier( origin.clone(), query_id, - Some(responder), + match_querier, + querier.cloned(), )); return 0 } - return match maybe_notify { - Some((pallet_index, call_index)) => { - // This is a bit horrible, but we happen to know that the `Call` will - // be built by `(pallet_index: u8, call_index: u8, QueryId, Response)`. - // So we just encode that and then re-encode to a real Call. - let bare = (pallet_index, call_index, query_id, response); - if let Ok(call) = bare - .using_encoded(|mut bytes| ::Call::decode(&mut bytes)) - { - Queries::::remove(query_id); - let weight = call.get_dispatch_info().weight; - if weight > max_weight { - let e = Event::NotifyOverweight( + } + let responder = match MultiLocation::try_from(responder) { + Ok(r) => r, + Err(_) => { + Self::deposit_event(Event::InvalidResponderVersion( + origin.clone(), + query_id, + )); + return 0 + }, + }; + if origin != &responder { + Self::deposit_event(Event::InvalidResponder( + origin.clone(), + query_id, + Some(responder), + )); + return 0 + } + return match maybe_notify { + Some((pallet_index, call_index)) => { + // This is a bit horrible, but we happen to know that the `Call` will + // be built by `(pallet_index: u8, call_index: u8, QueryId, Response)`. + // So we just encode that and then re-encode to a real Call. + let bare = (pallet_index, call_index, query_id, response); + if let Ok(call) = + bare.using_encoded(|mut bytes| ::Call::decode(&mut bytes)) + { + Queries::::remove(query_id); + let weight = call.get_dispatch_info().weight; + if weight > max_weight { + let e = Event::NotifyOverweight( + query_id, + pallet_index, + call_index, + weight, + max_weight, + ); + Self::deposit_event(e); + return 0 + } + let dispatch_origin = Origin::Response(origin.clone()).into(); + match call.dispatch(dispatch_origin) { + Ok(post_info) => { + let e = Event::Notified(query_id, pallet_index, call_index); + Self::deposit_event(e); + post_info.actual_weight + }, + Err(error_and_info) => { + let e = Event::NotifyDispatchError( query_id, pallet_index, call_index, - weight, - max_weight, ); Self::deposit_event(e); - return 0 - } - let dispatch_origin = Origin::Response(origin.clone()).into(); - match call.dispatch(dispatch_origin) { - Ok(post_info) => { - let e = Event::Notified(query_id, pallet_index, call_index); - Self::deposit_event(e); - post_info.actual_weight - }, - Err(error_and_info) => { - let e = Event::NotifyDispatchError( - query_id, - pallet_index, - call_index, - ); - Self::deposit_event(e); - // Not much to do with the result as it is. It's up to the parachain to ensure that the - // message makes sense. - error_and_info.post_info.actual_weight - }, - } - .unwrap_or(weight) - } else { - let e = - Event::NotifyDecodeFailed(query_id, pallet_index, call_index); - Self::deposit_event(e); - 0 + // Not much to do with the result as it is. It's up to the parachain to ensure that the + // message makes sense. + error_and_info.post_info.actual_weight + }, } - }, - None => { - let e = Event::ResponseReady(query_id, response.clone()); + .unwrap_or(weight) + } else { + let e = Event::NotifyDecodeFailed(query_id, pallet_index, call_index); Self::deposit_event(e); - let at = frame_system::Pallet::::current_block_number(); - let response = response.into(); - Queries::::insert(query_id, QueryStatus::Ready { response, at }); 0 - }, - } - }, - _ => { - Self::deposit_event(Event::UnexpectedResponse(origin.clone(), query_id)); - return 0 - }, - } + } + }, + None => { + let e = Event::ResponseReady(query_id, response.clone()); + Self::deposit_event(e); + let at = frame_system::Pallet::::current_block_number(); + let response = response.into(); + Queries::::insert(query_id, QueryStatus::Ready { response, at }); + 0 + }, + } + }, + _ => { + Self::deposit_event(Event::UnexpectedResponse(origin.clone(), query_id)); + return 0 + }, } } } diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 7d91f50380b2..1c394fe963d3 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -288,6 +288,8 @@ impl xcm_executor::Config for XcmConfig { type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; @@ -318,6 +320,11 @@ impl pallet_xcm::Config for Test { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = AdvertisedXcmVersion; + type TrustedLockers = (); + type SovereignAccountOf = AccountId32Aliases<(), AccountId32>; + type Currency = Balances; + type CurrencyMatcher = IsConcrete; + type MaxLockers = frame_support::traits::ConstU32<8>; } impl origin::Config for Test {} diff --git a/xcm/src/lib.rs b/xcm/src/lib.rs index b8b5ea98c2f4..e883f959b5b9 100644 --- a/xcm/src/lib.rs +++ b/xcm/src/lib.rs @@ -28,13 +28,17 @@ use core::{ result::Result, }; use derivative::Derivative; -use parity_scale_codec::{Decode, Encode, Error as CodecError, Input}; +use parity_scale_codec::{Decode, Encode, Error as CodecError, Input, MaxEncodedLen}; use scale_info::TypeInfo; pub mod v1; pub mod v2; pub mod v3; +pub mod lts { + pub use super::v3::*; +} + pub mod latest { pub use super::v3::*; } @@ -68,306 +72,315 @@ pub trait IntoVersion: Sized { } } -/// A single `MultiLocation` value, together with its version code. -#[derive(Derivative, Encode, Decode, TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -pub enum VersionedMultiLocation { - #[codec(index = 1)] - V1(v1::MultiLocation), - #[codec(index = 2)] - V3(v3::MultiLocation), -} - -impl IntoVersion for VersionedMultiLocation { - fn into_version(self, n: Version) -> Result { - Ok(match n { - 1 | 2 => Self::V1(self.try_into()?), - 3 => Self::V3(self.try_into()?), - _ => return Err(()), - }) - } -} - -impl From for VersionedMultiLocation { - fn from(x: v1::MultiLocation) -> Self { - VersionedMultiLocation::V1(x) - } -} - -impl> From for VersionedMultiLocation { - fn from(x: T) -> Self { - VersionedMultiLocation::V3(x.into()) - } -} - -impl TryFrom for v1::MultiLocation { - type Error = (); - fn try_from(x: VersionedMultiLocation) -> Result { - use VersionedMultiLocation::*; - match x { - V1(x) => Ok(x), - V3(x) => x.try_into(), +pub trait TryAs { + fn try_as(&self) -> Result<&T, ()>; +} + +macro_rules! versioned_type { + ($(#[$attr:meta])* pub enum $n:ident { + V3($v3:ty), + }) => { + #[derive(Derivative, Encode, Decode, TypeInfo)] + #[derivative( + Clone(bound = ""), + Eq(bound = ""), + PartialEq(bound = ""), + Debug(bound = "") + )] + #[codec(encode_bound())] + #[codec(decode_bound())] + $(#[$attr])* + pub enum $n { + #[codec(index = 0)] + V3($v3), } - } -} - -impl TryFrom for v3::MultiLocation { - type Error = (); - fn try_from(x: VersionedMultiLocation) -> Result { - use VersionedMultiLocation::*; - match x { - V1(x) => x.try_into(), - V3(x) => Ok(x), + impl $n { + pub fn try_as(&self) -> Result<&T, ()> where Self: TryAs { + >::try_as(&self) + } } - } -} - -/// A single `InteriorMultiLocation` value, together with its version code. -#[derive(Derivative, Encode, Decode, TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -pub enum VersionedInteriorMultiLocation { - #[codec(index = 0)] - V1(v1::InteriorMultiLocation), - #[codec(index = 1)] - V3(v3::InteriorMultiLocation), -} - -impl IntoVersion for VersionedInteriorMultiLocation { - fn into_version(self, n: Version) -> Result { - Ok(match n { - 1 | 2 => Self::V1(self.try_into()?), - 3 => Self::V3(self.try_into()?), - _ => return Err(()), - }) - } -} - -impl From for VersionedInteriorMultiLocation { - fn from(x: v1::InteriorMultiLocation) -> Self { - VersionedInteriorMultiLocation::V1(x) - } -} - -impl> From for VersionedInteriorMultiLocation { - fn from(x: T) -> Self { - VersionedInteriorMultiLocation::V3(x.into()) - } -} - -impl TryFrom for v1::InteriorMultiLocation { - type Error = (); - fn try_from(x: VersionedInteriorMultiLocation) -> Result { - use VersionedInteriorMultiLocation::*; - match x { - V1(x) => Ok(x), - V3(x) => x.try_into(), + impl TryAs<$v3> for $n { + fn try_as(&self) -> Result<&$v3, ()> { + match &self { + Self::V3(ref x) => Ok(x), + } + } } - } -} - -impl TryFrom for v3::InteriorMultiLocation { - type Error = (); - fn try_from(x: VersionedInteriorMultiLocation) -> Result { - use VersionedInteriorMultiLocation::*; - match x { - V1(x) => x.try_into(), - V3(x) => Ok(x), + impl IntoVersion for $n { + fn into_version(self, n: Version) -> Result { + Ok(match n { + 3 => Self::V3(self.try_into()?), + _ => return Err(()), + }) + } } - } -} - -/// A single `Response` value, together with its version code. -#[derive(Derivative, Encode, Decode, TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -pub enum VersionedResponse { - #[codec(index = 1)] - V1(v1::Response), - #[codec(index = 2)] - V2(v2::Response), - #[codec(index = 3)] - V3(v3::Response), -} - -impl IntoVersion for VersionedResponse { - fn into_version(self, n: Version) -> Result { - Ok(match n { - 1 => Self::V1(self.try_into()?), - 2 => Self::V2(self.try_into()?), - 3 => Self::V3(self.try_into()?), - _ => return Err(()), - }) - } -} - -impl From for VersionedResponse { - fn from(x: v1::Response) -> Self { - VersionedResponse::V1(x) - } -} - -impl From for VersionedResponse { - fn from(x: v2::Response) -> Self { - VersionedResponse::V2(x) - } -} - -impl> From for VersionedResponse { - fn from(x: T) -> Self { - VersionedResponse::V3(x.into()) - } -} - -impl TryFrom for v1::Response { - type Error = (); - fn try_from(x: VersionedResponse) -> Result { - use VersionedResponse::*; - match x { - V1(x) => Ok(x), - V2(x) => x.try_into(), - V3(x) => V2(x.try_into()?).try_into(), + impl> From for $n { + fn from(x: T) -> Self { + $n::V3(x.into()) + } } - } -} - -impl TryFrom for v2::Response { - type Error = (); - fn try_from(x: VersionedResponse) -> Result { - use VersionedResponse::*; - match x { - V1(x) => x.try_into(), - V2(x) => Ok(x), - V3(x) => x.try_into(), + impl TryFrom<$n> for $v3 { + type Error = (); + fn try_from(x: $n) -> Result { + use $n::*; + match x { + V3(x) => Ok(x), + } + } } - } -} - -impl TryFrom for v3::Response { - type Error = (); - fn try_from(x: VersionedResponse) -> Result { - use VersionedResponse::*; - match x { - V1(x) => V2(x.try_into()?).try_into(), - V2(x) => x.try_into(), - V3(x) => Ok(x), + impl MaxEncodedLen for $n { + fn max_encoded_len() -> usize { + <$v3>::max_encoded_len() + } } - } -} - -/// A single `MultiAsset` value, together with its version code. -#[derive(Derivative, Encode, Decode, TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -pub enum VersionedMultiAsset { - #[codec(index = 1)] - V1(v1::MultiAsset), - #[codec(index = 2)] - V3(v3::MultiAsset), -} - -impl IntoVersion for VersionedMultiAsset { - fn into_version(self, n: Version) -> Result { - Ok(match n { - 1 | 2 => Self::V1(self.try_into()?), - 3 => Self::V3(self.try_into()?), - _ => return Err(()), - }) - } -} - -impl From for VersionedMultiAsset { - fn from(x: v1::MultiAsset) -> Self { - VersionedMultiAsset::V1(x) - } -} - -impl From for VersionedMultiAsset { - fn from(x: v3::MultiAsset) -> Self { - VersionedMultiAsset::V3(x) - } -} + }; -impl TryFrom for v1::MultiAsset { - type Error = (); - fn try_from(x: VersionedMultiAsset) -> Result { - use VersionedMultiAsset::*; - match x { - V1(x) => Ok(x), - V3(x) => x.try_into(), + ($(#[$attr:meta])* pub enum $n:ident { + V1($v1:ty), + V3($v3:ty), + }) => { + #[derive(Derivative, Encode, Decode, TypeInfo)] + #[derivative( + Clone(bound = ""), + Eq(bound = ""), + PartialEq(bound = ""), + Debug(bound = "") + )] + #[codec(encode_bound())] + #[codec(decode_bound())] + $(#[$attr])* + pub enum $n { + #[codec(index = 0)] + V1($v1), + #[codec(index = 1)] + V3($v3), } - } -} + impl $n { + pub fn try_as(&self) -> Result<&T, ()> where Self: TryAs { + >::try_as(&self) + } + } + impl TryAs<$v1> for $n { + fn try_as(&self) -> Result<&$v1, ()> { + match &self { + Self::V1(ref x) => Ok(x), + _ => Err(()), + } + } + } + impl TryAs<$v3> for $n { + fn try_as(&self) -> Result<&$v3, ()> { + match &self { + Self::V3(ref x) => Ok(x), + _ => Err(()), + } + } + } + impl IntoVersion for $n { + fn into_version(self, n: Version) -> Result { + Ok(match n { + 1 | 2 => Self::V1(self.try_into()?), + 3 => Self::V3(self.try_into()?), + _ => return Err(()), + }) + } + } + impl From<$v1> for $n { + fn from(x: $v1) -> Self { + $n::V1(x) + } + } + impl> From for $n { + fn from(x: T) -> Self { + $n::V3(x.into()) + } + } + impl TryFrom<$n> for $v1 { + type Error = (); + fn try_from(x: $n) -> Result { + use $n::*; + match x { + V1(x) => Ok(x), + V3(x) => x.try_into(), + } + } + } + impl TryFrom<$n> for $v3 { + type Error = (); + fn try_from(x: $n) -> Result { + use $n::*; + match x { + V1(x) => x.try_into(), + V3(x) => Ok(x), + } + } + } + impl MaxEncodedLen for $n { + fn max_encoded_len() -> usize { + <$v3>::max_encoded_len() + } + } + }; -impl TryFrom for v3::MultiAsset { - type Error = (); - fn try_from(x: VersionedMultiAsset) -> Result { - use VersionedMultiAsset::*; - match x { - V1(x) => x.try_into(), - V3(x) => Ok(x), + ($(#[$attr:meta])* pub enum $n:ident { + V1($v1:ty), + V2($v2:ty), + V3($v3:ty), + }) => { + #[derive(Derivative, Encode, Decode, TypeInfo)] + #[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] + #[codec(encode_bound())] + #[codec(decode_bound())] + $(#[$attr])* + pub enum $n { + #[codec(index = 0)] + V1($v1), + #[codec(index = 1)] + V2($v2), + #[codec(index = 2)] + V3($v3), + } + impl $n { + pub fn try_as(&self) -> Result<&T, ()> where Self: TryAs { + >::try_as(&self) + } + } + impl TryAs<$v1> for $n { + fn try_as(&self) -> Result<&$v1, ()> { + match &self { + Self::V1(ref x) => Ok(x), + _ => Err(()), + } + } + } + impl TryAs<$v2> for $n { + fn try_as(&self) -> Result<&$v2, ()> { + match &self { + Self::V2(ref x) => Ok(x), + _ => Err(()), + } + } + } + impl TryAs<$v3> for $n { + fn try_as(&self) -> Result<&$v3, ()> { + match &self { + Self::V3(ref x) => Ok(x), + _ => Err(()), + } + } + } + impl IntoVersion for $n { + fn into_version(self, n: Version) -> Result { + Ok(match n { + 1 => Self::V1(self.try_into()?), + 2 => Self::V2(self.try_into()?), + 3 => Self::V3(self.try_into()?), + _ => return Err(()), + }) + } + } + impl From<$v1> for $n { + fn from(x: $v1) -> Self { + $n::V1(x) + } + } + impl From<$v2> for $n { + fn from(x: $v2) -> Self { + $n::V2(x) + } + } + impl> From for $n { + fn from(x: T) -> Self { + $n::V3(x.into()) + } + } + impl TryFrom<$n> for $v1 { + type Error = (); + fn try_from(x: $n) -> Result { + use $n::*; + match x { + V1(x) => Ok(x), + V2(x) => x.try_into(), + V3(x) => V2(x.try_into()?).try_into(), + } + } + } + impl TryFrom<$n> for $v2 { + type Error = (); + fn try_from(x: $n) -> Result { + use $n::*; + match x { + V1(x) => x.try_into(), + V2(x) => Ok(x), + V3(x) => x.try_into(), + } + } + } + impl TryFrom<$n> for $v3 { + type Error = (); + fn try_from(x: $n) -> Result { + use $n::*; + match x { + V1(x) => V2(x.try_into()?).try_into(), + V2(x) => x.try_into(), + V3(x) => Ok(x), + } + } + } + impl MaxEncodedLen for $n { + fn max_encoded_len() -> usize { + <$v3>::max_encoded_len() + } } } } -/// A single `MultiAssets` value, together with its version code. -#[derive(Derivative, Encode, Decode, TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -pub enum VersionedMultiAssets { - #[codec(index = 1)] - V1(v1::MultiAssets), - #[codec(index = 2)] - V3(v3::MultiAssets), +versioned_type! { + /// A single version's `Response` value, together with its version code. + pub enum VersionedAssetId { + V3(v3::AssetId), + } } -impl IntoVersion for VersionedMultiAssets { - fn into_version(self, n: Version) -> Result { - Ok(match n { - 1 | 2 => Self::V1(self.try_into()?), - 3 => Self::V3(self.try_into()?), - _ => return Err(()), - }) +versioned_type! { + /// A single version's `Response` value, together with its version code. + pub enum VersionedResponse { + V1(v1::Response), + V2(v2::Response), + V3(v3::Response), } } -impl From for VersionedMultiAssets { - fn from(x: v1::MultiAssets) -> Self { - VersionedMultiAssets::V1(x) +versioned_type! { + /// A single `MultiLocation` value, together with its version code. + #[derive(Ord, PartialOrd)] + pub enum VersionedMultiLocation { + V1(v1::MultiLocation), + V3(v3::MultiLocation), } } -impl> From for VersionedMultiAssets { - fn from(x: T) -> Self { - VersionedMultiAssets::V3(x.into()) +versioned_type! { + /// A single `InteriorMultiLocation` value, together with its version code. + pub enum VersionedInteriorMultiLocation { + V1(v1::InteriorMultiLocation), + V3(v3::InteriorMultiLocation), } } -impl TryFrom for v1::MultiAssets { - type Error = (); - fn try_from(x: VersionedMultiAssets) -> Result { - use VersionedMultiAssets::*; - match x { - V1(x) => Ok(x), - V3(x) => x.try_into(), - } +versioned_type! { + /// A single `MultiAsset` value, together with its version code. + pub enum VersionedMultiAsset { + V1(v1::MultiAsset), + V3(v3::MultiAsset), } } -impl TryFrom for v3::MultiAssets { - type Error = (); - fn try_from(x: VersionedMultiAssets) -> Result { - use VersionedMultiAssets::*; - match x { - V1(x) => x.try_into(), - V3(x) => Ok(x), - } +versioned_type! { + /// A single `MultiAssets` value, together with its version code. + pub enum VersionedMultiAssets { + V1(v1::MultiAssets), + V3(v3::MultiAssets), } } @@ -378,11 +391,11 @@ impl TryFrom for v3::MultiAssets { #[codec(decode_bound())] #[scale_info(bounds(), skip_type_params(Call))] pub enum VersionedXcm { - #[codec(index = 1)] + #[codec(index = 0)] V1(v1::Xcm), - #[codec(index = 2)] + #[codec(index = 1)] V2(v2::Xcm), - #[codec(index = 3)] + #[codec(index = 2)] V3(v3::Xcm), } @@ -491,17 +504,20 @@ impl WrapVersion for AlwaysV3 { } } -/// `WrapVersion` implementation which attempts to always convert the XCM to the latest version before wrapping it. -pub type AlwaysLatest = AlwaysV2; +/// `WrapVersion` implementation which attempts to always convert the XCM to the latest version +/// before wrapping it. +pub type AlwaysLatest = AlwaysV3; -/// `WrapVersion` implementation which attempts to always convert the XCM to the release version before wrapping it. -pub type AlwaysRelease = AlwaysV2; +/// `WrapVersion` implementation which attempts to always convert the XCM to the most recent Long- +/// Term-Support version before wrapping it. +pub type AlwaysLts = AlwaysV3; pub mod prelude { pub use super::{ - latest::prelude::*, AlwaysLatest, AlwaysRelease, AlwaysV2, AlwaysV3, IntoVersion, - Unsupported, Version as XcmVersion, VersionedInteriorMultiLocation, VersionedMultiAsset, - VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, VersionedXcm, WrapVersion, + latest::prelude::*, AlwaysLatest, AlwaysLts, AlwaysV2, AlwaysV3, IntoVersion, Unsupported, + Version as XcmVersion, VersionedAssetId, VersionedInteriorMultiLocation, + VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, + VersionedXcm, WrapVersion, }; } @@ -529,6 +545,10 @@ pub mod opaque { pub use super::v3::*; } + pub mod lts { + pub use super::v3::*; + } + /// The basic `VersionedXcm` type which just uses the `Vec` as an encoded call. pub type VersionedXcm = super::VersionedXcm<()>; } diff --git a/xcm/src/v1/junction.rs b/xcm/src/v1/junction.rs index af740447daaf..613160aa42dd 100644 --- a/xcm/src/v1/junction.rs +++ b/xcm/src/v1/junction.rs @@ -92,9 +92,9 @@ impl TryFrom for Junction { Self::AccountKey20 { network: network.try_into()?, key }, PalletInstance(index) => Self::PalletInstance(index), GeneralIndex(id) => Self::GeneralIndex(id), - GeneralKey(key) => Self::GeneralKey(key), + GeneralKey(key) => Self::GeneralKey(key[..].to_vec()), OnlyChild => Self::OnlyChild, - Plurality { id, part } => Self::Plurality { id: id.into(), part }, + Plurality { id, part } => Self::Plurality { id: id.into(), part: part.into() }, _ => return Err(()), }) } diff --git a/xcm/src/v1/mod.rs b/xcm/src/v1/mod.rs index 949403c83c5f..01cc80fdf96b 100644 --- a/xcm/src/v1/mod.rs +++ b/xcm/src/v1/mod.rs @@ -62,7 +62,7 @@ use crate::{ v2::{Instruction, Response as NewResponse, Xcm as NewXcm}, - v3::NetworkId as NewNetworkId, + v3::{BodyId as NewBodyId, BodyPart as NewBodyPart, NetworkId as NewNetworkId}, DoubleEncoded, }; use alloc::vec::Vec; @@ -186,6 +186,21 @@ pub enum BodyId { Judicial, } +impl From for BodyId { + fn from(n: NewBodyId) -> Self { + use NewBodyId::*; + match n { + Unit => Self::Unit, + Moniker(n) => Self::Named(n[..].to_vec()), + Index(n) => Self::Index(n), + Executive => Self::Executive, + Technical => Self::Technical, + Legislative => Self::Legislative, + Judicial => Self::Judicial, + } + } +} + /// A part of a pluralistic body. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] pub enum BodyPart { @@ -231,6 +246,19 @@ impl BodyPart { } } +impl From for BodyPart { + fn from(n: NewBodyPart) -> Self { + use NewBodyPart::*; + match n { + Voice => Self::Voice, + Members { count } => Self::Members { count }, + Fraction { nom, denom } => Self::Fraction { nom, denom }, + AtLeastProportion { nom, denom } => Self::AtLeastProportion { nom, denom }, + MoreThanProportion { nom, denom } => Self::MoreThanProportion { nom, denom }, + } + } +} + /// Response data to a query. #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] pub enum Response { diff --git a/xcm/src/v1/multiasset.rs b/xcm/src/v1/multiasset.rs index fd2f2a4925ec..037b72070672 100644 --- a/xcm/src/v1/multiasset.rs +++ b/xcm/src/v1/multiasset.rs @@ -25,8 +25,10 @@ use super::MultiLocation; use crate::v3::{ - AssetId as NewAssetId, MultiAsset as NewMultiAsset, MultiAssetFilter as NewMultiAssetFilter, - MultiAssets as NewMultiAssets, WildMultiAsset as NewWildMultiAsset, + AssetId as NewAssetId, AssetInstance as NewAssetInstance, Fungibility as NewFungibility, + MultiAsset as NewMultiAsset, MultiAssetFilter as NewMultiAssetFilter, + MultiAssets as NewMultiAssets, WildFungibility as NewWildFungibility, + WildMultiAsset as NewWildMultiAsset, }; use alloc::{vec, vec::Vec}; use core::{ @@ -98,6 +100,21 @@ impl From> for AssetInstance { } } +impl TryFrom for AssetInstance { + type Error = (); + fn try_from(value: NewAssetInstance) -> Result { + use NewAssetInstance::*; + Ok(match value { + Undefined => Self::Undefined, + Index(n) => Self::Index(n), + Array4(n) => Self::Array4(n), + Array8(n) => Self::Array8(n), + Array16(n) => Self::Array16(n), + Array32(n) => Self::Array32(n), + }) + } +} + /// Classification of an asset being concrete or abstract. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] pub enum AssetId { @@ -123,7 +140,10 @@ impl TryFrom for AssetId { use NewAssetId::*; Ok(match old { Concrete(l) => Self::Concrete(l.try_into()?), - Abstract(v) => Self::Abstract(v), + Abstract(v) => { + let zeroes = v.iter().rev().position(|n| *n != 0).unwrap_or(v.len()); + Self::Abstract(v[0..(32 - zeroes)].to_vec()) + }, }) } } @@ -186,6 +206,17 @@ impl> From for Fungibility { } } +impl TryFrom for Fungibility { + type Error = (); + fn try_from(value: NewFungibility) -> Result { + use NewFungibility::*; + Ok(match value { + Fungible(n) => Self::Fungible(n), + NonFungible(i) => Self::NonFungible(i.try_into()?), + }) + } +} + #[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] pub struct MultiAsset { pub id: AssetId, @@ -264,7 +295,7 @@ impl MultiAsset { impl TryFrom for MultiAsset { type Error = (); fn try_from(new: NewMultiAsset) -> Result { - Ok(Self { id: new.id.try_into()?, fun: new.fun }) + Ok(Self { id: new.id.try_into()?, fun: new.fun.try_into()? }) } } @@ -283,7 +314,7 @@ impl TryFrom for MultiAssets { type Error = (); fn try_from(new: NewMultiAssets) -> Result { let v = new - .drain() + .into_inner() .into_iter() .map(MultiAsset::try_from) .collect::, ()>>()?; @@ -440,6 +471,17 @@ pub enum WildFungibility { NonFungible, } +impl TryFrom for WildFungibility { + type Error = (); + fn try_from(value: NewWildFungibility) -> Result { + use NewWildFungibility::*; + Ok(match value { + Fungible => Self::Fungible, + NonFungible => Self::NonFungible, + }) + } +} + /// A wildcard representing a set of assets. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] pub enum WildMultiAsset { @@ -543,7 +585,7 @@ impl TryFrom for WildMultiAsset { use NewWildMultiAsset::*; Ok(match new { AllOf { id, fun } | AllOfCounted { id, fun, .. } => - Self::AllOf { id: id.try_into()?, fun }, + Self::AllOf { id: id.try_into()?, fun: fun.try_into()? }, All | AllCounted(_) => Self::All, }) } diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index 3fa82fc43ec0..4a787877fa95 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -971,9 +971,9 @@ impl TryFrom> for Instruction { let assets = assets.try_into()?; Self::DepositReserveAsset { assets, max_assets, dest, xcm } }, - ExchangeAsset { give, receive } => { + ExchangeAsset { give, want, .. } => { let give = give.try_into()?; - let receive = receive.try_into()?; + let receive = want.try_into()?; Self::ExchangeAsset { give, receive } }, InitiateReserveWithdraw { assets, reserve, xcm } => { diff --git a/xcm/src/v3/junction.rs b/xcm/src/v3/junction.rs index d0b323782444..60fbff43f229 100644 --- a/xcm/src/v3/junction.rs +++ b/xcm/src/v3/junction.rs @@ -16,21 +16,23 @@ //! Support data structures for `MultiLocation`, primarily the `Junction` datatype. -use super::{BodyId, BodyPart, Junctions, MultiLocation}; +use super::{Junctions, MultiLocation}; use crate::{ + v1::{BodyId as OldBodyId, BodyPart as OldBodyPart}, v2::{Junction as OldJunction, NetworkId as OldNetworkId}, VersionedMultiLocation, }; -use alloc::vec::Vec; -use core::convert::TryFrom; -use parity_scale_codec::{self, Decode, Encode}; +use core::convert::{TryFrom, TryInto}; +use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A global identifier of a data structure existing within consensus. /// /// Maintenance note: Networks with global consensus and which are practically bridgeable within the /// Polkadot ecosystem are given preference over explicit naming in this enumeration. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, +)] pub enum NetworkId { /// Network specified by the first 32 bytes of its genesis block. ByGenesis([u8; 32]), @@ -68,10 +70,113 @@ impl From for Option { } } +/// An identifier of a pluralistic body. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] +pub enum BodyId { + /// The only body in its context. + Unit, + /// A named body. + Moniker([u8; 4]), + /// An indexed body. + Index(#[codec(compact)] u32), + /// The unambiguous executive body (for Polkadot, this would be the Polkadot council). + Executive, + /// The unambiguous technical body (for Polkadot, this would be the Technical Committee). + Technical, + /// The unambiguous legislative body (for Polkadot, this could be considered the opinion of a majority of + /// lock-voters). + Legislative, + /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it + /// may be considered as that). + Judicial, +} + +impl TryFrom for BodyId { + type Error = (); + fn try_from(value: OldBodyId) -> Result { + use OldBodyId::*; + Ok(match value { + Unit => Self::Unit, + Named(n) => + if n.len() == 4 { + let mut r = [0u8; 4]; + r.copy_from_slice(&n[..]); + Self::Moniker(r) + } else { + return Err(()) + }, + Index(n) => Self::Index(n), + Executive => Self::Executive, + Technical => Self::Technical, + Legislative => Self::Legislative, + Judicial => Self::Judicial, + }) + } +} + +/// A part of a pluralistic body. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] +pub enum BodyPart { + /// The body's declaration, under whatever means it decides. + Voice, + /// A given number of members of the body. + Members { + #[codec(compact)] + count: u32, + }, + /// A given number of members of the body, out of some larger caucus. + Fraction { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + /// No less than the given proportion of members of the body. + AtLeastProportion { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + /// More than than the given proportion of members of the body. + MoreThanProportion { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, +} + +impl BodyPart { + /// Returns `true` if the part represents a strict majority (> 50%) of the body in question. + pub fn is_majority(&self) -> bool { + match self { + BodyPart::Fraction { nom, denom } if *nom * 2 > *denom => true, + BodyPart::AtLeastProportion { nom, denom } if *nom * 2 > *denom => true, + BodyPart::MoreThanProportion { nom, denom } if *nom * 2 >= *denom => true, + _ => false, + } + } +} + +impl TryFrom for BodyPart { + type Error = (); + fn try_from(value: OldBodyPart) -> Result { + use OldBodyPart::*; + Ok(match value { + Voice => Self::Voice, + Members { count } => Self::Members { count }, + Fraction { nom, denom } => Self::Fraction { nom, denom }, + AtLeastProportion { nom, denom } => Self::AtLeastProportion { nom, denom }, + MoreThanProportion { nom, denom } => Self::MoreThanProportion { nom, denom }, + }) + } +} + /// A single item in a path to describe the relative location of a consensus system. /// /// Each item assumes a pre-existing location as its context and is defined in terms of it. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] pub enum Junction { /// An indexed parachain belonging to and operated by the context. /// @@ -106,12 +211,12 @@ pub enum Junction { /// /// NOTE: Try to avoid using this and instead use a more specific item. GeneralIndex(#[codec(compact)] u128), - /// A nondescript datum acting as a key within the context location. + /// A nondescript 128-byte datum acting as a key within the context location. /// /// Usage will vary widely owing to its generality. /// /// NOTE: Try to avoid using this and instead use a more specific item. - GeneralKey(Vec), + GeneralKey([u8; 32]), /// The unambiguous child. /// /// Not currently used except as a fallback when deriving context. @@ -156,12 +261,6 @@ impl From for Junction { } } -impl From> for Junction { - fn from(id: Vec) -> Self { - Self::GeneralKey(id) - } -} - impl TryFrom for Junction { type Error = (); fn try_from(value: OldJunction) -> Result { @@ -174,9 +273,10 @@ impl TryFrom for Junction { AccountKey20 { network, key } => Self::AccountKey20 { network: network.into(), key }, PalletInstance(index) => Self::PalletInstance(index), GeneralIndex(id) => Self::GeneralIndex(id), - GeneralKey(key) => Self::GeneralKey(key), + GeneralKey(_key) => return Err(()), OnlyChild => Self::OnlyChild, - Plurality { id, part } => Self::Plurality { id: id.into(), part }, + Plurality { id, part } => + Self::Plurality { id: id.try_into()?, part: part.try_into()? }, }) } } @@ -202,4 +302,15 @@ impl Junction { pub const fn into_versioned(self) -> VersionedMultiLocation { self.into_location().into_versioned() } + + /// Remove the `NetworkId` value. + pub fn remove_network_id(&mut self) { + use Junction::*; + match self { + AccountId32 { ref mut network, .. } | + AccountIndex64 { ref mut network, .. } | + AccountKey20 { ref mut network, .. } => *network = None, + _ => {}, + } + } } diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs index 9ad0171c82a9..88df3a0d3061 100644 --- a/xcm/src/v3/junctions.rs +++ b/xcm/src/v3/junctions.rs @@ -18,7 +18,7 @@ use super::{Junction, MultiLocation, NetworkId}; use core::{convert::TryFrom, mem, result}; -use parity_scale_codec::{Decode, Encode}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// Maximum number of `Junction`s that a `Junctions` can contain. @@ -29,7 +29,7 @@ pub(crate) const MAX_JUNCTIONS: usize = 8; /// /// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for /// instructions on constructing parent junctions. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] pub enum Junctions { /// The interpreting consensus system. Here, @@ -97,7 +97,6 @@ impl<'a> DoubleEndedIterator for JunctionsRefIterator<'a> { self.junctions.at(index) } } - impl<'a> IntoIterator for &'a Junctions { type Item = &'a Junction; type IntoIter = JunctionsRefIterator<'a>; @@ -129,6 +128,71 @@ impl Junctions { MultiLocation { parents: n, interior: self } } + /// Remove the `NetworkId` value in any `Junction`s. + pub fn remove_network_id(&mut self) { + self.for_each_mut(Junction::remove_network_id); + } + + /// Execute a function `f` on every junction. We use this since we cannot implement a mutable + /// `Iterator` without unsafe code. + pub fn for_each_mut(&mut self, mut x: impl FnMut(&mut Junction)) { + match self { + Junctions::Here => {}, + Junctions::X1(a) => { + x(a); + }, + Junctions::X2(a, b) => { + x(a); + x(b); + }, + Junctions::X3(a, b, c) => { + x(a); + x(b); + x(c); + }, + Junctions::X4(a, b, c, d) => { + x(a); + x(b); + x(c); + x(d); + }, + Junctions::X5(a, b, c, d, e) => { + x(a); + x(b); + x(c); + x(d); + x(e); + }, + Junctions::X6(a, b, c, d, e, f) => { + x(a); + x(b); + x(c); + x(d); + x(e); + x(f); + }, + Junctions::X7(a, b, c, d, e, f, g) => { + x(a); + x(b); + x(c); + x(d); + x(e); + x(f); + x(g); + }, + Junctions::X8(a, b, c, d, e, f, g, h) => { + x(a); + x(b); + x(c); + x(d); + x(e); + x(f); + x(g); + x(h); + }, + } + } + /// Extract the network ID treating this value as a universal location. /// /// This will return an `Err` if the first item is not a `GlobalConsensus`, which would indicate @@ -393,7 +457,7 @@ impl Junctions { /// Returns a mutable reference to the junction at index `i`, or `None` if the location doesn't contain that many /// elements. - pub fn at_mut(&mut self, i: usize) -> Option<&mut Junction> { + pub fn at_mut<'a>(&'a mut self, i: usize) -> Option<&'a mut Junction> { Some(match (i, self) { (0, Junctions::X1(ref mut a)) => a, (0, Junctions::X2(ref mut a, ..)) => a, @@ -499,7 +563,6 @@ xcm_procedural::impl_conversion_functions_for_junctions_v3!(); #[cfg(test)] mod tests { use super::{super::prelude::*, *}; - use alloc::vec; #[test] fn relative_to_works() { @@ -549,9 +612,9 @@ mod tests { (Parent, PalletInstance(2), [1u8; 32]).into() ); assert_eq!( - X5(Kusama.into(), Parachain(1), PalletInstance(1), [1u8; 32].into(), vec![1].into()) + X5(Kusama.into(), Parachain(1), PalletInstance(1), [1u8; 32].into(), 1u128.into()) .relative_to(&base), - ([1u8; 32], vec![1]).into() + ([1u8; 32], 1u128).into() ); } diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 10a8b8ac0726..5e522e32baba 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -25,7 +25,7 @@ use core::{ result, }; use derivative::Derivative; -use parity_scale_codec::{self, Decode, Encode}; +use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; mod junction; @@ -34,7 +34,7 @@ mod multiasset; mod multilocation; mod traits; -pub use junction::{Junction, NetworkId}; +pub use junction::{BodyId, BodyPart, Junction, NetworkId}; pub use junctions::Junctions; pub use multiasset::{ AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssetFilter, MultiAssets, @@ -48,7 +48,7 @@ pub use traits::{ SendResult, SendXcm, Unwrappable, Weight, }; // These parts of XCM v2 are unchanged in XCM v3, and are re-imported here. -pub use super::v2::{BodyId, BodyPart, OriginKind, WeightLimit}; +pub use super::v2::{OriginKind, WeightLimit}; /// This module's XCM version. pub const VERSION: super::Version = 3; @@ -200,21 +200,70 @@ pub mod prelude { #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] pub struct PalletInfo { #[codec(compact)] - pub index: u32, - pub name: Vec, - pub module_name: Vec, + index: u32, + // TODO: Change to `BoundedVec` so `MaxEncodedLen` derive will work. + name: Vec, + // TODO: Change to `BoundedVec` so `MaxEncodedLen` derive will work. + module_name: Vec, #[codec(compact)] - pub major: u32, + major: u32, #[codec(compact)] - pub minor: u32, + minor: u32, #[codec(compact)] - pub patch: u32, + patch: u32, +} + +const MAX_NAME_LEN: usize = 48; + +impl PalletInfo { + pub fn new( + index: u32, + name: Vec, + module_name: Vec, + major: u32, + minor: u32, + patch: u32, + ) -> result::Result { + if name.len() > MAX_NAME_LEN || module_name.len() > MAX_NAME_LEN { + return Err(Error::Overflow) + } + Ok(Self { index, name, module_name, major, minor, patch }) + } +} + +impl MaxEncodedLen for PalletInfo { + fn max_encoded_len() -> usize { + parity_scale_codec::Compact::::max_encoded_len() * 4 + MAX_NAME_LEN * 2 + } } #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] pub enum MaybeErrorCode { Success, + // TODO: Change to a `BoundedVec` so that deriving `MaxEncodedLen` works. Error(Vec), + TruncatedError(Vec), +} + +/// Maximum size of the encoded error code coming from a `Dispatch` result, used for +/// `MaybeErrorCode`. This is not (yet) enforced, so it's just an indication of expectation. +const MAX_DISPATCH_ERROR_LEN: usize = 128; + +impl MaxEncodedLen for MaybeErrorCode { + fn max_encoded_len() -> usize { + MAX_DISPATCH_ERROR_LEN + 3 + } +} + +impl From> for MaybeErrorCode { + fn from(mut v: Vec) -> Self { + if v.len() <= MAX_DISPATCH_ERROR_LEN { + MaybeErrorCode::Error(v) + } else { + v.truncate(MAX_DISPATCH_ERROR_LEN); + MaybeErrorCode::TruncatedError(v) + } + } } impl Default for MaybeErrorCode { @@ -223,8 +272,28 @@ impl Default for MaybeErrorCode { } } -/// Response data to a query. +/// Maximum number of pallets which we expect to be returned in `PalletsInfo`. +const MAX_PALLETS_INFO_LEN: usize = 64; + #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] +pub struct VecPalletInfo(Vec); +impl TryFrom> for VecPalletInfo { + type Error = Error; + fn try_from(v: Vec) -> result::Result { + if v.len() > MAX_PALLETS_INFO_LEN { + return Err(Error::Overflow) + } + Ok(VecPalletInfo(v)) + } +} +impl MaxEncodedLen for VecPalletInfo { + fn max_encoded_len() -> usize { + PalletInfo::max_encoded_len() * MAX_PALLETS_INFO_LEN + } +} + +/// Response data to a query. +#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] pub enum Response { /// No response. Serves as a neutral default. Null, @@ -235,7 +304,8 @@ pub enum Response { /// An XCM version. Version(super::Version), /// The index, instance name, pallet name and version of some pallets. - PalletsInfo(Vec), + // TODO: Change to a `BoundedVec` so that deriving `MaxEncodedLen` works. + PalletsInfo(VecPalletInfo), /// The status of a dispatch attempt using `Transact`. DispatchResult(MaybeErrorCode), } @@ -352,7 +422,7 @@ pub enum Instruction { /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets /// under the ownership of `dest` within this consensus system (i.e. its sovereign account). /// - /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the given + /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the wantn /// `xcm`. /// /// - `assets`: The asset(s) to be withdrawn. @@ -465,7 +535,7 @@ pub enum Instruction { /// Errors: DescendOrigin(InteriorMultiLocation), - /// Immediately report the contents of the Error Register to the given destination via XCM. + /// Immediately report the contents of the Error Register to the wantn destination via XCM. /// /// A `QueryResponse` message of type `ExecutionOutcome` is sent to the described destination. /// @@ -491,7 +561,7 @@ pub enum Instruction { /// the ownership of `dest` within this consensus system (i.e. deposit them into its sovereign /// account). /// - /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the given `effects`. + /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the wantn `effects`. /// /// - `assets`: The asset(s) to remove from holding. /// - `dest`: The location whose sovereign account will own the assets and thus the effective @@ -505,19 +575,22 @@ pub enum Instruction { /// Errors: DepositReserveAsset { assets: MultiAssetFilter, dest: MultiLocation, xcm: Xcm<()> }, - /// Remove the asset(s) (`give`) from the Holding Register and replace them with alternative + /// Remove the asset(s) (`want`) from the Holding Register and replace them with alternative /// assets. /// /// The minimum amount of assets to be received into the Holding Register for the order not to /// fail may be stated. /// - /// - `give`: The asset(s) to remove from holding. - /// - `receive`: The minimum amount of assets(s) which `give` should be exchanged for. + /// - `give`: The maximum amount of assets to remove from holding. + /// - `want`: The minimum amount of assets which `give` should be exchanged for. + /// - `maximal`: If `true`, then prefer to give as much as possible up to the limit of `give` + /// and receive accordingly more. If `false`, then prefer to give as little as possible in + /// order to receive as little as possible while receiving at least `want`. /// /// Kind: *Instruction* /// /// Errors: - ExchangeAsset { give: MultiAssetFilter, receive: MultiAssets }, + ExchangeAsset { give: MultiAssetFilter, want: MultiAssets, maximal: bool }, /// Remove the asset(s) (`assets`) from holding and send a `WithdrawAsset` XCM message to a /// reserve location. @@ -526,7 +599,7 @@ pub enum Instruction { /// - `reserve`: A valid location that acts as a reserve for all asset(s) in `assets`. The /// sovereign account of this consensus system *on the reserve location* will have appropriate /// assets withdrawn and `effects` will be executed on them. There will typically be only one - /// valid location on any given asset/chain combination. + /// valid location on any wantn asset/chain combination. /// - `xcm`: The instructions to execute on the assets once withdrawn *on the reserve /// location*. /// @@ -551,7 +624,7 @@ pub enum Instruction { /// Errors: InitiateTeleport { assets: MultiAssetFilter, dest: MultiLocation, xcm: Xcm<()> }, - /// Report to a given destination the contents of the Holding Register. + /// Report to a wantn destination the contents of the Holding Register. /// /// A `QueryResponse` message of type `Assets` is sent to the described destination. /// @@ -670,7 +743,7 @@ pub enum Instruction { /// Errors: *Fallible* UnsubscribeVersion, - /// Reduce Holding by up to the given assets. + /// Reduce Holding by up to the wantn assets. /// /// Holding is reduced by as much as possible up to the assets in the parameter. It is not an /// error if the Holding does not contain the assets (to make this an error, use `ExpectAsset` @@ -681,7 +754,7 @@ pub enum Instruction { /// Errors: *Infallible* BurnAsset(MultiAssets), - /// Throw an error if Holding does not contain at least the given assets. + /// Throw an error if Holding does not contain at least the wantn assets. /// /// Kind: *Instruction* /// @@ -689,7 +762,7 @@ pub enum Instruction { /// - `ExpectationFalse`: If Holding Register does not contain the assets in the parameter. ExpectAsset(MultiAssets), - /// Ensure that the Origin Register equals some given value and throw an error if not. + /// Ensure that the Origin Register equals some wantn value and throw an error if not. /// /// Kind: *Instruction* /// @@ -697,7 +770,7 @@ pub enum Instruction { /// - `ExpectationFalse`: If Origin Register is not equal to the parameter. ExpectOrigin(Option), - /// Ensure that the Error Register equals some given value and throw an error if not. + /// Ensure that the Error Register equals some wantn value and throw an error if not. /// /// Kind: *Instruction* /// @@ -803,6 +876,74 @@ pub enum Instruction { /// /// Errors: *Fallible*. ExportMessage { network: NetworkId, destination: InteriorMultiLocation, xcm: Xcm<()> }, + + /// Lock the locally held asset and prevent further transfer or withdrawal. + /// + /// This restriction may be removed by the `UnlockAsset` instruction being called with an + /// Origin of `unlocker` and a `target` equal to the current `Origin`. + /// + /// If the locking is successful, then a `NoteAssetLocked` instruction is sent to `unlocker`. + /// + /// - `asset`: The asset(s) which should be locked. + /// - `unlocker`: The value which the Origin must be for a corresponding `UnlockAsset` + /// instruction to work. + /// + /// Kind: *Instruction*. + /// + /// Errors: + LockAsset { asset: MultiAsset, unlocker: MultiLocation }, + + /// Remove the lock over `asset` on this chain and (if nothing else is preventing it) allow the + /// asset to be transferred. + /// + /// - `asset`: The asset to be unlocked. + /// - `owner`: The owner of the asset on the local chain. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction*. + /// + /// Errors: + UnlockAsset { asset: MultiAsset, target: MultiLocation }, + + /// Asset (`asset`) has been locked on the `origin` system and may not be transferred. It may + /// only be unlocked with the receipt of the `UnlockAsset` instruction from this chain. + /// + /// - `asset`: The asset(s) which are now unlockable from this origin. + /// - `owner`: The owner of the asset on the chain in which it was locked. This may be a + /// location specific to the origin network. + /// + /// Safety: `origin` must be trusted to have locked the corresponding `asset` + /// prior as a consequence of sending this message. + /// + /// Kind: *Trusted Indication*. + /// + /// Errors: + NoteUnlockable { asset: MultiAsset, owner: MultiLocation }, + + /// Send an `UnlockAsset` instruction to the `locker` for the given `asset`. + /// + /// This may fail if the local system is making use of the fact that the asset is locked or, + /// of course, if there is no record that the asset actually is locked. + /// + /// - `asset`: The asset(s) to be unlocked. + /// - `locker`: The location from which a previous `NoteUnlockable` was sent and to which + /// an `UnlockAsset` should be sent. + /// + /// Kind: *Instruction*. + /// + /// Errors: + RequestUnlock { asset: MultiAsset, locker: MultiLocation }, + + /// Sets the Fees Mode Register. + /// + /// - `jit_withdraw`: The fees mode item; if set to `true` then fees for any instructions + /// are withdrawn as needed using the same mechanism as `WithdrawAssets`. + /// + /// Kind: *Instruction*. + /// + /// Errors: + SetFeesMode { jit_withdraw: bool }, } impl Xcm { @@ -839,7 +980,7 @@ impl Instruction { ReportError(response_info) => ReportError(response_info), DepositAsset { assets, beneficiary } => DepositAsset { assets, beneficiary }, DepositReserveAsset { assets, dest, xcm } => DepositReserveAsset { assets, dest, xcm }, - ExchangeAsset { give, receive } => ExchangeAsset { give, receive }, + ExchangeAsset { give, want, maximal } => ExchangeAsset { give, want, maximal }, InitiateReserveWithdraw { assets, reserve, xcm } => InitiateReserveWithdraw { assets, reserve, xcm }, InitiateTeleport { assets, dest, xcm } => InitiateTeleport { assets, dest, xcm }, @@ -869,6 +1010,11 @@ impl Instruction { UniversalOrigin(j) => UniversalOrigin(j), ExportMessage { network, destination, xcm } => ExportMessage { network, destination, xcm }, + LockAsset { asset, unlocker } => LockAsset { asset, unlocker }, + UnlockAsset { asset, target } => UnlockAsset { asset, target }, + NoteUnlockable { asset, owner } => NoteUnlockable { asset, owner }, + RequestUnlock { asset, locker } => RequestUnlock { asset, locker }, + SetFeesMode { jit_withdraw } => SetFeesMode { jit_withdraw }, } } } @@ -899,7 +1045,7 @@ impl> GetWeight for Instruction { DepositAsset { assets, beneficiary } => W::deposit_asset(assets, beneficiary), DepositReserveAsset { assets, dest, xcm } => W::deposit_reserve_asset(assets, dest, xcm), - ExchangeAsset { give, receive } => W::exchange_asset(give, receive), + ExchangeAsset { give, want, maximal } => W::exchange_asset(give, want, maximal), InitiateReserveWithdraw { assets, reserve, xcm } => W::initiate_reserve_withdraw(assets, reserve, xcm), InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm), @@ -927,6 +1073,11 @@ impl> GetWeight for Instruction { UniversalOrigin(j) => W::universal_origin(j), ExportMessage { network, destination, xcm } => W::export_message(network, destination, xcm), + LockAsset { asset, unlocker } => W::lock_asset(asset, unlocker), + UnlockAsset { asset, target } => W::unlock_asset(asset, target), + NoteUnlockable { asset, owner } => W::note_unlockable(asset, owner), + RequestUnlock { asset, locker } => W::request_unlock(asset, locker), + SetFeesMode { jit_withdraw } => W::set_fees_mode(jit_withdraw), } } } @@ -1017,8 +1168,8 @@ impl TryFrom> for Instruction { }, ExchangeAsset { give, receive } => { let give = give.try_into()?; - let receive = receive.try_into()?; - Self::ExchangeAsset { give, receive } + let want = receive.try_into()?; + Self::ExchangeAsset { give, want, maximal: true } }, InitiateReserveWithdraw { assets, reserve, xcm } => Self::InitiateReserveWithdraw { assets: assets.try_into()?, diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index 83cd37109f6d..9762fd97c02a 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -25,24 +25,152 @@ use super::MultiLocation; use crate::v2::{ - AssetId as OldAssetId, MultiAsset as OldMultiAsset, MultiAssetFilter as OldMultiAssetFilter, - MultiAssets as OldMultiAssets, WildMultiAsset as OldWildMultiAsset, + AssetId as OldAssetId, AssetInstance as OldAssetInstance, Fungibility as OldFungibility, + MultiAsset as OldMultiAsset, MultiAssetFilter as OldMultiAssetFilter, + MultiAssets as OldMultiAssets, WildFungibility as OldWildFungibility, + WildMultiAsset as OldWildMultiAsset, }; use alloc::{vec, vec::Vec}; use core::{ cmp::Ordering, convert::{TryFrom, TryInto}, }; -use parity_scale_codec::{self as codec, Decode, Encode}; +use parity_scale_codec::{self as codec, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -pub use crate::v2::{AssetInstance, Fungibility, WildFungibility}; +/// A general identifier for an instance of a non-fungible asset class. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] +pub enum AssetInstance { + /// Undefined - used if the non-fungible asset class has only one instance. + Undefined, + + /// A compact index. Technically this could be greater than `u128`, but this implementation supports only + /// values up to `2**128 - 1`. + Index(#[codec(compact)] u128), + + /// A 4-byte fixed-length datum. + Array4([u8; 4]), + + /// An 8-byte fixed-length datum. + Array8([u8; 8]), + + /// A 16-byte fixed-length datum. + Array16([u8; 16]), + + /// A 32-byte fixed-length datum. + Array32([u8; 32]), +} + +impl TryFrom for AssetInstance { + type Error = (); + fn try_from(value: OldAssetInstance) -> Result { + use OldAssetInstance::*; + Ok(match value { + Undefined => Self::Undefined, + Index(n) => Self::Index(n), + Array4(n) => Self::Array4(n), + Array8(n) => Self::Array8(n), + Array16(n) => Self::Array16(n), + Array32(n) => Self::Array32(n), + Blob(_) => return Err(()), + }) + } +} + +impl From<()> for AssetInstance { + fn from(_: ()) -> Self { + Self::Undefined + } +} + +impl From<[u8; 4]> for AssetInstance { + fn from(x: [u8; 4]) -> Self { + Self::Array4(x) + } +} + +impl From<[u8; 8]> for AssetInstance { + fn from(x: [u8; 8]) -> Self { + Self::Array8(x) + } +} + +impl From<[u8; 16]> for AssetInstance { + fn from(x: [u8; 16]) -> Self { + Self::Array16(x) + } +} + +impl From<[u8; 32]> for AssetInstance { + fn from(x: [u8; 32]) -> Self { + Self::Array32(x) + } +} + +/// Classification of whether an asset is fungible or not, along with a mandatory amount or instance. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +pub enum Fungibility { + Fungible(#[codec(compact)] u128), + NonFungible(AssetInstance), +} + +impl Fungibility { + pub fn is_kind(&self, w: WildFungibility) -> bool { + use Fungibility::*; + use WildFungibility::{Fungible as WildFungible, NonFungible as WildNonFungible}; + matches!((self, w), (Fungible(_), WildFungible) | (NonFungible(_), WildNonFungible)) + } +} + +impl From for Fungibility { + fn from(amount: u128) -> Fungibility { + debug_assert_ne!(amount, 0); + Fungibility::Fungible(amount) + } +} + +impl> From for Fungibility { + fn from(instance: T) -> Fungibility { + Fungibility::NonFungible(instance.into()) + } +} + +impl TryFrom for Fungibility { + type Error = (); + fn try_from(value: OldFungibility) -> Result { + use OldFungibility::*; + Ok(match value { + Fungible(n) => Self::Fungible(n), + NonFungible(i) => Self::NonFungible(i.try_into()?), + }) + } +} + +/// Classification of whether an asset is fungible or not. +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, +)] +pub enum WildFungibility { + Fungible, + NonFungible, +} + +impl TryFrom for WildFungibility { + type Error = (); + fn try_from(value: OldWildFungibility) -> Result { + use OldWildFungibility::*; + Ok(match value { + Fungible => Self::Fungible, + NonFungible => Self::NonFungible, + }) + } +} /// Classification of an asset being concrete or abstract. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] pub enum AssetId { Concrete(MultiLocation), - Abstract(Vec), + Abstract([u8; 32]), } impl> From for AssetId { @@ -51,8 +179,8 @@ impl> From for AssetId { } } -impl From> for AssetId { - fn from(x: Vec) -> Self { +impl From<[u8; 32]> for AssetId { + fn from(x: [u8; 32]) -> Self { Self::Abstract(x) } } @@ -63,7 +191,12 @@ impl TryFrom for AssetId { use OldAssetId::*; Ok(match old { Concrete(l) => Self::Concrete(l.try_into()?), - Abstract(v) => Self::Abstract(v), + Abstract(v) if v.len() <= 32 => { + let mut r = [0u8; 32]; + r.copy_from_slice(&v[..]); + Self::Abstract(r) + }, + _ => return Err(()), }) } } @@ -98,7 +231,7 @@ impl AssetId { } } -#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] pub struct MultiAsset { pub id: AssetId, pub fun: Fungibility, @@ -176,14 +309,25 @@ impl MultiAsset { impl TryFrom for MultiAsset { type Error = (); fn try_from(old: OldMultiAsset) -> Result { - Ok(Self { id: old.id.try_into()?, fun: old.fun }) + Ok(Self { id: old.id.try_into()?, fun: old.fun.try_into()? }) } } /// A `Vec` of `MultiAsset`s. There may be no duplicate fungible items in here and when decoding, they must be sorted. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo, Default)] +// TODO: Change to a `BoundedVec`. pub struct MultiAssets(Vec); +/// Maximum number of items we expect in a single `MultiAssets` value. Note this is not (yet) +/// enforced, and just serves to provide a sensible `max_encoded_len` for `MultiAssets`. +const MAX_ITEMS_IN_MULTIASSETS: usize = 20; + +impl MaxEncodedLen for MultiAssets { + fn max_encoded_len() -> usize { + MultiAsset::max_encoded_len() * MAX_ITEMS_IN_MULTIASSETS + } +} + impl Decode for MultiAssets { fn decode(input: &mut I) -> Result { Self::from_sorted_and_deduplicated(Vec::::decode(input)?) @@ -314,10 +458,16 @@ impl MultiAssets { } /// Consume `self` and return the inner vec. + #[deprecated = "Use `into_inner()` instead"] pub fn drain(self) -> Vec { self.0 } + /// Consume `self` and return the inner vec. + pub fn into_inner(self) -> Vec { + self.0 + } + /// Return a reference to the inner vec. pub fn inner(&self) -> &Vec { &self.0 @@ -346,7 +496,7 @@ impl MultiAssets { } /// A wildcard representing a set of assets. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] pub enum WildMultiAsset { /// All assets in Holding. All, @@ -370,7 +520,7 @@ impl TryFrom for WildMultiAsset { fn try_from(old: OldWildMultiAsset) -> Result { use OldWildMultiAsset::*; Ok(match old { - AllOf { id, fun } => Self::AllOf { id: id.try_into()?, fun }, + AllOf { id, fun } => Self::AllOf { id: id.try_into()?, fun: fun.try_into()? }, All => Self::All, }) } @@ -382,7 +532,8 @@ impl TryFrom<(OldWildMultiAsset, u32)> for WildMultiAsset { use OldWildMultiAsset::*; let count = old.1; Ok(match old.0 { - AllOf { id, fun } => Self::AllOfCounted { id: id.try_into()?, fun, count }, + AllOf { id, fun } => + Self::AllOfCounted { id: id.try_into()?, fun: fun.try_into()?, count }, All => Self::AllCounted(count), }) } @@ -455,7 +606,7 @@ impl, B: Into> From<(A, B)> for WildMultiAsset } /// `MultiAsset` collection, either `MultiAssets` or a single wildcard. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] pub enum MultiAssetFilter { Definite(MultiAssets), Wild(WildMultiAsset), diff --git a/xcm/src/v3/multilocation.rs b/xcm/src/v3/multilocation.rs index e5124be27abd..6cd684afa147 100644 --- a/xcm/src/v3/multilocation.rs +++ b/xcm/src/v3/multilocation.rs @@ -22,7 +22,7 @@ use core::{ convert::{TryFrom, TryInto}, result, }; -use parity_scale_codec::{Decode, Encode}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A relative path between state-bearing consensus systems. @@ -51,7 +51,7 @@ use scale_info::TypeInfo; /// that a value is strictly an interior location, in those cases, `Junctions` may be used. /// /// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system. -#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo)] +#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo, MaxEncodedLen)] pub struct MultiLocation { /// The number of parent junctions at the beginning of this `MultiLocation`. pub parents: u8, @@ -108,6 +108,11 @@ impl MultiLocation { self.parents == 0 && self.interior.len() == 0 } + /// Remove the `NetworkId` value in any interior `Junction`s. + pub fn remove_network_id(&mut self) { + self.interior.remove_network_id(); + } + /// Return a reference to the interior field. pub fn interior(&self) -> &Junctions { &self.interior @@ -715,13 +720,9 @@ mod tests { ); assert_eq!(v1::MultiLocation::from(v1::Parent).try_into(), Ok(MultiLocation::parent())); assert_eq!( - v1::MultiLocation::from(( - v1::Parent, - v1::Parent, - v1::Junction::GeneralKey(b"foo".to_vec()), - )) - .try_into(), - Ok(MultiLocation { parents: 2, interior: X1(GeneralKey(b"foo".to_vec())) }), + v1::MultiLocation::from((v1::Parent, v1::Parent, v1::Junction::GeneralIndex(42u128),)) + .try_into(), + Ok(MultiLocation { parents: 2, interior: X1(GeneralIndex(42u128)) }), ); } } diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 1072d140b980..357ebfc391ce 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}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use super::*; @@ -114,6 +114,15 @@ pub enum Error { /// `MultiLocation` value failed to be reanchored. #[codec(index = 28)] ReanchorFailed, + /// No deal is possible under the given constraints. + #[codec(index = 29)] + NoDeal, + /// Fees were required which the origin could not pay. + #[codec(index = 30)] + FeesNotMet, + /// Some other error with locking. + #[codec(index = 31)] + LockError, // Errors that happen prior to instructions being executed. These fall outside of the XCM spec. /// XCM version not able to be handled. @@ -132,6 +141,14 @@ pub enum Error { WeightNotComputable, } +impl MaxEncodedLen for Error { + fn max_encoded_len() -> usize { + // TODO: max_encoded_len doesn't quite work here as it tries to take notice of the fields + // marked `codec(skip)`. We can hard-code it with the right answer for now. + 1 + } +} + impl TryFrom for Error { type Error = (); fn try_from(old_error: OldError) -> result::Result { @@ -172,6 +189,7 @@ impl From for Error { SendError::Transport(s) => Error::Transport(s), SendError::DestinationUnsupported => Error::DestinationUnsupported, SendError::ExceedsMaxMessageSize => Error::ExceedsMaxMessageSize, + SendError::Fees => Error::FeesNotMet, } } } @@ -270,6 +288,10 @@ pub trait ExecuteXcm { } Self::execute(origin, pre, weight_credit) } + + /// Deduct some `fees` to the sovereign account of the given `location` and place them as per + /// the convention for fees. + fn charge_fees(location: impl Into, fees: MultiAssets) -> Result; } pub enum Weightless {} @@ -287,6 +309,9 @@ impl ExecuteXcm for () { fn execute(_: impl Into, _: Self::Prepared, _: Weight) -> Outcome { unreachable!() } + fn charge_fees(_location: impl Into, _fees: MultiAssets) -> Result { + Err(Error::Unimplemented) + } } /// Error result value when attempting to send an XCM message. @@ -311,6 +336,8 @@ pub enum SendError { ExceedsMaxMessageSize, /// A needed argument is `None` when it should be `Some`. MissingArgument, + /// Fees needed to be paid in order to send the message and they were unavailable. + Fees, } /// Result value when attempting to send an XCM message. diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index 1af8ff237d51..08d13b23cb6b 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -7,7 +7,7 @@ version = "0.9.17" [dependencies] impl-trait-for-tuples = "0.2.2" -parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive"] } +parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "1.0", default-features = false, features = ["derive"] } xcm = { path = "..", default-features = false } xcm-executor = { path = "../xcm-executor", default-features = false } diff --git a/xcm/xcm-builder/src/currency_adapter.rs b/xcm/xcm-builder/src/currency_adapter.rs index 86a2f5490155..fb616a961bdf 100644 --- a/xcm/xcm-builder/src/currency_adapter.rs +++ b/xcm/xcm-builder/src/currency_adapter.rs @@ -71,10 +71,13 @@ impl From for XcmError { /// /// messages from the parent (relay chain). /// pub type LocationConverter = (ParentIsPreset); /// +/// /// Just a dummy implementation of `Currency`. Normally this would be `Balances`. +/// pub type CurrencyImpl = (); +/// /// /// Final currency adapter. This can be used in `xcm::Config` to specify how asset related transactions happen. /// pub type AssetTransactor = CurrencyAdapter< -/// // Use this balance type: -/// u128, +/// // Use this `Currency` impl instance: +/// CurrencyImpl, /// // The matcher: use the currency when the asset is a concrete asset in our relay chain. /// IsConcrete, /// // The local converter: default account of the parent relay chain. @@ -90,9 +93,9 @@ pub struct CurrencyAdapter, Matcher: MatchesFungible, AccountIdConverter: Convert, - Currency: frame_support::traits::Currency, AccountId: Clone, // can't get away without it since Currency is generic over it. CheckedAccount: Get>, > TransactAsset diff --git a/xcm/xcm-builder/src/fungibles_adapter.rs b/xcm/xcm-builder/src/fungibles_adapter.rs index 082e3b6955df..cb7abd048d0d 100644 --- a/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/xcm/xcm-builder/src/fungibles_adapter.rs @@ -90,7 +90,7 @@ pub struct ConvertedAbstractAssetId, AssetId>, + ConvertAssetId: Convert<[u8; 32], AssetId>, ConvertBalance: Convert, > MatchesFungibles for ConvertedAbstractAssetId diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 20f57496e696..1cde398c7713 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -20,10 +20,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(test)] -mod bridging_tests; -#[cfg(test)] -mod mock; #[cfg(test)] mod tests; @@ -60,8 +56,6 @@ pub use fungibles_adapter::{ }; mod weight; -#[allow(deprecated)] -pub use weight::FixedRateOfConcreteFungible; pub use weight::{ FixedRateOfFungible, FixedWeightBounds, TakeRevenue, UsingComponents, WeightInfoBounds, }; diff --git a/xcm/xcm-builder/src/matches_fungible.rs b/xcm/xcm-builder/src/matches_fungible.rs index 6c33e18fe97c..d1ba33f6146e 100644 --- a/xcm/xcm-builder/src/matches_fungible.rs +++ b/xcm/xcm-builder/src/matches_fungible.rs @@ -67,17 +67,17 @@ impl, B: TryFrom> MatchesFungible for IsConcrete< /// use xcm_executor::traits::MatchesFungible; /// /// frame_support::parameter_types! { -/// pub TargetLocation: &'static [u8] = &[7u8]; +/// pub TargetLocation: [u8; 32] = [7u8; 32]; /// } /// /// # fn main() { -/// let asset = (vec![7u8], 999).into(); +/// let asset = ([7u8; 32], 999).into(); /// // match `asset` if it is a concrete asset in `TargetLocation`. /// assert_eq!( as MatchesFungible>::matches_fungible(&asset), Some(999)); /// # } /// ``` pub struct IsAbstract(PhantomData); -impl, B: TryFrom> MatchesFungible for IsAbstract { +impl, B: TryFrom> MatchesFungible for IsAbstract { fn matches_fungible(a: &MultiAsset) -> Option { match (&a.id, &a.fun) { (Abstract(ref id), Fungible(ref amount)) if id == &T::get() => diff --git a/xcm/xcm-builder/src/tests.rs b/xcm/xcm-builder/src/tests.rs deleted file mode 100644 index b9611fad829d..000000000000 --- a/xcm/xcm-builder/src/tests.rs +++ /dev/null @@ -1,1282 +0,0 @@ -// Copyright 2020 Parity Technologies query_id: (), max_response_weight: () query_id: (), max_response_weight: () (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 . - -use super::{mock::*, test_utils::*, *}; -use frame_support::{assert_err, traits::ConstU32, weights::constants::WEIGHT_PER_SECOND}; -use xcm_executor::{traits::*, Config, XcmExecutor}; - -#[test] -fn basic_setup_works() { - add_reserve(Parent.into(), Wild((Parent, WildFungible).into())); - assert!(::IsReserve::filter_asset_location( - &(Parent, 100).into(), - &Parent.into(), - )); - - assert_eq!(to_account(Parachain(1)), Ok(1001)); - assert_eq!(to_account(Parachain(50)), Ok(1050)); - assert_eq!(to_account((Parent, Parachain(1))), Ok(2001)); - assert_eq!(to_account((Parent, Parachain(50))), Ok(2050)); - assert_eq!( - to_account(MultiLocation::new(0, X1(AccountIndex64 { index: 1, network: None }))), - Ok(1), - ); - assert_eq!( - to_account(MultiLocation::new(0, X1(AccountIndex64 { index: 42, network: None }))), - Ok(42), - ); - assert_eq!(to_account(Here), Ok(3000)); -} - -#[test] -fn weigher_should_work() { - let mut message = Xcm(vec![ - ReserveAssetDeposited((Parent, 100).into()), - BuyExecution { fees: (Parent, 1).into(), weight_limit: Limited(30) }, - DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, - ]); - assert_eq!(::Weigher::weight(&mut message), Ok(30)); -} - -#[test] -fn take_weight_credit_barrier_should_work() { - let mut message = - Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); - let mut weight_credit = 10; - let r = TakeWeightCredit::should_execute( - &Parent.into(), - message.inner_mut(), - 10, - &mut weight_credit, - ); - assert_eq!(r, Ok(())); - assert_eq!(weight_credit, 0); - - let r = TakeWeightCredit::should_execute( - &Parent.into(), - message.inner_mut(), - 10, - &mut weight_credit, - ); - assert_eq!(r, Err(())); - assert_eq!(weight_credit, 0); -} - -#[test] -fn computed_origin_should_work() { - let mut message = Xcm::<()>(vec![ - UniversalOrigin(GlobalConsensus(Kusama)), - DescendOrigin(Parachain(100).into()), - DescendOrigin(PalletInstance(69).into()), - WithdrawAsset((Parent, 100).into()), - BuyExecution { fees: (Parent, 100).into(), weight_limit: Limited(100) }, - TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, - ]); - - AllowPaidFrom::set(vec![( - Parent, - Parent, - GlobalConsensus(Kusama), - Parachain(100), - PalletInstance(69), - ) - .into()]); - - let r = AllowTopLevelPaidExecutionFrom::>::should_execute( - &Parent.into(), - message.inner_mut(), - 100, - &mut 0, - ); - assert_eq!(r, Err(())); - - let r = WithComputedOrigin::< - AllowTopLevelPaidExecutionFrom>, - ExecutorUniversalLocation, - ConstU32<2>, - >::should_execute(&Parent.into(), message.inner_mut(), 100, &mut 0); - assert_eq!(r, Err(())); - - let r = WithComputedOrigin::< - AllowTopLevelPaidExecutionFrom>, - ExecutorUniversalLocation, - ConstU32<5>, - >::should_execute(&Parent.into(), message.inner_mut(), 100, &mut 0); - assert_eq!(r, Ok(())); -} - -#[test] -fn allow_unpaid_should_work() { - let mut message = - Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); - - AllowUnpaidFrom::set(vec![Parent.into()]); - - let r = AllowUnpaidExecutionFrom::>::should_execute( - &Parachain(1).into(), - message.inner_mut(), - 10, - &mut 0, - ); - assert_eq!(r, Err(())); - - let r = AllowUnpaidExecutionFrom::>::should_execute( - &Parent.into(), - message.inner_mut(), - 10, - &mut 0, - ); - assert_eq!(r, Ok(())); -} - -#[test] -fn allow_paid_should_work() { - AllowPaidFrom::set(vec![Parent.into()]); - - let mut message = - Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); - - let r = AllowTopLevelPaidExecutionFrom::>::should_execute( - &Parachain(1).into(), - message.inner_mut(), - 10, - &mut 0, - ); - assert_eq!(r, Err(())); - - let fees = (Parent, 1).into(); - let mut underpaying_message = Xcm::<()>(vec![ - ReserveAssetDeposited((Parent, 100).into()), - BuyExecution { fees, weight_limit: Limited(20) }, - DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, - ]); - - let r = AllowTopLevelPaidExecutionFrom::>::should_execute( - &Parent.into(), - underpaying_message.inner_mut(), - 30, - &mut 0, - ); - assert_eq!(r, Err(())); - - let fees = (Parent, 1).into(); - let mut paying_message = Xcm::<()>(vec![ - ReserveAssetDeposited((Parent, 100).into()), - BuyExecution { fees, weight_limit: Limited(30) }, - DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, - ]); - - let r = AllowTopLevelPaidExecutionFrom::>::should_execute( - &Parachain(1).into(), - paying_message.inner_mut(), - 30, - &mut 0, - ); - assert_eq!(r, Err(())); - - let r = AllowTopLevelPaidExecutionFrom::>::should_execute( - &Parent.into(), - paying_message.inner_mut(), - 30, - &mut 0, - ); - assert_eq!(r, Ok(())); -} - -#[test] -fn paying_reserve_deposit_should_work() { - AllowPaidFrom::set(vec![Parent.into()]); - add_reserve(Parent.into(), (Parent, WildFungible).into()); - WeightPrice::set((Parent.into(), 1_000_000_000_000)); - - let fees = (Parent, 30).into(); - let message = Xcm(vec![ - ReserveAssetDeposited((Parent, 100).into()), - BuyExecution { fees, weight_limit: Limited(30) }, - DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, - ]); - let weight_limit = 50; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Complete(30)); - assert_eq!(assets(3000), vec![(Parent, 70).into()]); -} - -#[test] -fn transfer_should_work() { - // we'll let them have message execution for free. - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - // Child parachain #1 owns 1000 tokens held by us in reserve. - add_asset(1001, (Here, 1000)); - // They want to transfer 100 of them to their sibling parachain #2 - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![TransferAsset { - assets: (Here, 100).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }]), - 50, - ); - assert_eq!(r, Outcome::Complete(10)); - assert_eq!(assets(3), vec![(Here, 100).into()]); - assert_eq!(assets(1001), vec![(Here, 900).into()]); - assert_eq!(sent_xcm(), vec![]); -} - -#[test] -fn universal_origin_should_work() { - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into(), X1(Parachain(2)).into()]); - clear_universal_aliases(); - // Parachain 1 may represent Kusama to us - add_universal_alias(Parachain(1), Kusama); - // Parachain 2 may represent Polkadot to us - add_universal_alias(Parachain(2), Polkadot); - - let r = XcmExecutor::::execute_xcm( - Parachain(2), - Xcm(vec![ - UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, - ]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::InvalidLocation)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, - ]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); - - add_asset(4000, (Parent, 100)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, - ]), - 50, - ); - assert_eq!(r, Outcome::Complete(20)); - assert_eq!(assets(4000), vec![]); -} - -#[test] -fn export_message_should_work() { - // Bridge chain (assumed to be Relay) lets Parachain #1 have message execution for free. - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - // Local parachain #1 issues a transfer asset on Polkadot Relay-chain, transfering 100 Planck to - // Polkadot parachain #2. - let message = - Xcm(vec![TransferAsset { assets: (Here, 100).into(), beneficiary: Parachain(2).into() }]); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExportMessage { network: Polkadot, destination: Here, xcm: message.clone() }]), - 50, - ); - assert_eq!(r, Outcome::Complete(10)); - assert_eq!(exported_xcm(), vec![(Polkadot, 403611790, Here, message)]); -} - -#[test] -fn basic_asset_trap_should_work() { - // we'll let them have message execution for free. - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into(), X1(Parachain(2)).into()]); - - // Child parachain #1 owns 1000 tokens held by us in reserve. - add_asset(1001, (Here, 1000)); - // They want to transfer 100 of them to their sibling parachain #2 but have a problem - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((Here, 100).into()), - DepositAsset { - assets: Wild(AllCounted(0)), // <<< 0 is an error. - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); - assert_eq!(r, Outcome::Complete(25)); - assert_eq!(assets(1001), vec![(Here, 900).into()]); - assert_eq!(assets(3), vec![]); - - // Incorrect ticket doesn't work. - let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(1).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); - assert_eq!(assets(1001), vec![(Here, 900).into()]); - assert_eq!(assets(3), vec![]); - assert_eq!(old_trapped_assets, TrappedAssets::get()); - - // Incorrect origin doesn't work. - let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm( - Parachain(2), - Xcm(vec![ - ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); - assert_eq!(assets(1001), vec![(Here, 900).into()]); - assert_eq!(assets(3), vec![]); - assert_eq!(old_trapped_assets, TrappedAssets::get()); - - // Incorrect assets doesn't work. - let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - ClaimAsset { assets: (Here, 101).into(), ticket: GeneralIndex(0).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); - assert_eq!(assets(1001), vec![(Here, 900).into()]); - assert_eq!(assets(3), vec![]); - assert_eq!(old_trapped_assets, TrappedAssets::get()); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); - assert_eq!(r, Outcome::Complete(20)); - assert_eq!(assets(1001), vec![(Here, 900).into()]); - assert_eq!(assets(3), vec![(Here, 100).into()]); - - // Same again doesn't work :-) - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); -} - -#[test] -fn errors_should_return_unused_weight() { - // we'll let them have message execution for free. - AllowUnpaidFrom::set(vec![Here.into()]); - // We own 1000 of our tokens. - add_asset(3000, (Here, 11)); - let mut message = Xcm(vec![ - // First xfer results in an error on the last message only - TransferAsset { - assets: (Here, 1).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }, - // Second xfer results in error third message and after - TransferAsset { - assets: (Here, 2).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }, - // Third xfer results in error second message and after - TransferAsset { - assets: (Here, 4).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }, - ]); - // Weight limit of 70 is needed. - let limit = ::Weigher::weight(&mut message).unwrap(); - assert_eq!(limit, 30); - - let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); - assert_eq!(r, Outcome::Complete(30)); - assert_eq!(assets(3), vec![(Here, 7).into()]); - assert_eq!(assets(3000), vec![(Here, 4).into()]); - assert_eq!(sent_xcm(), vec![]); - - let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); - assert_eq!(r, Outcome::Incomplete(30, XcmError::NotWithdrawable)); - assert_eq!(assets(3), vec![(Here, 10).into()]); - assert_eq!(assets(3000), vec![(Here, 1).into()]); - assert_eq!(sent_xcm(), vec![]); - - let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); - assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); - assert_eq!(assets(3), vec![(Here, 11).into()]); - assert_eq!(assets(3000), vec![]); - assert_eq!(sent_xcm(), vec![]); - - let r = XcmExecutor::::execute_xcm(Here, message, limit); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NotWithdrawable)); - assert_eq!(assets(3), vec![(Here, 11).into()]); - assert_eq!(assets(3000), vec![]); - assert_eq!(sent_xcm(), vec![]); -} - -#[test] -fn weight_bounds_should_respect_instructions_limit() { - MaxInstructions::set(3); - let mut message = Xcm(vec![ClearOrigin; 4]); - // 4 instructions are too many. - assert_eq!(::Weigher::weight(&mut message), Err(())); - - let mut message = - Xcm(vec![SetErrorHandler(Xcm(vec![ClearOrigin])), SetAppendix(Xcm(vec![ClearOrigin]))]); - // 4 instructions are too many, even when hidden within 2. - assert_eq!(::Weigher::weight(&mut message), Err(())); - - let mut message = - Xcm(vec![SetErrorHandler(Xcm(vec![SetErrorHandler(Xcm(vec![SetErrorHandler(Xcm( - vec![ClearOrigin], - ))]))]))]); - // 4 instructions are too many, even when it's just one that's 3 levels deep. - assert_eq!(::Weigher::weight(&mut message), Err(())); - - let mut message = - Xcm(vec![SetErrorHandler(Xcm(vec![SetErrorHandler(Xcm(vec![ClearOrigin]))]))]); - // 3 instructions are OK. - assert_eq!(::Weigher::weight(&mut message), Ok(30)); -} - -#[test] -fn code_registers_should_work() { - // we'll let them have message execution for free. - AllowUnpaidFrom::set(vec![Here.into()]); - // We own 1000 of our tokens. - add_asset(3000, (Here, 21)); - let mut message = Xcm(vec![ - // Set our error handler - this will fire only on the second message, when there's an error - SetErrorHandler(Xcm(vec![ - TransferAsset { - assets: (Here, 2).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }, - // It was handled fine. - ClearError, - ])), - // Set the appendix - this will always fire. - SetAppendix(Xcm(vec![TransferAsset { - assets: (Here, 4).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }])), - // First xfer always works ok - TransferAsset { - assets: (Here, 1).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }, - // Second xfer results in error on the second message - our error handler will fire. - TransferAsset { - assets: (Here, 8).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }, - ]); - // Weight limit of 70 is needed. - let limit = ::Weigher::weight(&mut message).unwrap(); - assert_eq!(limit, 70); - - let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); - assert_eq!(r, Outcome::Complete(50)); // We don't pay the 20 weight for the error handler. - assert_eq!(assets(3), vec![(Here, 13).into()]); - assert_eq!(assets(3000), vec![(Here, 8).into()]); - assert_eq!(sent_xcm(), vec![]); - - let r = XcmExecutor::::execute_xcm(Here, message, limit); - assert_eq!(r, Outcome::Complete(70)); // We pay the full weight here. - assert_eq!(assets(3), vec![(Here, 20).into()]); - assert_eq!(assets(3000), vec![(Here, 1).into()]); - assert_eq!(sent_xcm(), vec![]); -} - -#[test] -fn reserve_transfer_should_work() { - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - // Child parachain #1 owns 1000 tokens held by us in reserve. - add_asset(1001, (Here, 1000)); - // The remote account owned by gav. - let three: MultiLocation = X1(AccountIndex64 { index: 3, network: None }).into(); - - // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 - // and let them know to hand it to account #3. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![TransferReserveAsset { - assets: (Here, 100).into(), - dest: Parachain(2).into(), - xcm: Xcm::<()>(vec![DepositAsset { - assets: AllCounted(1).into(), - beneficiary: three.clone(), - }]), - }]), - 50, - ); - assert_eq!(r, Outcome::Complete(10)); - - assert_eq!(assets(1002), vec![(Here, 100).into()]); - assert_eq!( - sent_xcm(), - vec![( - Parachain(2).into(), - Xcm::<()>(vec![ - ReserveAssetDeposited((Parent, 100).into()), - ClearOrigin, - DepositAsset { assets: AllCounted(1).into(), beneficiary: three }, - ]), - )] - ); -} - -#[test] -fn simple_version_subscriptions_should_work() { - AllowSubsFrom::set(vec![Parent.into()]); - - let origin = Parachain(1000); - let message = Xcm::(vec![ - SetAppendix(Xcm(vec![])), - SubscribeVersion { query_id: 42, max_response_weight: 5000 }, - ]); - let weight_limit = 20; - let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); - assert_eq!(r, Outcome::Error(XcmError::Barrier)); - - let origin = Parachain(1000); - let message = - Xcm::(vec![SubscribeVersion { query_id: 42, max_response_weight: 5000 }]); - let weight_limit = 10; - let r = XcmExecutor::::execute_xcm(origin, message.clone(), weight_limit); - assert_eq!(r, Outcome::Error(XcmError::Barrier)); - - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Complete(10)); - - assert_eq!(SubscriptionRequests::get(), vec![(Parent.into(), Some((42, 5000)))]); -} - -#[test] -fn version_subscription_instruction_should_work() { - let origin = Parachain(1000); - let message = Xcm::(vec![ - DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), - SubscribeVersion { query_id: 42, max_response_weight: 5000 }, - ]); - let weight_limit = 20; - let r = XcmExecutor::::execute_xcm_in_credit( - origin.clone(), - message.clone(), - weight_limit, - weight_limit, - ); - assert_eq!(r, Outcome::Incomplete(20, XcmError::BadOrigin)); - - let message = Xcm::(vec![ - SetAppendix(Xcm(vec![])), - SubscribeVersion { query_id: 42, max_response_weight: 5000 }, - ]); - let r = XcmExecutor::::execute_xcm_in_credit( - origin, - message.clone(), - weight_limit, - weight_limit, - ); - assert_eq!(r, Outcome::Complete(20)); - - assert_eq!(SubscriptionRequests::get(), vec![(Parachain(1000).into(), Some((42, 5000)))]); -} - -#[test] -fn simple_version_unsubscriptions_should_work() { - AllowSubsFrom::set(vec![Parent.into()]); - - let origin = Parachain(1000); - let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); - let weight_limit = 20; - let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); - assert_eq!(r, Outcome::Error(XcmError::Barrier)); - - let origin = Parachain(1000); - let message = Xcm::(vec![UnsubscribeVersion]); - let weight_limit = 10; - let r = XcmExecutor::::execute_xcm(origin, message.clone(), weight_limit); - assert_eq!(r, Outcome::Error(XcmError::Barrier)); - - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Complete(10)); - - assert_eq!(SubscriptionRequests::get(), vec![(Parent.into(), None)]); - assert_eq!(sent_xcm(), vec![]); -} - -#[test] -fn version_unsubscription_instruction_should_work() { - let origin = Parachain(1000); - - // Not allowed to do it when origin has been changed. - let message = Xcm::(vec![ - DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), - UnsubscribeVersion, - ]); - let weight_limit = 20; - let r = XcmExecutor::::execute_xcm_in_credit( - origin.clone(), - message.clone(), - weight_limit, - weight_limit, - ); - assert_eq!(r, Outcome::Incomplete(20, XcmError::BadOrigin)); - - // Fine to do it when origin is untouched. - let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); - let r = XcmExecutor::::execute_xcm_in_credit( - origin, - message.clone(), - weight_limit, - weight_limit, - ); - assert_eq!(r, Outcome::Complete(20)); - - assert_eq!(SubscriptionRequests::get(), vec![(Parachain(1000).into(), None)]); - assert_eq!(sent_xcm(), vec![]); -} - -#[test] -fn transacting_should_work() { - AllowUnpaidFrom::set(vec![Parent.into()]); - - let message = Xcm::(vec![Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::Any(50, None).encode().into(), - }]); - let weight_limit = 60; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Complete(60)); -} - -#[test] -fn transacting_should_respect_max_weight_requirement() { - AllowUnpaidFrom::set(vec![Parent.into()]); - - let message = Xcm::(vec![Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: 40, - call: TestCall::Any(50, None).encode().into(), - }]); - let weight_limit = 60; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Incomplete(50, XcmError::MaxWeightInvalid)); -} - -#[test] -fn transacting_should_refund_weight() { - AllowUnpaidFrom::set(vec![Parent.into()]); - - let message = Xcm::(vec![Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::Any(50, Some(30)).encode().into(), - }]); - let weight_limit = 60; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Complete(40)); -} - -#[test] -fn paid_transacting_should_refund_payment_for_unused_weight() { - let one: MultiLocation = AccountIndex64 { index: 1, network: None }.into(); - AllowPaidFrom::set(vec![one.clone()]); - add_asset(1, (Parent, 100)); - WeightPrice::set((Parent.into(), 1_000_000_000_000)); - - let origin = one.clone(); - let fees = (Parent, 100).into(); - let message = Xcm::(vec![ - WithdrawAsset((Parent, 100).into()), // enough for 100 units of weight. - BuyExecution { fees, weight_limit: Limited(100) }, - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: 50, - // call estimated at 50 but only takes 10. - call: TestCall::Any(50, Some(10)).encode().into(), - }, - RefundSurplus, - DepositAsset { assets: AllCounted(1).into(), beneficiary: one.clone() }, - ]); - let weight_limit = 100; - let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); - assert_eq!(r, Outcome::Complete(60)); - assert_eq!(assets(1), vec![(Parent, 40).into()]); -} - -#[test] -fn prepaid_result_of_query_should_get_free_execution() { - let query_id = 33; - // We put this in manually here, but normally this would be done at the point of crafting the message. - expect_response(query_id, Parent.into()); - - let the_response = Response::Assets((Parent, 100).into()); - let message = Xcm::(vec![QueryResponse { - query_id, - response: the_response.clone(), - max_weight: 10, - querier: Some(Here.into()), - }]); - let weight_limit = 10; - - // First time the response gets through since we're expecting it... - let r = XcmExecutor::::execute_xcm(Parent, message.clone(), weight_limit); - assert_eq!(r, Outcome::Complete(10)); - assert_eq!(response(query_id).unwrap(), the_response); - - // Second time it doesn't, since we're not. - let r = XcmExecutor::::execute_xcm(Parent, message.clone(), weight_limit); - assert_eq!(r, Outcome::Error(XcmError::Barrier)); -} - -fn fungible_multi_asset(location: MultiLocation, amount: u128) -> MultiAsset { - (AssetId::from(location), Fungibility::Fungible(amount)).into() -} - -#[test] -fn weight_trader_tuple_should_work() { - let para_1: MultiLocation = Parachain(1).into(); - let para_2: MultiLocation = Parachain(2).into(); - - parameter_types! { - pub static HereWeightPrice: (AssetId, u128) = (Here.into(), WEIGHT_PER_SECOND.into()); - pub static Para1WeightPrice: (AssetId, u128) = (Parachain(1).into(), WEIGHT_PER_SECOND.into()); - } - - type Traders = ( - // trader one - FixedRateOfFungible, - // trader two - FixedRateOfFungible, - ); - - let mut traders = Traders::new(); - // trader one buys weight - assert_eq!( - traders.buy_weight(5, fungible_multi_asset(Here.into(), 10).into()), - Ok(fungible_multi_asset(Here.into(), 5).into()), - ); - // trader one refunds - assert_eq!(traders.refund_weight(2), Some(fungible_multi_asset(Here.into(), 2))); - - let mut traders = Traders::new(); - // trader one failed; trader two buys weight - assert_eq!( - traders.buy_weight(5, fungible_multi_asset(para_1.clone(), 10).into()), - Ok(fungible_multi_asset(para_1.clone(), 5).into()), - ); - // trader two refunds - assert_eq!(traders.refund_weight(2), Some(fungible_multi_asset(para_1, 2))); - - let mut traders = Traders::new(); - // all traders fails - assert_err!( - traders.buy_weight(5, fungible_multi_asset(para_2, 10).into()), - XcmError::TooExpensive, - ); - // and no refund - assert_eq!(traders.refund_weight(2), None); -} - -#[test] -fn pallet_query_should_work() { - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 - // and let them know to hand it to account #3. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![QueryPallet { - module_name: "Error".into(), - response_info: QueryResponseInfo { - destination: Parachain(1).into(), - query_id: 1, - max_weight: 50, - }, - }]), - 50, - ); - assert_eq!(r, Outcome::Complete(10)); - - assert_eq!( - sent_xcm(), - vec![( - Parachain(1).into(), - Xcm::<()>(vec![QueryResponse { - query_id: 1, - max_weight: 50, - response: Response::PalletsInfo(vec![]), - querier: Some(Here.into()), - }]), - )] - ); -} - -#[test] -fn pallet_query_with_results_should_work() { - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 - // and let them know to hand it to account #3. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![QueryPallet { - module_name: "pallet_balances".into(), - response_info: QueryResponseInfo { - destination: Parachain(1).into(), - query_id: 1, - max_weight: 50, - }, - }]), - 50, - ); - assert_eq!(r, Outcome::Complete(10)); - - assert_eq!( - sent_xcm(), - vec![( - Parachain(1).into(), - Xcm::<()>(vec![QueryResponse { - query_id: 1, - max_weight: 50, - response: Response::PalletsInfo(vec![PalletInfo { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - major: 1, - minor: 42, - patch: 69, - },]), - querier: Some(Here.into()), - }]), - )] - ); -} - -#[test] -fn report_successful_transact_status_should_work() { - AllowUnpaidFrom::set(vec![Parent.into()]); - - let message = Xcm::(vec![ - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::Any(50, None).encode().into(), - }, - ReportTransactStatus(QueryResponseInfo { - destination: Parent.into(), - query_id: 42, - max_weight: 5000, - }), - ]); - let weight_limit = 70; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Complete(70)); - assert_eq!( - sent_xcm(), - vec![( - Parent.into(), - Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Success), - query_id: 42, - max_weight: 5000, - querier: Some(Here.into()), - }]) - )] - ); -} - -#[test] -fn report_failed_transact_status_should_work() { - AllowUnpaidFrom::set(vec![Parent.into()]); - - let message = Xcm::(vec![ - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::OnlyRoot(50, None).encode().into(), - }, - ReportTransactStatus(QueryResponseInfo { - destination: Parent.into(), - query_id: 42, - max_weight: 5000, - }), - ]); - let weight_limit = 70; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Complete(70)); - assert_eq!( - sent_xcm(), - vec![( - Parent.into(), - Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), - query_id: 42, - max_weight: 5000, - querier: Some(Here.into()), - }]) - )] - ); -} - -#[test] -fn clear_transact_status_should_work() { - AllowUnpaidFrom::set(vec![Parent.into()]); - - let message = Xcm::(vec![ - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::OnlyRoot(50, None).encode().into(), - }, - ClearTransactStatus, - ReportTransactStatus(QueryResponseInfo { - destination: Parent.into(), - query_id: 42, - max_weight: 5000, - }), - ]); - let weight_limit = 80; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); - assert_eq!(r, Outcome::Complete(80)); - assert_eq!( - sent_xcm(), - vec![( - Parent.into(), - Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Success), - query_id: 42, - max_weight: 5000, - querier: Some(Here.into()), - }]) - )] - ); -} - -#[test] -fn max_assets_limit_should_work() { - // we'll let them have message execution for free. - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - // Child parachain #1 owns 1000 tokens held by us in reserve. - add_asset(1001, (vec![1], 1000)); - add_asset(1001, (vec![2], 1000)); - add_asset(1001, (vec![3], 1000)); - add_asset(1001, (vec![4], 1000)); - add_asset(1001, (vec![5], 1000)); - add_asset(1001, (vec![6], 1000)); - add_asset(1001, (vec![7], 1000)); - add_asset(1001, (vec![8], 1000)); - add_asset(1001, (vec![9], 1000)); - - // Attempt to withdraw 8 (=2x4)different assets. This will succeed. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((vec![1], 100).into()), - WithdrawAsset((vec![2], 100).into()), - WithdrawAsset((vec![3], 100).into()), - WithdrawAsset((vec![4], 100).into()), - WithdrawAsset((vec![5], 100).into()), - WithdrawAsset((vec![6], 100).into()), - WithdrawAsset((vec![7], 100).into()), - WithdrawAsset((vec![8], 100).into()), - ]), - 100, - ); - assert_eq!(r, Outcome::Complete(85)); - - // Attempt to withdraw 9 different assets will fail. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((vec![1], 100).into()), - WithdrawAsset((vec![2], 100).into()), - WithdrawAsset((vec![3], 100).into()), - WithdrawAsset((vec![4], 100).into()), - WithdrawAsset((vec![5], 100).into()), - WithdrawAsset((vec![6], 100).into()), - WithdrawAsset((vec![7], 100).into()), - WithdrawAsset((vec![8], 100).into()), - WithdrawAsset((vec![9], 100).into()), - ]), - 100, - ); - assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); - - // Attempt to withdraw 4 different assets and then the same 4 and then a different 4 will succeed. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((vec![1], 100).into()), - WithdrawAsset((vec![2], 100).into()), - WithdrawAsset((vec![3], 100).into()), - WithdrawAsset((vec![4], 100).into()), - WithdrawAsset((vec![1], 100).into()), - WithdrawAsset((vec![2], 100).into()), - WithdrawAsset((vec![3], 100).into()), - WithdrawAsset((vec![4], 100).into()), - WithdrawAsset((vec![5], 100).into()), - WithdrawAsset((vec![6], 100).into()), - WithdrawAsset((vec![7], 100).into()), - WithdrawAsset((vec![8], 100).into()), - ]), - 200, - ); - assert_eq!(r, Outcome::Complete(125)); - - // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((vec![1], 100).into()), - WithdrawAsset((vec![2], 100).into()), - WithdrawAsset((vec![3], 100).into()), - WithdrawAsset((vec![4], 100).into()), - WithdrawAsset((vec![5], 100).into()), - WithdrawAsset((vec![6], 100).into()), - WithdrawAsset((vec![7], 100).into()), - WithdrawAsset((vec![8], 100).into()), - WithdrawAsset((vec![1], 100).into()), - WithdrawAsset((vec![2], 100).into()), - WithdrawAsset((vec![3], 100).into()), - WithdrawAsset((vec![4], 100).into()), - ]), - 200, - ); - assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); - - // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset(MultiAssets::from(vec![ - (vec![1], 100).into(), - (vec![2], 100).into(), - (vec![3], 100).into(), - (vec![4], 100).into(), - (vec![5], 100).into(), - (vec![6], 100).into(), - (vec![7], 100).into(), - (vec![8], 100).into(), - ])), - WithdrawAsset((vec![1], 100).into()), - ]), - 200, - ); - assert_eq!(r, Outcome::Incomplete(25, XcmError::HoldingWouldOverflow)); -} - -#[test] -fn burn_should_work() { - // we'll let them have message execution for free. - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - // Child parachain #1 owns 1000 tokens held by us in reserve. - add_asset(1001, (Here, 1000)); - // They want to burn 100 of them - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((Here, 1000).into()), - BurnAsset((Here, 100).into()), - DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, - ]), - 50, - ); - assert_eq!(r, Outcome::Complete(30)); - assert_eq!(assets(1001), vec![(Here, 900).into()]); - assert_eq!(sent_xcm(), vec![]); - - // Now they want to burn 1000 of them, which will actually only burn 900. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((Here, 900).into()), - BurnAsset((Here, 1000).into()), - DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, - ]), - 50, - ); - assert_eq!(r, Outcome::Complete(30)); - assert_eq!(assets(1001), vec![]); - assert_eq!(sent_xcm(), vec![]); -} - -#[test] -fn expect_pallet_should_work() { - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 - // and let them know to hand it to account #3. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); - assert_eq!(r, Outcome::Complete(10)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 41, - }]), - 50, - ); - assert_eq!(r, Outcome::Complete(10)); -} - -#[test] -fn expect_pallet_should_fail_correctly() { - AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 60, - }]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"System".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_system".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 0, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 2, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::PalletNotFound)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 2, - min_crate_minor: 42, - }]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 0, - min_crate_minor: 42, - }]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); - - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 43, - }]), - 50, - ); - assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); -} diff --git a/xcm/xcm-builder/src/tests/assets.rs b/xcm/xcm-builder/src/tests/assets.rs new file mode 100644 index 000000000000..e3d4c9ab75fe --- /dev/null +++ b/xcm/xcm-builder/src/tests/assets.rs @@ -0,0 +1,427 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn exchange_asset_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + add_asset(Parent, (Parent, 1000)); + set_exchange_assets(vec![(Here, 100).into()]); + let r = XcmExecutor::::execute_xcm( + Parent, + Xcm(vec![ + WithdrawAsset((Parent, 100).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] + .into(), + ), + ExchangeAsset { + give: Definite((Parent, 50).into()), + want: (Here, 50).into(), + maximal: true, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(40)); + assert_eq!(asset_list(Parent), vec![(Here, 100).into(), (Parent, 950).into()]); + assert_eq!(exchange_assets(), vec![(Parent, 50).into()].into()); +} + +#[test] +fn exchange_asset_without_maximal_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + add_asset(Parent, (Parent, 1000)); + set_exchange_assets(vec![(Here, 100).into()]); + let r = XcmExecutor::::execute_xcm( + Parent, + Xcm(vec![ + WithdrawAsset((Parent, 100).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] + .into(), + ), + ExchangeAsset { + give: Definite((Parent, 50).into()), + want: (Here, 50).into(), + maximal: false, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(40)); + assert_eq!(asset_list(Parent), vec![(Here, 50).into(), (Parent, 950).into()]); + assert_eq!(exchange_assets(), vec![(Here, 50).into(), (Parent, 50).into()].into()); +} + +#[test] +fn exchange_asset_should_fail_when_no_deal_possible() { + AllowUnpaidFrom::set(vec![Parent.into()]); + add_asset(Parent, (Parent, 1000)); + set_exchange_assets(vec![(Here, 100).into()]); + let r = XcmExecutor::::execute_xcm( + Parent, + Xcm(vec![ + WithdrawAsset((Parent, 150).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] + .into(), + ), + ExchangeAsset { + give: Definite((Parent, 150).into()), + want: (Here, 150).into(), + maximal: false, + }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(40, XcmError::NoDeal)); + assert_eq!(asset_list(Parent), vec![(Parent, 1000).into()]); + assert_eq!(exchange_assets(), vec![(Here, 100).into()].into()); +} + +#[test] +fn paying_reserve_deposit_should_work() { + AllowPaidFrom::set(vec![Parent.into()]); + add_reserve(Parent.into(), (Parent, WildFungible).into()); + WeightPrice::set((Parent.into(), 1_000_000_000_000)); + + let fees = (Parent, 30).into(); + let message = Xcm(vec![ + ReserveAssetDeposited((Parent, 100).into()), + BuyExecution { fees, weight_limit: Limited(30) }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, + ]); + let weight_limit = 50; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(30)); + assert_eq!(asset_list(Here), vec![(Parent, 70).into()]); +} + +#[test] +fn transfer_should_work() { + // we'll let them have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Child parachain #1 owns 1000 tokens held by us in reserve. + add_asset(Parachain(1), (Here, 1000)); + // They want to transfer 100 of them to their sibling parachain #2 + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![TransferAsset { + assets: (Here, 100).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 100).into()]); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(sent_xcm(), vec![]); +} + +#[test] +fn reserve_transfer_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Child parachain #1 owns 1000 tokens held by us in reserve. + add_asset(Parachain(1), (Here, 1000)); + // The remote account owned by gav. + let three: MultiLocation = X1(AccountIndex64 { index: 3, network: None }).into(); + + // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 + // and let them know to hand it to account #3. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![TransferReserveAsset { + assets: (Here, 100).into(), + dest: Parachain(2).into(), + xcm: Xcm::<()>(vec![DepositAsset { + assets: AllCounted(1).into(), + beneficiary: three.clone(), + }]), + }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + + assert_eq!(asset_list(Parachain(2)), vec![(Here, 100).into()]); + assert_eq!( + sent_xcm(), + vec![( + Parachain(2).into(), + Xcm::<()>(vec![ + ReserveAssetDeposited((Parent, 100).into()), + ClearOrigin, + DepositAsset { assets: AllCounted(1).into(), beneficiary: three }, + ]), + )] + ); +} + +#[test] +fn burn_should_work() { + // we'll let them have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Child parachain #1 owns 1000 tokens held by us in reserve. + add_asset(Parachain(1), (Here, 1000)); + // They want to burn 100 of them + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((Here, 1000).into()), + BurnAsset((Here, 100).into()), + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(30)); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(sent_xcm(), vec![]); + + // Now they want to burn 1000 of them, which will actually only burn 900. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((Here, 900).into()), + BurnAsset((Here, 1000).into()), + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(30)); + assert_eq!(asset_list(Parachain(1)), vec![]); + assert_eq!(sent_xcm(), vec![]); +} + +#[test] +fn basic_asset_trap_should_work() { + // we'll let them have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into(), X1(Parachain(2)).into()]); + + // Child parachain #1 owns 1000 tokens held by us in reserve. + add_asset(Parachain(1), (Here, 1000)); + // They want to transfer 100 of them to their sibling parachain #2 but have a problem + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset((Here, 100).into()), + DepositAsset { + assets: Wild(AllCounted(0)), // <<< 0 is an error. + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]), + 20, + ); + assert_eq!(r, Outcome::Complete(25)); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); + + // Incorrect ticket doesn't work. + let old_trapped_assets = TrappedAssets::get(); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(1).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]), + 20, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); + assert_eq!(old_trapped_assets, TrappedAssets::get()); + + // Incorrect origin doesn't work. + let old_trapped_assets = TrappedAssets::get(); + let r = XcmExecutor::::execute_xcm( + Parachain(2), + Xcm(vec![ + ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]), + 20, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); + assert_eq!(old_trapped_assets, TrappedAssets::get()); + + // Incorrect assets doesn't work. + let old_trapped_assets = TrappedAssets::get(); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ClaimAsset { assets: (Here, 101).into(), ticket: GeneralIndex(0).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]), + 20, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); + assert_eq!(old_trapped_assets, TrappedAssets::get()); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]), + 20, + ); + assert_eq!(r, Outcome::Complete(20)); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 100).into()]); + + // Same again doesn't work :-) + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]), + 20, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); +} + +#[test] +fn max_assets_limit_should_work() { + // we'll let them have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Child parachain #1 owns 1000 tokens held by us in reserve. + add_asset(Parachain(1), ([1u8; 32], 1000)); + add_asset(Parachain(1), ([2u8; 32], 1000)); + add_asset(Parachain(1), ([3u8; 32], 1000)); + add_asset(Parachain(1), ([4u8; 32], 1000)); + add_asset(Parachain(1), ([5u8; 32], 1000)); + add_asset(Parachain(1), ([6u8; 32], 1000)); + add_asset(Parachain(1), ([7u8; 32], 1000)); + add_asset(Parachain(1), ([8u8; 32], 1000)); + add_asset(Parachain(1), ([9u8; 32], 1000)); + + // Attempt to withdraw 8 (=2x4)different assets. This will succeed. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset(([1u8; 32], 100).into()), + WithdrawAsset(([2u8; 32], 100).into()), + WithdrawAsset(([3u8; 32], 100).into()), + WithdrawAsset(([4u8; 32], 100).into()), + WithdrawAsset(([5u8; 32], 100).into()), + WithdrawAsset(([6u8; 32], 100).into()), + WithdrawAsset(([7u8; 32], 100).into()), + WithdrawAsset(([8u8; 32], 100).into()), + ]), + 100, + ); + assert_eq!(r, Outcome::Complete(85)); + + // Attempt to withdraw 9 different assets will fail. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset(([1u8; 32], 100).into()), + WithdrawAsset(([2u8; 32], 100).into()), + WithdrawAsset(([3u8; 32], 100).into()), + WithdrawAsset(([4u8; 32], 100).into()), + WithdrawAsset(([5u8; 32], 100).into()), + WithdrawAsset(([6u8; 32], 100).into()), + WithdrawAsset(([7u8; 32], 100).into()), + WithdrawAsset(([8u8; 32], 100).into()), + WithdrawAsset(([9u8; 32], 100).into()), + ]), + 100, + ); + assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); + + // Attempt to withdraw 4 different assets and then the same 4 and then a different 4 will succeed. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset(([1u8; 32], 100).into()), + WithdrawAsset(([2u8; 32], 100).into()), + WithdrawAsset(([3u8; 32], 100).into()), + WithdrawAsset(([4u8; 32], 100).into()), + WithdrawAsset(([1u8; 32], 100).into()), + WithdrawAsset(([2u8; 32], 100).into()), + WithdrawAsset(([3u8; 32], 100).into()), + WithdrawAsset(([4u8; 32], 100).into()), + WithdrawAsset(([5u8; 32], 100).into()), + WithdrawAsset(([6u8; 32], 100).into()), + WithdrawAsset(([7u8; 32], 100).into()), + WithdrawAsset(([8u8; 32], 100).into()), + ]), + 200, + ); + assert_eq!(r, Outcome::Complete(125)); + + // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset(([1u8; 32], 100).into()), + WithdrawAsset(([2u8; 32], 100).into()), + WithdrawAsset(([3u8; 32], 100).into()), + WithdrawAsset(([4u8; 32], 100).into()), + WithdrawAsset(([5u8; 32], 100).into()), + WithdrawAsset(([6u8; 32], 100).into()), + WithdrawAsset(([7u8; 32], 100).into()), + WithdrawAsset(([8u8; 32], 100).into()), + WithdrawAsset(([1u8; 32], 100).into()), + WithdrawAsset(([2u8; 32], 100).into()), + WithdrawAsset(([3u8; 32], 100).into()), + WithdrawAsset(([4u8; 32], 100).into()), + ]), + 200, + ); + assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); + + // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + WithdrawAsset(MultiAssets::from(vec![ + ([1u8; 32], 100).into(), + ([2u8; 32], 100).into(), + ([3u8; 32], 100).into(), + ([4u8; 32], 100).into(), + ([5u8; 32], 100).into(), + ([6u8; 32], 100).into(), + ([7u8; 32], 100).into(), + ([8u8; 32], 100).into(), + ])), + WithdrawAsset(([1u8; 32], 100).into()), + ]), + 200, + ); + assert_eq!(r, Outcome::Incomplete(25, XcmError::HoldingWouldOverflow)); +} diff --git a/xcm/xcm-builder/src/tests/barriers.rs b/xcm/xcm-builder/src/tests/barriers.rs new file mode 100644 index 000000000000..b3af3b6c4d1d --- /dev/null +++ b/xcm/xcm-builder/src/tests/barriers.rs @@ -0,0 +1,162 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn take_weight_credit_barrier_should_work() { + let mut message = + Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); + let mut weight_credit = 10; + let r = TakeWeightCredit::should_execute( + &Parent.into(), + message.inner_mut(), + 10, + &mut weight_credit, + ); + assert_eq!(r, Ok(())); + assert_eq!(weight_credit, 0); + + let r = TakeWeightCredit::should_execute( + &Parent.into(), + message.inner_mut(), + 10, + &mut weight_credit, + ); + assert_eq!(r, Err(())); + assert_eq!(weight_credit, 0); +} + +#[test] +fn computed_origin_should_work() { + let mut message = Xcm::<()>(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + DescendOrigin(Parachain(100).into()), + DescendOrigin(PalletInstance(69).into()), + WithdrawAsset((Parent, 100).into()), + BuyExecution { fees: (Parent, 100).into(), weight_limit: Limited(100) }, + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]); + + AllowPaidFrom::set(vec![( + Parent, + Parent, + GlobalConsensus(Kusama), + Parachain(100), + PalletInstance(69), + ) + .into()]); + + let r = AllowTopLevelPaidExecutionFrom::>::should_execute( + &Parent.into(), + message.inner_mut(), + 100, + &mut 0, + ); + assert_eq!(r, Err(())); + + let r = WithComputedOrigin::< + AllowTopLevelPaidExecutionFrom>, + ExecutorUniversalLocation, + ConstU32<2>, + >::should_execute(&Parent.into(), message.inner_mut(), 100, &mut 0); + assert_eq!(r, Err(())); + + let r = WithComputedOrigin::< + AllowTopLevelPaidExecutionFrom>, + ExecutorUniversalLocation, + ConstU32<5>, + >::should_execute(&Parent.into(), message.inner_mut(), 100, &mut 0); + assert_eq!(r, Ok(())); +} + +#[test] +fn allow_unpaid_should_work() { + let mut message = + Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); + + AllowUnpaidFrom::set(vec![Parent.into()]); + + let r = AllowUnpaidExecutionFrom::>::should_execute( + &Parachain(1).into(), + message.inner_mut(), + 10, + &mut 0, + ); + assert_eq!(r, Err(())); + + let r = AllowUnpaidExecutionFrom::>::should_execute( + &Parent.into(), + message.inner_mut(), + 10, + &mut 0, + ); + assert_eq!(r, Ok(())); +} + +#[test] +fn allow_paid_should_work() { + AllowPaidFrom::set(vec![Parent.into()]); + + let mut message = + Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); + + let r = AllowTopLevelPaidExecutionFrom::>::should_execute( + &Parachain(1).into(), + message.inner_mut(), + 10, + &mut 0, + ); + assert_eq!(r, Err(())); + + let fees = (Parent, 1).into(); + let mut underpaying_message = Xcm::<()>(vec![ + ReserveAssetDeposited((Parent, 100).into()), + BuyExecution { fees, weight_limit: Limited(20) }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, + ]); + + let r = AllowTopLevelPaidExecutionFrom::>::should_execute( + &Parent.into(), + underpaying_message.inner_mut(), + 30, + &mut 0, + ); + assert_eq!(r, Err(())); + + let fees = (Parent, 1).into(); + let mut paying_message = Xcm::<()>(vec![ + ReserveAssetDeposited((Parent, 100).into()), + BuyExecution { fees, weight_limit: Limited(30) }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, + ]); + + let r = AllowTopLevelPaidExecutionFrom::>::should_execute( + &Parachain(1).into(), + paying_message.inner_mut(), + 30, + &mut 0, + ); + assert_eq!(r, Err(())); + + let r = AllowTopLevelPaidExecutionFrom::>::should_execute( + &Parent.into(), + paying_message.inner_mut(), + 30, + &mut 0, + ); + assert_eq!(r, Ok(())); +} diff --git a/xcm/xcm-builder/src/tests/basic.rs b/xcm/xcm-builder/src/tests/basic.rs new file mode 100644 index 000000000000..1b611d5b6168 --- /dev/null +++ b/xcm/xcm-builder/src/tests/basic.rs @@ -0,0 +1,99 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn basic_setup_works() { + add_reserve(Parent.into(), Wild((Parent, WildFungible).into())); + assert!(::IsReserve::filter_asset_location( + &(Parent, 100).into(), + &Parent.into(), + )); + + assert_eq!(to_account(Parachain(1)), Ok(1001)); + assert_eq!(to_account(Parachain(50)), Ok(1050)); + assert_eq!(to_account((Parent, Parachain(1))), Ok(2001)); + assert_eq!(to_account((Parent, Parachain(50))), Ok(2050)); + assert_eq!( + to_account(MultiLocation::new(0, X1(AccountIndex64 { index: 1, network: None }))), + Ok(1), + ); + assert_eq!( + to_account(MultiLocation::new(0, X1(AccountIndex64 { index: 42, network: None }))), + Ok(42), + ); + assert_eq!(to_account(Here), Ok(3000)); +} + +#[test] +fn weigher_should_work() { + let mut message = Xcm(vec![ + ReserveAssetDeposited((Parent, 100).into()), + BuyExecution { fees: (Parent, 1).into(), weight_limit: Limited(30) }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, + ]); + assert_eq!(::Weigher::weight(&mut message), Ok(30)); +} + +#[test] +fn code_registers_should_work() { + // we'll let them have message execution for free. + AllowUnpaidFrom::set(vec![Here.into()]); + // We own 1000 of our tokens. + add_asset(Here, (Here, 21)); + let mut message = Xcm(vec![ + // Set our error handler - this will fire only on the second message, when there's an error + SetErrorHandler(Xcm(vec![ + TransferAsset { + assets: (Here, 2).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }, + // It was handled fine. + ClearError, + ])), + // Set the appendix - this will always fire. + SetAppendix(Xcm(vec![TransferAsset { + assets: (Here, 4).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }])), + // First xfer always works ok + TransferAsset { + assets: (Here, 1).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }, + // Second xfer results in error on the second message - our error handler will fire. + TransferAsset { + assets: (Here, 8).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }, + ]); + // Weight limit of 70 is needed. + let limit = ::Weigher::weight(&mut message).unwrap(); + assert_eq!(limit, 70); + + let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); + assert_eq!(r, Outcome::Complete(50)); // We don't pay the 20 weight for the error handler. + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 13).into()]); + assert_eq!(asset_list(Here), vec![(Here, 8).into()]); + assert_eq!(sent_xcm(), vec![]); + + let r = XcmExecutor::::execute_xcm(Here, message, limit); + assert_eq!(r, Outcome::Complete(70)); // We pay the full weight here. + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 20).into()]); + assert_eq!(asset_list(Here), vec![(Here, 1).into()]); + assert_eq!(sent_xcm(), vec![]); +} diff --git a/xcm/xcm-builder/src/bridging_tests/local_para_para.rs b/xcm/xcm-builder/src/tests/bridging/local_para_para.rs similarity index 100% rename from xcm/xcm-builder/src/bridging_tests/local_para_para.rs rename to xcm/xcm-builder/src/tests/bridging/local_para_para.rs diff --git a/xcm/xcm-builder/src/bridging_tests/local_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs similarity index 100% rename from xcm/xcm-builder/src/bridging_tests/local_relay_relay.rs rename to xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs diff --git a/xcm/xcm-builder/src/bridging_tests/mod.rs b/xcm/xcm-builder/src/tests/bridging/mod.rs similarity index 98% rename from xcm/xcm-builder/src/bridging_tests/mod.rs rename to xcm/xcm-builder/src/tests/bridging/mod.rs index 6e340ff613d1..9bb5e13196c2 100644 --- a/xcm/xcm-builder/src/bridging_tests/mod.rs +++ b/xcm/xcm-builder/src/tests/bridging/mod.rs @@ -16,10 +16,10 @@ //! Tests specific to the bridging primitives -use crate::{mock::*, universal_exports::*}; +use super::mock::*; +use crate::universal_exports::*; use frame_support::{parameter_types, traits::Get}; use std::{cell::RefCell, marker::PhantomData}; -use xcm::prelude::*; use xcm_executor::{ traits::{export_xcm, validate_export}, XcmExecutor, diff --git a/xcm/xcm-builder/src/bridging_tests/paid_remote_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs similarity index 94% rename from xcm/xcm-builder/src/bridging_tests/paid_remote_relay_relay.rs rename to xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs index cf70b56b4a87..8336e03d1faa 100644 --- a/xcm/xcm-builder/src/bridging_tests/paid_remote_relay_relay.rs +++ b/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs @@ -63,7 +63,7 @@ fn sending_to_bridged_chain_works() { ); // Initialize the local relay so that our parachain has funds to pay for export. - add_asset(to_account(Parachain(100)).unwrap(), (Here, 1000)); + add_asset(Parachain(100), (Here, 1000)); let msg = Xcm(vec![Trap(1)]); assert_eq!(send_xcm::(dest, msg), Ok((Parent, 150).into())); @@ -81,7 +81,7 @@ fn sending_to_bridged_chain_works() { ); // The export cost 50 weight units (and thus 50 units of balance). - assert_eq!(assets(to_account(Parachain(100)).unwrap()), vec![(Here, 850).into()]); + assert_eq!(asset_list(Parachain(100)), vec![(Here, 850).into()]); } /// ```nocompile @@ -104,7 +104,7 @@ fn sending_to_parachain_of_bridged_chain_works() { ); // Initialize the local relay so that our parachain has funds to pay for export. - add_asset(to_account(Parachain(100)).unwrap(), (Here, 1000)); + add_asset(Parachain(100), (Here, 1000)); assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Parent, 150).into())); assert_eq!(TheBridge::service(), 1); @@ -119,5 +119,5 @@ fn sending_to_parachain_of_bridged_chain_works() { assert_eq!(take_received_remote_messages(), expected); // The export cost 50 weight units (and thus 50 units of balance). - assert_eq!(assets(to_account(Parachain(100)).unwrap()), vec![(Here, 850).into()]); + assert_eq!(asset_list(Parachain(100)), vec![(Here, 850).into()]); } diff --git a/xcm/xcm-builder/src/bridging_tests/remote_para_para.rs b/xcm/xcm-builder/src/tests/bridging/remote_para_para.rs similarity index 100% rename from xcm/xcm-builder/src/bridging_tests/remote_para_para.rs rename to xcm/xcm-builder/src/tests/bridging/remote_para_para.rs diff --git a/xcm/xcm-builder/src/bridging_tests/remote_para_para_via_relay.rs b/xcm/xcm-builder/src/tests/bridging/remote_para_para_via_relay.rs similarity index 100% rename from xcm/xcm-builder/src/bridging_tests/remote_para_para_via_relay.rs rename to xcm/xcm-builder/src/tests/bridging/remote_para_para_via_relay.rs diff --git a/xcm/xcm-builder/src/bridging_tests/remote_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/remote_relay_relay.rs similarity index 100% rename from xcm/xcm-builder/src/bridging_tests/remote_relay_relay.rs rename to xcm/xcm-builder/src/tests/bridging/remote_relay_relay.rs diff --git a/xcm/xcm-builder/src/tests/expecting.rs b/xcm/xcm-builder/src/tests/expecting.rs new file mode 100644 index 000000000000..d54eef86c358 --- /dev/null +++ b/xcm/xcm-builder/src/tests/expecting.rs @@ -0,0 +1,157 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn expect_pallet_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 + // and let them know to hand it to account #3. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 41, + }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); +} + +#[test] +fn expect_pallet_should_fail_correctly() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 60, + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 1, + name: b"System".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_system".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 0, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 2, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::PalletNotFound)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 2, + min_crate_minor: 42, + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 0, + min_crate_minor: 42, + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 43, + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); +} diff --git a/xcm/xcm-builder/src/tests/locking.rs b/xcm/xcm-builder/src/tests/locking.rs new file mode 100644 index 000000000000..01cdb80f8ad5 --- /dev/null +++ b/xcm/xcm-builder/src/tests/locking.rs @@ -0,0 +1,235 @@ +// Copyright 2022 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 . + +use super::*; +use LockTraceItem::*; + +#[test] +fn lock_roundtrip_should_work() { + // Account #3 and Parachain #1 can execute for free + AllowUnpaidFrom::set(vec![(3u64,).into(), (Parent, Parachain(1)).into()]); + // Account #3 owns 1000 native parent tokens. + add_asset((3u64,), (Parent, 1000)); + // Sending a message costs 10 parent-tokens. + set_send_price((Parent, 10)); + + // They want to lock 100 of the native parent tokens to be unlocked only by Parachain #1. + let r = XcmExecutor::::execute_xcm( + (3u64,), + Xcm(vec![ + WithdrawAsset((Parent, 100).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: (3u64,).into() }] + .into(), + ), + LockAsset { asset: (Parent, 100).into(), unlocker: (Parent, Parachain(1)).into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(40)); + assert_eq!(asset_list((3u64,)), vec![(Parent, 990).into()]); + + assert_eq!( + sent_xcm(), + vec![( + (Parent, Parachain(1)).into(), + Xcm::<()>(vec![NoteUnlockable { owner: (3u64,).into(), asset: (Parent, 100).into() },]), + )] + ); + assert_eq!( + take_lock_trace(), + vec![Lock { + asset: (Parent, 100).into(), + owner: (3u64,).into(), + unlocker: (Parent, Parachain(1)).into(), + }] + ); + + // Now we'll unlock it. + let r = XcmExecutor::::execute_xcm( + (Parent, Parachain(1)), + Xcm(vec![UnlockAsset { asset: (Parent, 100).into(), target: (3u64,).into() }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); +} + +#[test] +fn auto_fee_paying_should_work() { + // Account #3 and Parachain #1 can execute for free + AllowUnpaidFrom::set(vec![(3u64,).into()]); + // Account #3 owns 1000 native parent tokens. + add_asset((3u64,), (Parent, 1000)); + // Sending a message costs 10 parent-tokens. + set_send_price((Parent, 10)); + + // They want to lock 100 of the native parent tokens to be unlocked only by Parachain #1. + let r = XcmExecutor::::execute_xcm( + (3u64,), + Xcm(vec![ + SetFeesMode { jit_withdraw: true }, + LockAsset { asset: (Parent, 100).into(), unlocker: (Parent, Parachain(1)).into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(20)); + assert_eq!(asset_list((3u64,)), vec![(Parent, 990).into()]); +} + +#[test] +fn lock_should_fail_correctly() { + // Account #3 can execute for free + AllowUnpaidFrom::set(vec![(3u64,).into(), (Parent, Parachain(1)).into()]); + + // #3 wants to lock 100 of the native parent tokens to be unlocked only by parachain ../#1, + // but they don't have any. + let r = XcmExecutor::::execute_xcm( + (3u64,), + Xcm(vec![LockAsset { + asset: (Parent, 100).into(), + unlocker: (Parent, Parachain(1)).into(), + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::LockError)); + assert_eq!(sent_xcm(), vec![]); + assert_eq!(take_lock_trace(), vec![]); + + // Account #3 owns 1000 native parent tokens. + add_asset((3u64,), (Parent, 1000)); + // But we require a price to be paid for the sending + set_send_price((Parent, 10)); + + // #3 wants to lock 100 of the native parent tokens to be unlocked only by parachain ../#1, + // but there's nothing to pay the fees for sending the notification message. + let r = XcmExecutor::::execute_xcm( + (3u64,), + Xcm(vec![LockAsset { + asset: (Parent, 100).into(), + unlocker: (Parent, Parachain(1)).into(), + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NotHoldingFees)); + assert_eq!(sent_xcm(), vec![]); + assert_eq!(take_lock_trace(), vec![]); +} + +#[test] +fn remote_unlock_roundtrip_should_work() { + // Account #3 can execute for free + AllowUnpaidFrom::set(vec![(3u64,).into(), (Parent, Parachain(1)).into()]); + // Account #3 owns 1000 native parent tokens. + add_asset((3u64,), (Parent, 1000)); + // Sending a message costs 10 parent-tokens. + set_send_price((Parent, 10)); + + // We have been told by Parachain #1 that Account #3 has locked funds which we can unlock. + let r = XcmExecutor::::execute_xcm( + (Parent, Parachain(1)), + Xcm(vec![NoteUnlockable { asset: (Parent, 100).into(), owner: (3u64,).into() }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + assert_eq!( + take_lock_trace(), + vec![Note { + asset: (Parent, 100).into(), + owner: (3u64,).into(), + locker: (Parent, Parachain(1)).into(), + }] + ); + + // Let's request those funds be unlocked. + let r = XcmExecutor::::execute_xcm( + (3u64,), + Xcm(vec![ + WithdrawAsset((Parent, 100).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: (3u64,).into() }] + .into(), + ), + RequestUnlock { asset: (Parent, 100).into(), locker: (Parent, Parachain(1)).into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(40)); + assert_eq!(asset_list((3u64,)), vec![(Parent, 990).into()]); + + assert_eq!( + sent_xcm(), + vec![( + (Parent, Parachain(1)).into(), + Xcm::<()>(vec![UnlockAsset { target: (3u64,).into(), asset: (Parent, 100).into() },]), + )] + ); + assert_eq!( + take_lock_trace(), + vec![Reduce { + asset: (Parent, 100).into(), + owner: (3u64,).into(), + locker: (Parent, Parachain(1)).into(), + }] + ); +} + +#[test] +fn remote_unlock_should_fail_correctly() { + // Account #3 can execute for free + AllowUnpaidFrom::set(vec![(3u64,).into(), (Parent, Parachain(1)).into()]); + // But we require a price to be paid for the sending + set_send_price((Parent, 10)); + + // We want to unlock 100 of the native parent tokens which were locked for us on parachain. + // This won't work as we don't have any record of them being locked for us. + // No message will be sent and no lock records changed. + let r = XcmExecutor::::execute_xcm( + (3u64,), + Xcm(vec![RequestUnlock { + asset: (Parent, 100).into(), + locker: (Parent, Parachain(1)).into(), + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::LockError)); + assert_eq!(sent_xcm(), vec![]); + assert_eq!(take_lock_trace(), vec![]); + + // We have been told by Parachain #1 that Account #3 has locked funds which we can unlock. + let r = XcmExecutor::::execute_xcm( + (Parent, Parachain(1)), + Xcm(vec![NoteUnlockable { asset: (Parent, 100).into(), owner: (3u64,).into() }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + let _discard = take_lock_trace(); + + // We want to unlock 100 of the native parent tokens which were locked for us on parachain. + // This won't work now as we don't have the funds to send the onward message. + // No message will be sent and no lock records changed. + let r = XcmExecutor::::execute_xcm( + (3u64,), + Xcm(vec![RequestUnlock { + asset: (Parent, 100).into(), + locker: (Parent, Parachain(1)).into(), + }]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NotHoldingFees)); + + assert_eq!(sent_xcm(), vec![]); + assert_eq!(take_lock_trace(), vec![]); +} diff --git a/xcm/xcm-builder/src/mock.rs b/xcm/xcm-builder/src/tests/mock.rs similarity index 65% rename from xcm/xcm-builder/src/mock.rs rename to xcm/xcm-builder/src/tests/mock.rs index 0d80e7fdbb28..bcaad110dd33 100644 --- a/xcm/xcm-builder/src/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -38,8 +38,8 @@ pub use sp_std::{ pub use xcm::latest::prelude::*; pub use xcm_executor::{ traits::{ - ConvertOrigin, ExportXcm, FeeManager, FeeReason, FilterAssetLocation, OnResponse, - TransactAsset, UniversalLocation, + AssetExchange, AssetLock, ConvertOrigin, Enact, ExportXcm, FeeManager, FeeReason, + FilterAssetLocation, LockError, OnResponse, TransactAsset, UniversalLocation, }, Assets, Config, }; @@ -110,10 +110,14 @@ thread_local! { fn(NetworkId, u32, &InteriorMultiLocation, &Xcm<()>) -> Result, fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result<(), SendError>, )>> = RefCell::new(None); + pub static SEND_PRICE: RefCell = RefCell::new(MultiAssets::new()); } pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm)> { SENT_XCM.with(|q| (*q.borrow()).clone()) } +pub fn set_send_price(p: impl Into) { + SEND_PRICE.with(|l| l.replace(p.into().into())); +} pub fn exported_xcm() -> Vec<(NetworkId, u32, InteriorMultiLocation, opaque::Xcm)> { EXPORTED_XCM.with(|q| (*q.borrow()).clone()) } @@ -135,7 +139,7 @@ impl SendXcm for TestMessageSender { msg: &mut Option>, ) -> SendResult<(MultiLocation, Xcm<()>)> { let pair = (dest.take().unwrap(), msg.take().unwrap()); - Ok((pair, MultiAssets::new())) + Ok((pair, SEND_PRICE.with(|l| l.borrow().clone()))) } fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { SENT_XCM.with(|q| q.borrow_mut().push(pair)); @@ -182,28 +186,29 @@ impl ExportXcm for TestMessageExporter { } thread_local! { - pub static ASSETS: RefCell> = RefCell::new(BTreeMap::new()); + pub static ASSETS: RefCell> = RefCell::new(BTreeMap::new()); +} +pub fn assets(who: impl Into) -> Assets { + ASSETS.with(|a| a.borrow().get(&who.into()).cloned()).unwrap_or_default() } -pub fn assets(who: u64) -> Vec { - ASSETS.with(|a| a.borrow().get(&who).map_or(vec![], |a| a.clone().into())) +pub fn asset_list(who: impl Into) -> Vec { + MultiAssets::from(assets(who)).into_inner() } -pub fn add_asset>(who: u64, what: AssetArg) { - ASSETS.with(|a| a.borrow_mut().entry(who).or_insert(Assets::new()).subsume(what.into())); +pub fn add_asset(who: impl Into, what: impl Into) { + ASSETS.with(|a| a.borrow_mut().entry(who.into()).or_insert(Assets::new()).subsume(what.into())); } pub struct TestAssetTransactor; impl TransactAsset for TestAssetTransactor { fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> Result<(), XcmError> { - let who = to_account(who.clone()).map_err(|_| XcmError::LocationCannotHold)?; - add_asset(who, what.clone()); + add_asset(who.clone(), what.clone()); Ok(()) } fn withdraw_asset(what: &MultiAsset, who: &MultiLocation) -> Result { - let who = to_account(who.clone()).map_err(|_| XcmError::LocationCannotHold)?; ASSETS.with(|a| { a.borrow_mut() - .get_mut(&who) + .get_mut(who) .ok_or(XcmError::NotWithdrawable)? .try_take(what.clone().into()) .map_err(|_| XcmError::NotWithdrawable) @@ -370,14 +375,198 @@ pub type TestBarrier = ( AllowSubscriptionsFrom>, ); +thread_local! { + pub static IS_WAIVED: RefCell> = RefCell::new(vec![]); +} +#[allow(dead_code)] +pub fn set_fee_waiver(waived: Vec) { + IS_WAIVED.with(|l| l.replace(waived)); +} + pub struct TestFeeManager; impl FeeManager for TestFeeManager { - fn is_waived(_: &Option, r: FeeReason) -> bool { - !matches!(r, FeeReason::Export(_)) + fn is_waived(_: Option<&MultiLocation>, r: FeeReason) -> bool { + IS_WAIVED.with(|l| l.borrow().contains(&r)) } fn handle_fee(_: MultiAssets) {} } +#[derive(Clone, Eq, PartialEq, Debug)] +pub enum LockTraceItem { + Lock { unlocker: MultiLocation, asset: MultiAsset, owner: MultiLocation }, + Unlock { unlocker: MultiLocation, asset: MultiAsset, owner: MultiLocation }, + Note { locker: MultiLocation, asset: MultiAsset, owner: MultiLocation }, + Reduce { locker: MultiLocation, asset: MultiAsset, owner: MultiLocation }, +} +thread_local! { + pub static NEXT_INDEX: RefCell = RefCell::new(0); + pub static LOCK_TRACE: RefCell> = RefCell::new(Vec::new()); + pub static ALLOWED_UNLOCKS: RefCell> = RefCell::new(BTreeMap::new()); + pub static ALLOWED_REQUEST_UNLOCKS: RefCell> = RefCell::new(BTreeMap::new()); +} + +pub fn take_lock_trace() -> Vec { + LOCK_TRACE.with(|l| l.replace(Vec::new())) +} +pub fn allow_unlock( + unlocker: impl Into, + asset: impl Into, + owner: impl Into, +) { + ALLOWED_UNLOCKS.with(|l| { + l.borrow_mut() + .entry((owner.into(), unlocker.into())) + .or_default() + .subsume(asset.into()) + }); +} +pub fn disallow_unlock( + unlocker: impl Into, + asset: impl Into, + owner: impl Into, +) { + ALLOWED_UNLOCKS.with(|l| { + l.borrow_mut() + .entry((owner.into(), unlocker.into())) + .or_default() + .saturating_take(asset.into().into()) + }); +} +pub fn unlock_allowed(unlocker: &MultiLocation, asset: &MultiAsset, owner: &MultiLocation) -> bool { + ALLOWED_UNLOCKS.with(|l| { + l.borrow_mut() + .get(&(owner.clone(), unlocker.clone())) + .map_or(false, |x| x.contains_asset(asset)) + }) +} +pub fn allow_request_unlock( + locker: impl Into, + asset: impl Into, + owner: impl Into, +) { + ALLOWED_REQUEST_UNLOCKS.with(|l| { + l.borrow_mut() + .entry((owner.into(), locker.into())) + .or_default() + .subsume(asset.into()) + }); +} +pub fn disallow_request_unlock( + locker: impl Into, + asset: impl Into, + owner: impl Into, +) { + ALLOWED_REQUEST_UNLOCKS.with(|l| { + l.borrow_mut() + .entry((owner.into(), locker.into())) + .or_default() + .saturating_take(asset.into().into()) + }); +} +pub fn request_unlock_allowed( + locker: &MultiLocation, + asset: &MultiAsset, + owner: &MultiLocation, +) -> bool { + ALLOWED_REQUEST_UNLOCKS.with(|l| { + l.borrow_mut() + .get(&(owner.clone(), locker.clone())) + .map_or(false, |x| x.contains_asset(asset)) + }) +} + +pub struct TestTicket(LockTraceItem); +impl Enact for TestTicket { + fn enact(self) -> Result<(), LockError> { + match &self.0 { + LockTraceItem::Lock { unlocker, asset, owner } => + allow_unlock(unlocker.clone(), asset.clone(), owner.clone()), + LockTraceItem::Unlock { unlocker, asset, owner } => + disallow_unlock(unlocker.clone(), asset.clone(), owner.clone()), + LockTraceItem::Reduce { locker, asset, owner } => + disallow_request_unlock(locker.clone(), asset.clone(), owner.clone()), + _ => {}, + } + LOCK_TRACE.with(move |l| l.borrow_mut().push(self.0)); + Ok(()) + } +} + +pub struct TestAssetLock; +impl AssetLock for TestAssetLock { + type LockTicket = TestTicket; + type UnlockTicket = TestTicket; + type ReduceTicket = TestTicket; + + fn prepare_lock( + unlocker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result { + ensure!(assets(owner.clone()).contains_asset(&asset), LockError::AssetNotOwned); + Ok(TestTicket(LockTraceItem::Lock { unlocker, asset, owner })) + } + + fn prepare_unlock( + unlocker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result { + ensure!(unlock_allowed(&unlocker, &asset, &owner), LockError::NotLocked); + Ok(TestTicket(LockTraceItem::Unlock { unlocker, asset, owner })) + } + + fn note_unlockable( + locker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result<(), LockError> { + allow_request_unlock(locker.clone(), asset.clone(), owner.clone()); + let item = LockTraceItem::Note { locker, asset, owner }; + LOCK_TRACE.with(move |l| l.borrow_mut().push(item)); + Ok(()) + } + + fn prepare_reduce_unlockable( + locker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result { + ensure!(request_unlock_allowed(&locker, &asset, &owner), LockError::NotLocked); + Ok(TestTicket(LockTraceItem::Reduce { locker, asset, owner })) + } +} + +thread_local! { + pub static EXCHANGE_ASSETS: RefCell = RefCell::new(Assets::new()); +} +pub fn set_exchange_assets(assets: impl Into) { + EXCHANGE_ASSETS.with(|a| a.replace(assets.into().into())); +} +pub fn exchange_assets() -> MultiAssets { + EXCHANGE_ASSETS.with(|a| a.borrow().clone().into()) +} +pub struct TestAssetExchange; +impl AssetExchange for TestAssetExchange { + fn exchange_asset( + _origin: Option<&MultiLocation>, + give: Assets, + want: &MultiAssets, + maximal: bool, + ) -> Result { + let mut have = EXCHANGE_ASSETS.with(|l| l.borrow().clone()); + ensure!(have.contains_assets(want), give); + let get = if maximal { + std::mem::replace(&mut have, Assets::new()) + } else { + have.saturating_take(want.clone().into()) + }; + have.subsume_assets(give); + EXCHANGE_ASSETS.with(|l| l.replace(have)); + Ok(get) + } +} + pub struct TestConfig; impl Config for TestConfig { type Call = TestCall; @@ -392,6 +581,8 @@ impl Config for TestConfig { type Trader = FixedRateOfFungible; type ResponseHandler = TestResponseHandler; type AssetTrap = TestAssetTrap; + type AssetLocker = TestAssetLock; + type AssetExchanger = TestAssetExchange; type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; type PalletInstancesInfo = TestPalletsInfo; @@ -400,3 +591,7 @@ impl Config for TestConfig { type UniversalAliases = TestUniversalAliases; type MessageExporter = TestMessageExporter; } + +pub fn fungible_multi_asset(location: MultiLocation, amount: u128) -> MultiAsset { + (AssetId::from(location), Fungibility::Fungible(amount)).into() +} diff --git a/xcm/xcm-builder/src/tests/mod.rs b/xcm/xcm-builder/src/tests/mod.rs new file mode 100644 index 000000000000..da17f2d36e83 --- /dev/null +++ b/xcm/xcm-builder/src/tests/mod.rs @@ -0,0 +1,35 @@ +// Copyright 2022 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 . + +use super::{test_utils::*, *}; +use core::convert::TryInto; +use frame_support::{assert_err, traits::ConstU32, weights::constants::WEIGHT_PER_SECOND}; +use xcm_executor::{traits::*, Config, XcmExecutor}; + +mod mock; +use mock::*; + +mod assets; +mod barriers; +mod basic; +mod bridging; +mod expecting; +mod locking; +mod origins; +mod querying; +mod transacting; +mod version_subscriptions; +mod weight; diff --git a/xcm/xcm-builder/src/tests/origins.rs b/xcm/xcm-builder/src/tests/origins.rs new file mode 100644 index 000000000000..5dee287a559b --- /dev/null +++ b/xcm/xcm-builder/src/tests/origins.rs @@ -0,0 +1,76 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn universal_origin_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into(), X1(Parachain(2)).into()]); + clear_universal_aliases(); + // Parachain 1 may represent Kusama to us + add_universal_alias(Parachain(1), Kusama); + // Parachain 2 may represent Polkadot to us + add_universal_alias(Parachain(2), Polkadot); + + let r = XcmExecutor::::execute_xcm( + Parachain(2), + Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(10, XcmError::InvalidLocation)); + + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); + + add_asset((Ancestor(2), GlobalConsensus(Kusama)), (Parent, 100)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]), + 50, + ); + assert_eq!(r, Outcome::Complete(20)); + assert_eq!(asset_list((Ancestor(2), GlobalConsensus(Kusama))), vec![]); +} + +#[test] +fn export_message_should_work() { + // Bridge chain (assumed to be Relay) lets Parachain #1 have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Local parachain #1 issues a transfer asset on Polkadot Relay-chain, transfering 100 Planck to + // Polkadot parachain #2. + let message = + Xcm(vec![TransferAsset { assets: (Here, 100).into(), beneficiary: Parachain(2).into() }]); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![ExportMessage { network: Polkadot, destination: Here, xcm: message.clone() }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + assert_eq!(exported_xcm(), vec![(Polkadot, 403611790, Here, message)]); +} diff --git a/xcm/xcm-builder/src/tests/querying.rs b/xcm/xcm-builder/src/tests/querying.rs new file mode 100644 index 000000000000..1b6e90e230d4 --- /dev/null +++ b/xcm/xcm-builder/src/tests/querying.rs @@ -0,0 +1,120 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn pallet_query_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 + // and let them know to hand it to account #3. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![QueryPallet { + module_name: "Error".into(), + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: 1, + max_weight: 50, + }, + }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + + assert_eq!( + sent_xcm(), + vec![( + Parachain(1).into(), + Xcm::<()>(vec![QueryResponse { + query_id: 1, + max_weight: 50, + response: Response::PalletsInfo(vec![].try_into().unwrap()), + querier: Some(Here.into()), + }]), + )] + ); +} + +#[test] +fn pallet_query_with_results_should_work() { + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 + // and let them know to hand it to account #3. + let r = XcmExecutor::::execute_xcm( + Parachain(1), + Xcm(vec![QueryPallet { + module_name: "pallet_balances".into(), + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: 1, + max_weight: 50, + }, + }]), + 50, + ); + assert_eq!(r, Outcome::Complete(10)); + + assert_eq!( + sent_xcm(), + vec![( + Parachain(1).into(), + Xcm::<()>(vec![QueryResponse { + query_id: 1, + max_weight: 50, + response: Response::PalletsInfo( + vec![PalletInfo::new( + 1, + b"Balances".as_ref().into(), + b"pallet_balances".as_ref().into(), + 1, + 42, + 69, + ) + .unwrap(),] + .try_into() + .unwrap() + ), + querier: Some(Here.into()), + }]), + )] + ); +} + +#[test] +fn prepaid_result_of_query_should_get_free_execution() { + let query_id = 33; + // We put this in manually here, but normally this would be done at the point of crafting the message. + expect_response(query_id, Parent.into()); + + let the_response = Response::Assets((Parent, 100).into()); + let message = Xcm::(vec![QueryResponse { + query_id, + response: the_response.clone(), + max_weight: 10, + querier: Some(Here.into()), + }]); + let weight_limit = 10; + + // First time the response gets through since we're expecting it... + let r = XcmExecutor::::execute_xcm(Parent, message.clone(), weight_limit); + assert_eq!(r, Outcome::Complete(10)); + assert_eq!(response(query_id).unwrap(), the_response); + + // Second time it doesn't, since we're not. + let r = XcmExecutor::::execute_xcm(Parent, message.clone(), weight_limit); + assert_eq!(r, Outcome::Error(XcmError::Barrier)); +} diff --git a/xcm/xcm-builder/src/tests/transacting.rs b/xcm/xcm-builder/src/tests/transacting.rs new file mode 100644 index 000000000000..643a1054d8cb --- /dev/null +++ b/xcm/xcm-builder/src/tests/transacting.rs @@ -0,0 +1,186 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn transacting_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + call: TestCall::Any(50, None).encode().into(), + }]); + let weight_limit = 60; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(60)); +} + +#[test] +fn transacting_should_respect_max_weight_requirement() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 40, + call: TestCall::Any(50, None).encode().into(), + }]); + let weight_limit = 60; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Incomplete(50, XcmError::MaxWeightInvalid)); +} + +#[test] +fn transacting_should_refund_weight() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + call: TestCall::Any(50, Some(30)).encode().into(), + }]); + let weight_limit = 60; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(40)); +} + +#[test] +fn paid_transacting_should_refund_payment_for_unused_weight() { + let one: MultiLocation = AccountIndex64 { index: 1, network: None }.into(); + AllowPaidFrom::set(vec![one.clone()]); + add_asset(AccountIndex64 { index: 1, network: None }, (Parent, 100)); + WeightPrice::set((Parent.into(), 1_000_000_000_000)); + + let origin = one.clone(); + let fees = (Parent, 100).into(); + let message = Xcm::(vec![ + WithdrawAsset((Parent, 100).into()), // enough for 100 units of weight. + BuyExecution { fees, weight_limit: Limited(100) }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + // call estimated at 50 but only takes 10. + call: TestCall::Any(50, Some(10)).encode().into(), + }, + RefundSurplus, + DepositAsset { assets: AllCounted(1).into(), beneficiary: one.clone() }, + ]); + let weight_limit = 100; + let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); + assert_eq!(r, Outcome::Complete(60)); + assert_eq!(asset_list(AccountIndex64 { index: 1, network: None }), vec![(Parent, 40).into()]); +} + +#[test] +fn report_successful_transact_status_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![ + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + call: TestCall::Any(50, None).encode().into(), + }, + ReportTransactStatus(QueryResponseInfo { + destination: Parent.into(), + query_id: 42, + max_weight: 5000, + }), + ]); + let weight_limit = 70; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(70)); + assert_eq!( + sent_xcm(), + vec![( + Parent.into(), + Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Success), + query_id: 42, + max_weight: 5000, + querier: Some(Here.into()), + }]) + )] + ); +} + +#[test] +fn report_failed_transact_status_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![ + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + call: TestCall::OnlyRoot(50, None).encode().into(), + }, + ReportTransactStatus(QueryResponseInfo { + destination: Parent.into(), + query_id: 42, + max_weight: 5000, + }), + ]); + let weight_limit = 70; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(70)); + assert_eq!( + sent_xcm(), + vec![( + Parent.into(), + Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), + query_id: 42, + max_weight: 5000, + querier: Some(Here.into()), + }]) + )] + ); +} + +#[test] +fn clear_transact_status_should_work() { + AllowUnpaidFrom::set(vec![Parent.into()]); + + let message = Xcm::(vec![ + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: 50, + call: TestCall::OnlyRoot(50, None).encode().into(), + }, + ClearTransactStatus, + ReportTransactStatus(QueryResponseInfo { + destination: Parent.into(), + query_id: 42, + max_weight: 5000, + }), + ]); + let weight_limit = 80; + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(80)); + assert_eq!( + sent_xcm(), + vec![( + Parent.into(), + Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Success), + query_id: 42, + max_weight: 5000, + querier: Some(Here.into()), + }]) + )] + ); +} diff --git a/xcm/xcm-builder/src/tests/version_subscriptions.rs b/xcm/xcm-builder/src/tests/version_subscriptions.rs new file mode 100644 index 000000000000..2ecd12a05b4f --- /dev/null +++ b/xcm/xcm-builder/src/tests/version_subscriptions.rs @@ -0,0 +1,129 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn simple_version_subscriptions_should_work() { + AllowSubsFrom::set(vec![Parent.into()]); + + let origin = Parachain(1000); + let message = Xcm::(vec![ + SetAppendix(Xcm(vec![])), + SubscribeVersion { query_id: 42, max_response_weight: 5000 }, + ]); + let weight_limit = 20; + let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); + assert_eq!(r, Outcome::Error(XcmError::Barrier)); + + let origin = Parachain(1000); + let message = + Xcm::(vec![SubscribeVersion { query_id: 42, max_response_weight: 5000 }]); + let weight_limit = 10; + let r = XcmExecutor::::execute_xcm(origin, message.clone(), weight_limit); + assert_eq!(r, Outcome::Error(XcmError::Barrier)); + + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(10)); + + assert_eq!(SubscriptionRequests::get(), vec![(Parent.into(), Some((42, 5000)))]); +} + +#[test] +fn version_subscription_instruction_should_work() { + let origin = Parachain(1000); + let message = Xcm::(vec![ + DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), + SubscribeVersion { query_id: 42, max_response_weight: 5000 }, + ]); + let weight_limit = 20; + let r = XcmExecutor::::execute_xcm_in_credit( + origin.clone(), + message.clone(), + weight_limit, + weight_limit, + ); + assert_eq!(r, Outcome::Incomplete(20, XcmError::BadOrigin)); + + let message = Xcm::(vec![ + SetAppendix(Xcm(vec![])), + SubscribeVersion { query_id: 42, max_response_weight: 5000 }, + ]); + let r = XcmExecutor::::execute_xcm_in_credit( + origin, + message.clone(), + weight_limit, + weight_limit, + ); + assert_eq!(r, Outcome::Complete(20)); + + assert_eq!(SubscriptionRequests::get(), vec![(Parachain(1000).into(), Some((42, 5000)))]); +} + +#[test] +fn simple_version_unsubscriptions_should_work() { + AllowSubsFrom::set(vec![Parent.into()]); + + let origin = Parachain(1000); + let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); + let weight_limit = 20; + let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); + assert_eq!(r, Outcome::Error(XcmError::Barrier)); + + let origin = Parachain(1000); + let message = Xcm::(vec![UnsubscribeVersion]); + let weight_limit = 10; + let r = XcmExecutor::::execute_xcm(origin, message.clone(), weight_limit); + assert_eq!(r, Outcome::Error(XcmError::Barrier)); + + let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + assert_eq!(r, Outcome::Complete(10)); + + assert_eq!(SubscriptionRequests::get(), vec![(Parent.into(), None)]); + assert_eq!(sent_xcm(), vec![]); +} + +#[test] +fn version_unsubscription_instruction_should_work() { + let origin = Parachain(1000); + + // Not allowed to do it when origin has been changed. + let message = Xcm::(vec![ + DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), + UnsubscribeVersion, + ]); + let weight_limit = 20; + let r = XcmExecutor::::execute_xcm_in_credit( + origin.clone(), + message.clone(), + weight_limit, + weight_limit, + ); + assert_eq!(r, Outcome::Incomplete(20, XcmError::BadOrigin)); + + // Fine to do it when origin is untouched. + let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); + let r = XcmExecutor::::execute_xcm_in_credit( + origin, + message.clone(), + weight_limit, + weight_limit, + ); + assert_eq!(r, Outcome::Complete(20)); + + assert_eq!(SubscriptionRequests::get(), vec![(Parachain(1000).into(), None)]); + assert_eq!(sent_xcm(), vec![]); +} diff --git a/xcm/xcm-builder/src/tests/weight.rs b/xcm/xcm-builder/src/tests/weight.rs new file mode 100644 index 000000000000..6c2a5cf112f8 --- /dev/null +++ b/xcm/xcm-builder/src/tests/weight.rs @@ -0,0 +1,139 @@ +// Copyright 2022 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 . + +use super::*; + +#[test] +fn errors_should_return_unused_weight() { + // we'll let them have message execution for free. + AllowUnpaidFrom::set(vec![Here.into()]); + // We own 1000 of our tokens. + add_asset(Here, (Here, 11)); + let mut message = Xcm(vec![ + // First xfer results in an error on the last message only + TransferAsset { + assets: (Here, 1).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }, + // Second xfer results in error third message and after + TransferAsset { + assets: (Here, 2).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }, + // Third xfer results in error second message and after + TransferAsset { + assets: (Here, 4).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }, + ]); + // Weight limit of 70 is needed. + let limit = ::Weigher::weight(&mut message).unwrap(); + assert_eq!(limit, 30); + + let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); + assert_eq!(r, Outcome::Complete(30)); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 7).into()]); + assert_eq!(asset_list(Here), vec![(Here, 4).into()]); + assert_eq!(sent_xcm(), vec![]); + + let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); + assert_eq!(r, Outcome::Incomplete(30, XcmError::NotWithdrawable)); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 10).into()]); + assert_eq!(asset_list(Here), vec![(Here, 1).into()]); + assert_eq!(sent_xcm(), vec![]); + + let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); + assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11).into()]); + assert_eq!(asset_list(Here), vec![]); + assert_eq!(sent_xcm(), vec![]); + + let r = XcmExecutor::::execute_xcm(Here, message, limit); + assert_eq!(r, Outcome::Incomplete(10, XcmError::NotWithdrawable)); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11).into()]); + assert_eq!(asset_list(Here), vec![]); + assert_eq!(sent_xcm(), vec![]); +} + +#[test] +fn weight_bounds_should_respect_instructions_limit() { + MaxInstructions::set(3); + let mut message = Xcm(vec![ClearOrigin; 4]); + // 4 instructions are too many. + assert_eq!(::Weigher::weight(&mut message), Err(())); + + let mut message = + Xcm(vec![SetErrorHandler(Xcm(vec![ClearOrigin])), SetAppendix(Xcm(vec![ClearOrigin]))]); + // 4 instructions are too many, even when hidden within 2. + assert_eq!(::Weigher::weight(&mut message), Err(())); + + let mut message = + Xcm(vec![SetErrorHandler(Xcm(vec![SetErrorHandler(Xcm(vec![SetErrorHandler(Xcm( + vec![ClearOrigin], + ))]))]))]); + // 4 instructions are too many, even when it's just one that's 3 levels deep. + assert_eq!(::Weigher::weight(&mut message), Err(())); + + let mut message = + Xcm(vec![SetErrorHandler(Xcm(vec![SetErrorHandler(Xcm(vec![ClearOrigin]))]))]); + // 3 instructions are OK. + assert_eq!(::Weigher::weight(&mut message), Ok(30)); +} + +#[test] +fn weight_trader_tuple_should_work() { + let para_1: MultiLocation = Parachain(1).into(); + let para_2: MultiLocation = Parachain(2).into(); + + parameter_types! { + pub static HereWeightPrice: (AssetId, u128) = (Here.into(), WEIGHT_PER_SECOND.into()); + pub static Para1WeightPrice: (AssetId, u128) = (Parachain(1).into(), WEIGHT_PER_SECOND.into()); + } + + type Traders = ( + // trader one + FixedRateOfFungible, + // trader two + FixedRateOfFungible, + ); + + let mut traders = Traders::new(); + // trader one buys weight + assert_eq!( + traders.buy_weight(5, fungible_multi_asset(Here.into(), 10).into()), + Ok(fungible_multi_asset(Here.into(), 5).into()), + ); + // trader one refunds + assert_eq!(traders.refund_weight(2), Some(fungible_multi_asset(Here.into(), 2))); + + let mut traders = Traders::new(); + // trader one failed; trader two buys weight + assert_eq!( + traders.buy_weight(5, fungible_multi_asset(para_1.clone(), 10).into()), + Ok(fungible_multi_asset(para_1.clone(), 5).into()), + ); + // trader two refunds + assert_eq!(traders.refund_weight(2), Some(fungible_multi_asset(para_1, 2))); + + let mut traders = Traders::new(); + // all traders fails + assert_err!( + traders.buy_weight(5, fungible_multi_asset(para_2, 10).into()), + XcmError::TooExpensive, + ); + // and no refund + assert_eq!(traders.refund_weight(2), None); +} diff --git a/xcm/xcm-builder/src/weight.rs b/xcm/xcm-builder/src/weight.rs index 755b6acf2844..b19106e1a543 100644 --- a/xcm/xcm-builder/src/weight.rs +++ b/xcm/xcm-builder/src/weight.rs @@ -127,62 +127,6 @@ impl TakeRevenue for () { fn take_revenue(_revenue: MultiAsset) {} } -/// Simple fee calculator that requires payment in a single concrete fungible at a fixed rate. -/// -/// The constant `Get` type parameter should be the concrete fungible ID and the amount of it required for -/// one second of weight. -#[deprecated = "Use `FixedRateOfFungible` instead"] -pub struct FixedRateOfConcreteFungible, R: TakeRevenue>( - Weight, - u128, - PhantomData<(T, R)>, -); -#[allow(deprecated)] -impl, R: TakeRevenue> WeightTrader - for FixedRateOfConcreteFungible -{ - fn new() -> Self { - Self(0, 0, PhantomData) - } - - fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { - log::trace!( - target: "xcm::weight", - "FixedRateOfConcreteFungible::buy_weight weight: {:?}, payment: {:?}", - weight, payment, - ); - let (id, units_per_second) = T::get(); - let amount = units_per_second * (weight as u128) / (WEIGHT_PER_SECOND as u128); - let unused = - payment.checked_sub((id, amount).into()).map_err(|_| XcmError::TooExpensive)?; - self.0 = self.0.saturating_add(weight); - self.1 = self.1.saturating_add(amount); - Ok(unused) - } - - fn refund_weight(&mut self, weight: Weight) -> Option { - log::trace!(target: "xcm::weight", "FixedRateOfConcreteFungible::refund_weight weight: {:?}", weight); - let (id, units_per_second) = T::get(); - let weight = weight.min(self.0); - let amount = units_per_second * (weight as u128) / (WEIGHT_PER_SECOND as u128); - self.0 -= weight; - self.1 = self.1.saturating_sub(amount); - if amount > 0 { - Some((Concrete(id), amount).into()) - } else { - None - } - } -} -#[allow(deprecated)] -impl, R: TakeRevenue> Drop for FixedRateOfConcreteFungible { - fn drop(&mut self) { - if self.1 > 0 { - R::take_revenue((Concrete(T::get().0), self.1).into()); - } - } -} - /// Simple fee calculator that requires payment in a single fungible at a fixed rate. /// /// The constant `Get` type parameter should be the fungible ID and the amount of it required for diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index b749f070a147..bc56e7dad0d3 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -180,6 +180,8 @@ impl xcm_executor::Config for XcmConfig { type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; @@ -207,6 +209,11 @@ impl pallet_xcm::Config for Runtime { type Origin = Origin; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type TrustedLockers = (); + type SovereignAccountOf = (); + type Currency = Balances; + type CurrencyMatcher = IsConcrete; + type MaxLockers = frame_support::traits::ConstU32<8>; } impl origin::Config for Runtime {} diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index 7b5d6f4a5855..ac8b41233bf4 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -60,7 +60,7 @@ impl From> for Assets { impl From for Assets { fn from(assets: MultiAssets) -> Assets { - assets.drain().into() + assets.into_inner().into() } } @@ -245,6 +245,30 @@ impl Assets { .collect(); } + /// Returns `true` if `asset` is contained within `self`. + pub fn contains_asset(&self, asset: &MultiAsset) -> bool { + match asset { + MultiAsset { fun: Fungible(ref amount), ref id } => + self.fungible.get(id).map_or(false, |a| a >= amount), + MultiAsset { fun: NonFungible(ref instance), ref id } => + self.non_fungible.contains(&(id.clone(), instance.clone())), + } + } + + /// Returns `true` if all `assets` are contained within `self`. + pub fn contains_assets(&self, assets: &MultiAssets) -> bool { + assets.inner().iter().all(|a| self.contains_asset(a)) + } + + /// Returns `true` if all `assets` are contained within `self`. + pub fn contains(&self, assets: &Assets) -> bool { + assets + .fungible + .iter() + .all(|(k, v)| self.fungible.get(k).map_or(false, |a| a >= v)) && + self.non_fungible.is_superset(&assets.non_fungible) + } + /// Returns an error unless all `assets` are contained in `self`. In the case of an error, the first asset in /// `assets` which is not wholly in `self` is returned. pub fn ensure_contains(&self, assets: &MultiAssets) -> Result<(), TakeError> { @@ -331,7 +355,7 @@ impl Assets { if !saturate { self.ensure_contains(&assets)?; } - for asset in assets.drain().into_iter() { + for asset in assets.into_inner().into_iter() { match asset { MultiAsset { fun: Fungible(amount), id } => { let (remove, amount) = match self.fungible.get_mut(&id) { @@ -417,12 +441,12 @@ impl Assets { /// ``` /// use xcm_executor::Assets; /// use xcm::latest::prelude::*; - /// let assets_i_have: Assets = vec![ (Here, 100).into(), (vec![0], 100).into() ].into(); - /// let assets_they_want: MultiAssetFilter = vec![ (Here, 200).into(), (vec![0], 50).into() ].into(); + /// let assets_i_have: Assets = vec![ (Here, 100).into(), ([0; 32], 100).into() ].into(); + /// let assets_they_want: MultiAssetFilter = vec![ (Here, 200).into(), ([0; 32], 50).into() ].into(); /// /// let assets_we_can_trade: Assets = assets_i_have.min(&assets_they_want); /// assert_eq!(assets_we_can_trade.into_assets_iter().collect::>(), vec![ - /// (Here, 100).into(), (vec![0], 50).into(), + /// (Here, 100).into(), ([0; 32], 50).into(), /// ]); /// ``` pub fn min(&self, mask: &MultiAssetFilter) -> Assets { @@ -493,12 +517,12 @@ mod tests { #[allow(non_snake_case)] /// Abstract fungible constructor fn AF(id: u8, amount: u128) -> MultiAsset { - (vec![id], amount).into() + ([id; 32], amount).into() } #[allow(non_snake_case)] /// Abstract non-fungible constructor fn ANF(class: u8, instance_id: u8) -> MultiAsset { - (vec![class], vec![instance_id]).into() + ([class; 32], [instance_id; 4]).into() } #[allow(non_snake_case)] /// Concrete fungible constructor @@ -617,8 +641,8 @@ mod tests { assets.subsume(CF(3000)); assets.subsume(CNF(80)); assets.subsume(ANF(3, 10)); - let fungible = WildMultiAsset::from((vec![1], WildFungible)).counted(2).into(); - let non_fungible = WildMultiAsset::from((vec![2], WildNonFungible)).counted(2).into(); + let fungible = WildMultiAsset::from(([1u8; 32], WildFungible)).counted(2).into(); + let non_fungible = WildMultiAsset::from(([2u8; 32], WildNonFungible)).counted(2).into(); let all = WildMultiAsset::AllCounted(6).into(); let fungible = assets.min(&fungible); @@ -635,8 +659,8 @@ mod tests { #[test] fn min_all_abstract_works() { let assets = test_assets(); - let fungible = Wild((vec![1], WildFungible).into()); - let non_fungible = Wild((vec![2], WildNonFungible).into()); + let fungible = Wild(([1u8; 32], WildFungible).into()); + let non_fungible = Wild(([2u8; 32], WildNonFungible).into()); let fungible = assets.min(&fungible); let fungible = fungible.assets_iter().collect::>(); @@ -696,8 +720,8 @@ mod tests { #[test] fn saturating_take_all_abstract_works() { let mut assets = test_assets(); - let fungible = Wild((vec![1], WildFungible).into()); - let non_fungible = Wild((vec![2], WildNonFungible).into()); + let fungible = Wild(([1u8; 32], WildFungible).into()); + let non_fungible = Wild(([2u8; 32], WildNonFungible).into()); let fungible = assets.saturating_take(fungible); let fungible = fungible.assets_iter().collect::>(); @@ -782,7 +806,7 @@ mod tests { assets.subsume(CF(3000)); assets.subsume(CNF(80)); assets.subsume(ANF(3, 10)); - let mask = WildMultiAsset::from((vec![1], WildFungible)).counted(2).into(); + let mask = WildMultiAsset::from(([1u8; 32], WildFungible)).counted(2).into(); let taken = assets.try_take(mask).unwrap(); assert_eq!(MultiAssets::from(taken).inner(), &vec![AF(1, 100)]); assert_eq!( @@ -812,7 +836,7 @@ mod tests { assets.subsume(CF(3000)); assets.subsume(CNF(80)); assets.subsume(ANF(3, 10)); - let mask = WildMultiAsset::from((vec![2], WildNonFungible)).counted(2).into(); + let mask = WildMultiAsset::from(([2u8; 32], WildNonFungible)).counted(2).into(); let taken = assets.try_take(mask).unwrap(); assert_eq!(MultiAssets::from(taken).inner(), &vec![ANF(2, 20), ANF(2, 30),]); assert_eq!( diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 83f7bbb49312..67b8ca3d72ab 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -15,9 +15,9 @@ // along with Polkadot. If not, see . use crate::traits::{ - ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, FilterAssetLocation, OnResponse, - ShouldExecute, TransactAsset, UniversalLocation, VersionChangeNotifier, WeightBounds, - WeightTrader, + AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, + FilterAssetLocation, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, + VersionChangeNotifier, WeightBounds, WeightTrader, }; use frame_support::{ dispatch::{Dispatchable, Parameter}, @@ -65,6 +65,12 @@ pub trait Config { /// end of execution. type AssetTrap: DropAssets; + /// Handler for asset locking. + type AssetLocker: AssetLock; + + /// Handler for exchanging assets. + type AssetExchanger: AssetExchange; + /// The handler for when there is an instruction to claim assets. type AssetClaims: ClaimAssets; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 3276fdb1e841..fcd7f85b18ea 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -30,9 +30,9 @@ use xcm::latest::prelude::*; pub mod traits; use traits::{ - validate_export, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, FeeReason, - FilterAssetLocation, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, - VersionChangeNotifier, WeightBounds, WeightTrader, + validate_export, AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, Enact, + ExportXcm, FeeManager, FeeReason, FilterAssetLocation, OnResponse, ShouldExecute, + TransactAsset, UniversalLocation, VersionChangeNotifier, WeightBounds, WeightTrader, }; mod assets; @@ -40,30 +40,124 @@ pub use assets::Assets; mod config; pub use config::Config; +#[derive(Copy, Clone)] +pub struct FeesMode { + pub jit_withdraw: bool, +} + /// The XCM executor. pub struct XcmExecutor { - pub holding: Assets, - pub holding_limit: usize, - pub origin: Option, - pub original_origin: MultiLocation, - pub trader: Config::Trader, + holding: Assets, + holding_limit: usize, + origin: Option, + original_origin: MultiLocation, + trader: Config::Trader, /// The most recent error result and instruction index into the fragment in which it occurred, /// if any. - pub error: Option<(u32, XcmError)>, + error: Option<(u32, XcmError)>, /// The surplus weight, defined as the amount by which `max_weight` is /// an over-estimate of the actual weight consumed. We do it this way to avoid needing the /// execution engine to keep track of all instructions' weights (it only needs to care about /// the weight of dynamically determined instructions such as `Transact`). - pub total_surplus: u64, - pub total_refunded: u64, - pub error_handler: Xcm, - pub error_handler_weight: u64, - pub appendix: Xcm, - pub appendix_weight: u64, - pub transact_status: MaybeErrorCode, + total_surplus: u64, + total_refunded: u64, + error_handler: Xcm, + error_handler_weight: u64, + appendix: Xcm, + appendix_weight: u64, + transact_status: MaybeErrorCode, + fees_mode: FeesMode, _config: PhantomData, } +#[cfg(feature = "runtime-benchmarks")] +impl XcmExecutor { + pub fn holding(&self) -> &Assets { + &self.holding + } + pub fn set_holding(&mut self, v: Assets) { + self.holding = v + } + pub fn holding_limit(&self) -> &usize { + &self.holding_limit + } + pub fn set_holding_limit(&mut self, v: usize) { + self.holding_limit = v + } + pub fn origin(&self) -> &Option { + &self.origin + } + pub fn set_origin(&mut self, v: Option) { + self.origin = v + } + pub fn original_origin(&self) -> &MultiLocation { + &self.original_origin + } + pub fn set_original_origin(&mut self, v: MultiLocation) { + self.original_origin = v + } + pub fn trader(&self) -> &Config::Trader { + &self.trader + } + pub fn set_trader(&mut self, v: Config::Trader) { + self.trader = v + } + pub fn error(&self) -> &Option<(u32, XcmError)> { + &self.error + } + pub fn set_error(&mut self, v: Option<(u32, XcmError)>) { + self.error = v + } + pub fn total_surplus(&self) -> &u64 { + &self.total_surplus + } + pub fn set_total_surplus(&mut self, v: u64) { + self.total_surplus = v + } + pub fn total_refunded(&self) -> &u64 { + &self.total_refunded + } + pub fn set_total_refunded(&mut self, v: u64) { + self.total_refunded = v + } + pub fn error_handler(&self) -> &Xcm { + &self.error_handler + } + pub fn set_error_handler(&mut self, v: Xcm) { + self.error_handler = v + } + pub fn error_handler_weight(&self) -> &u64 { + &self.error_handler_weight + } + pub fn set_error_handler_weight(&mut self, v: u64) { + self.error_handler_weight = v + } + pub fn appendix(&self) -> &Xcm { + &self.appendix + } + pub fn set_appendix(&mut self, v: Xcm) { + self.appendix = v + } + pub fn appendix_weight(&self) -> &u64 { + &self.appendix_weight + } + pub fn set_appendix_weight(&mut self, v: u64) { + self.appendix_weight = v + } + pub fn transact_status(&self) -> &MaybeErrorCode { + &self.transact_status + } + pub fn set_transact_status(&mut self, v: MaybeErrorCode) { + self.transact_status = v + } + pub fn fees_mode(&self) -> &FeesMode { + &self.fees_mode + } + pub fn set_fees_mode(&mut self, v: FeesMode) { + self.fees_mode = v + } +} + pub struct WeighedMessage(Weight, Xcm); impl PreparedMessage for WeighedMessage { fn weight_of(&self) -> Weight { @@ -126,6 +220,17 @@ impl ExecuteXcm for XcmExecutor { vm.post_execute(xcm_weight) } + + fn charge_fees(origin: impl Into, fees: MultiAssets) -> XcmResult { + let origin = origin.into(); + if !Config::FeeManager::is_waived(Some(&origin), FeeReason::ChargeFees) { + for asset in fees.inner() { + Config::AssetTransactor::withdraw_asset(&asset, &origin)?; + } + Config::FeeManager::handle_fee(fees); + } + Ok(()) + } } #[derive(Debug)] @@ -165,6 +270,7 @@ impl XcmExecutor { appendix: Xcm(vec![]), appendix_weight: 0, transact_status: Default::default(), + fees_mode: FeesMode { jit_withdraw: false }, _config: PhantomData, } } @@ -231,7 +337,7 @@ impl XcmExecutor { reason: FeeReason, ) -> Result<(), XcmError> { let (ticket, fee) = validate_send::(dest, msg)?; - if !Config::FeeManager::is_waived(&self.origin, reason) { + if !Config::FeeManager::is_waived(self.origin.as_ref(), reason) { let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; Config::FeeManager::handle_fee(paid.into()); } @@ -298,7 +404,7 @@ impl XcmExecutor { WithdrawAsset(assets) => { // Take `assets` from the origin account (on-chain) and place in holding. let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); - for asset in assets.drain().into_iter() { + for asset in assets.into_inner().into_iter() { Config::AssetTransactor::withdraw_asset(&asset, &origin)?; self.subsume_asset(asset)?; } @@ -307,7 +413,7 @@ impl XcmExecutor { ReserveAssetDeposited(assets) => { // check whether we trust origin to be our reserve location for this asset. let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); - for asset in assets.drain().into_iter() { + for asset in assets.into_inner().into_iter() { // Must ensure that we recognise the asset as being managed by the origin. ensure!( Config::IsReserve::filter_asset_location(&asset, &origin), @@ -353,7 +459,7 @@ impl XcmExecutor { // don't want to punish a possibly innocent chain/user). Config::AssetTransactor::can_check_in(&origin, asset)?; } - for asset in assets.drain().into_iter() { + for asset in assets.into_inner().into_iter() { Config::AssetTransactor::check_in(&origin, &asset); self.subsume_asset(asset)?; } @@ -375,7 +481,7 @@ impl XcmExecutor { post_info.actual_weight }, Err(error_and_info) => { - self.transact_status = MaybeErrorCode::Error(error_and_info.error.encode()); + self.transact_status = error_and_info.error.encode().into(); error_and_info.post_info.actual_weight }, }; @@ -521,7 +627,7 @@ impl XcmExecutor { let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; let ok = Config::AssetClaims::claim_assets(origin, &ticket, &assets); ensure!(ok, XcmError::UnknownClaim); - for asset in assets.drain().into_iter() { + for asset in assets.into_inner().into_iter() { self.subsume_asset(asset)?; } Ok(()) @@ -557,17 +663,19 @@ impl XcmExecutor { let pallets = Config::PalletInstancesInfo::infos() .into_iter() .filter(|x| x.module_name.as_bytes() == &module_name[..]) - .map(|x| PalletInfo { - index: x.index as u32, - name: x.name.as_bytes().into(), - module_name: x.module_name.as_bytes().into(), - major: x.crate_version.major as u32, - minor: x.crate_version.minor as u32, - patch: x.crate_version.patch as u32, + .map(|x| { + PalletInfo::new( + x.index as u32, + x.name.as_bytes().into(), + x.module_name.as_bytes().into(), + x.crate_version.major as u32, + x.crate_version.minor as u32, + x.crate_version.patch as u32, + ) }) - .collect::>(); + .collect::, XcmError>>()?; let QueryResponseInfo { destination, query_id, max_weight } = response_info; - let response = Response::PalletsInfo(pallets); + let response = Response::PalletsInfo(pallets.try_into()?); let querier = Self::to_querier(self.origin.clone(), &destination)?; let instruction = QueryResponse { query_id, response, max_weight, querier }; let message = Xcm(vec![instruction]); @@ -617,21 +725,91 @@ impl XcmExecutor { // generally have their own lanes. let (ticket, fee) = validate_export::(network, channel, destination, xcm)?; - if !Config::FeeManager::is_waived(&self.origin, FeeReason::Export(network)) { - let paid = - self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; - Config::FeeManager::handle_fee(paid.into()); - } + self.take_fee(fee, FeeReason::Export(network))?; Config::MessageExporter::deliver(ticket)?; Ok(()) }, - ExchangeAsset { .. } => Err(XcmError::Unimplemented), + LockAsset { asset, unlocker } => { + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let remote_asset = Self::try_reanchor(asset.clone(), &unlocker)?; + let lock_ticket = + Config::AssetLocker::prepare_lock(unlocker.clone(), asset, origin.clone())?; + let msg = + Xcm::<()>(vec![NoteUnlockable { asset: remote_asset, owner: origin.clone() }]); + let (ticket, price) = validate_send::(unlocker, msg)?; + self.take_fee(price, FeeReason::LockAsset)?; + lock_ticket.enact()?; + Config::XcmSender::deliver(ticket)?; + Ok(()) + }, + UnlockAsset { asset, target } => { + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + Config::AssetLocker::prepare_unlock(origin.clone(), asset, target)?.enact()?; + Ok(()) + }, + NoteUnlockable { asset, owner } => { + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + Config::AssetLocker::note_unlockable(origin, asset, owner)?; + Ok(()) + }, + RequestUnlock { asset, locker } => { + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let remote_asset = Self::try_reanchor(asset.clone(), &locker)?; + let reduce_ticket = Config::AssetLocker::prepare_reduce_unlockable( + locker.clone(), + asset, + origin.clone(), + )?; + let msg = + Xcm::<()>(vec![UnlockAsset { asset: remote_asset, target: origin.clone() }]); + let (ticket, price) = validate_send::(locker, msg)?; + self.take_fee(price, FeeReason::RequestUnlock)?; + reduce_ticket.enact()?; + Config::XcmSender::deliver(ticket)?; + Ok(()) + }, + ExchangeAsset { give, want, maximal } => { + let origin = self.origin.as_ref(); + let give = self.holding.saturating_take(give); + let r = Config::AssetExchanger::exchange_asset(origin, give, &want, maximal); + let completed = r.is_ok(); + let received = r.unwrap_or_else(|a| a); + for asset in received.into_assets_iter() { + self.holding.subsume(asset); + } + if completed { + Ok(()) + } else { + Err(XcmError::NoDeal) + } + }, + SetFeesMode { jit_withdraw } => { + self.fees_mode = FeesMode { jit_withdraw }; + Ok(()) + }, HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), HrmpChannelClosing { .. } => Err(XcmError::Unimplemented), } } + fn take_fee(&mut self, fee: MultiAssets, reason: FeeReason) -> XcmResult { + if Config::FeeManager::is_waived(self.origin.as_ref(), reason) { + return Ok(()) + } + let paid = if self.fees_mode.jit_withdraw { + let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + for asset in fee.inner() { + Config::AssetTransactor::withdraw_asset(&asset, origin)?; + } + fee + } else { + self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?.into() + }; + Config::FeeManager::handle_fee(paid); + Ok(()) + } + /// Calculates what `local_querier` would be from the perspective of `destination`. fn to_querier( local_querier: Option, @@ -661,7 +839,7 @@ impl XcmExecutor { let instruction = QueryResponse { query_id, response, max_weight, querier }; let message = Xcm(vec![instruction]); let (ticket, fee) = validate_send::(destination, message)?; - if !Config::FeeManager::is_waived(&self.origin, fee_reason) { + if !Config::FeeManager::is_waived(self.origin.as_ref(), fee_reason) { let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; Config::FeeManager::handle_fee(paid.into()); } @@ -669,6 +847,14 @@ impl XcmExecutor { Ok(()) } + fn try_reanchor( + asset: MultiAsset, + destination: &MultiLocation, + ) -> Result { + let context = Config::LocationInverter::universal_location().into(); + asset.reanchored(&destination, &context).map_err(|()| XcmError::ReanchorFailed) + } + /// NOTE: Any assets which were unable to be reanchored are introduced into `failed_bin`. fn reanchored( mut assets: Assets, diff --git a/xcm/xcm-executor/src/traits/asset_exchange.rs b/xcm/xcm-executor/src/traits/asset_exchange.rs new file mode 100644 index 000000000000..2d12606777c4 --- /dev/null +++ b/xcm/xcm-executor/src/traits/asset_exchange.rs @@ -0,0 +1,58 @@ +// Copyright 2020 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 . + +use crate::Assets; +use xcm::prelude::*; + +/// A service for exchanging assets. +pub trait AssetExchange { + /// Handler for exchanging an asset. + /// + /// - `origin`: The location attempting the exchange; this should generally not matter. + /// - `give`: The assets which have been removed from the caller. + /// - `want`: The minimum amount of assets which should be given to the caller in case any + /// exchange happens. If more assets are provided, then they should generally be of the + /// same asset class if at all possible. + /// - `maximal`: If `true`, then as much as possible should be exchanged. + /// + /// `Ok` is returned along with the new set of assets which have been exchanged for `give`. At + /// least want must be in the set. Some assets originally in `give` may also be in this set. In + /// the case of returning an `Err`, then `give` is returned. + fn exchange_asset( + origin: Option<&MultiLocation>, + give: Assets, + want: &MultiAssets, + maximal: bool, + ) -> Result; +} + +#[impl_trait_for_tuples::impl_for_tuples(30)] +impl AssetExchange for Tuple { + fn exchange_asset( + origin: Option<&MultiLocation>, + give: Assets, + want: &MultiAssets, + maximal: bool, + ) -> Result { + for_tuples!( #( + let give = match Tuple::exchange_asset(origin.clone(), give, want, maximal) { + Ok(r) => return Ok(r), + Err(a) => a, + }; + )* ); + Err(give) + } +} diff --git a/xcm/xcm-executor/src/traits/asset_lock.rs b/xcm/xcm-executor/src/traits/asset_lock.rs new file mode 100644 index 000000000000..315ba25cd614 --- /dev/null +++ b/xcm/xcm-executor/src/traits/asset_lock.rs @@ -0,0 +1,151 @@ +// Copyright 2020 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 . + +use sp_std::convert::Infallible; +use xcm::prelude::*; + +pub enum LockError { + NotApplicable, + WouldClobber, + BadOrigin, + NotLocked, + NotEnoughLocked, + Unimplemented, + NotTrusted, + BadOwner, + UnknownAsset, + AssetNotOwned, + NoResources, + UnexpectedState, + InUse, +} + +impl From for XcmError { + fn from(e: LockError) -> XcmError { + use LockError::*; + match e { + NotApplicable => XcmError::AssetNotFound, + BadOrigin => XcmError::BadOrigin, + WouldClobber | NotLocked | NotEnoughLocked | Unimplemented | NotTrusted | + BadOwner | UnknownAsset | AssetNotOwned | NoResources | UnexpectedState | InUse => + XcmError::LockError, + } + } +} + +pub trait Enact { + /// Enact a lock. This should generally be infallible if called immediately after being + /// received. + fn enact(self) -> Result<(), LockError>; +} + +impl Enact for Infallible { + fn enact(self) -> Result<(), LockError> { + unreachable!() + } +} + +/// Define a handler for notification of an asset being locked and for the unlock instruction. +pub trait AssetLock { + /// `Enact` implementer for `prepare_lock`. This type may be dropped safely to avoid doing the + /// lock. + type LockTicket: Enact; + + /// `Enact` implementer for `prepare_unlock`. This type may be dropped safely to avoid doing the + /// unlock. + type UnlockTicket: Enact; + + /// `Enact` implementer for `prepare_reduce_unlockable`. This type may be dropped safely to avoid doing the + /// unlock. + type ReduceTicket: Enact; + + /// Prepare to lock an asset. On success, a `Self::LockTicket` it returned, which can be used + /// to actually enact the lock. + /// + /// WARNING: Don't call this with an undropped instance of `Self::LockTicket` or + /// `Self::UnlockTicket`. + fn prepare_lock( + unlocker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result; + + /// Prepare to unlock an asset. On success, a `Self::UnlockTicket` it returned, which can be + /// used to actually enact the lock. + /// + /// WARNING: Don't call this with an undropped instance of `Self::LockTicket` or + /// `Self::UnlockTicket`. + fn prepare_unlock( + locker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result; + + /// Handler for when a location reports to us that an asset has been locked for us to unlock + /// at a later stage. + /// + /// If there is no way to handle the lock report, then this should return an error so that the + /// sending chain can ensure the lock does not remain. + /// + /// We should only act upon this message if we believe that the `origin` is honest. + fn note_unlockable( + locker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result<(), LockError>; + + /// Handler for when an owner wishes to unlock an asset on a remote chain. + /// + /// Returns a ticket which can be used to actually note the reduction in unlockable assets that + /// `owner` commands on `locker`. + /// + /// WARNING: Don't call this with an undropped instance of `Self::ReduceTicket`. + fn prepare_reduce_unlockable( + locker: MultiLocation, + asset: MultiAsset, + owner: MultiLocation, + ) -> Result; +} + +impl AssetLock for () { + type LockTicket = Infallible; + type UnlockTicket = Infallible; + type ReduceTicket = Infallible; + fn prepare_lock( + _: MultiLocation, + _: MultiAsset, + _: MultiLocation, + ) -> Result { + Err(LockError::NotApplicable) + } + fn prepare_unlock( + _: MultiLocation, + _: MultiAsset, + _: MultiLocation, + ) -> Result { + Err(LockError::NotApplicable) + } + fn note_unlockable(_: MultiLocation, _: MultiAsset, _: MultiLocation) -> Result<(), LockError> { + Err(LockError::NotApplicable) + } + fn prepare_reduce_unlockable( + _: MultiLocation, + _: MultiAsset, + _: MultiLocation, + ) -> Result { + Err(LockError::NotApplicable) + } +} diff --git a/xcm/xcm-executor/src/traits/fee_manager.rs b/xcm/xcm-executor/src/traits/fee_manager.rs index 583f2242188b..b883a6d573c8 100644 --- a/xcm/xcm-executor/src/traits/fee_manager.rs +++ b/xcm/xcm-executor/src/traits/fee_manager.rs @@ -19,7 +19,7 @@ use xcm::prelude::*; /// Handle stuff to do with taking fees in certain XCM instructions. pub trait FeeManager { /// Determine if a fee which would normally payable should be waived. - fn is_waived(origin: &Option, r: FeeReason) -> bool; + fn is_waived(origin: Option<&MultiLocation>, r: FeeReason) -> bool; /// Do something with the fee which has been paid. Doing nothing here silently burns the /// fees. @@ -27,6 +27,7 @@ pub trait FeeManager { } /// Context under which a fee is paid. +#[derive(Copy, Clone, Eq, PartialEq)] pub enum FeeReason { /// When a reporting instruction is called. Report, @@ -42,10 +43,16 @@ pub enum FeeReason { QueryPallet, /// When the `ExportMessage` instruction is called (and includes the network ID). Export(NetworkId), + /// The `charge_fees` API. + ChargeFees, + /// When the `LockAsset` instruction is called. + LockAsset, + /// When the `RequestUnlock` instruction is called. + RequestUnlock, } impl FeeManager for () { - fn is_waived(_: &Option, _: FeeReason) -> bool { + fn is_waived(_: Option<&MultiLocation>, _: FeeReason) -> bool { true } fn handle_fee(_: MultiAssets) {} diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index a08dc9b9a3f0..293077d52201 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -22,6 +22,10 @@ pub use conversion::{ }; mod drop_assets; pub use drop_assets::{ClaimAssets, DropAssets}; +mod asset_lock; +pub use asset_lock::{AssetLock, Enact, LockError}; +mod asset_exchange; +pub use asset_exchange::AssetExchange; mod export; pub use export::{export_xcm, validate_export, ExportXcm}; mod fee_manager; diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index da94f067fa70..f7f8588fe382 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -146,6 +146,8 @@ impl Config for XcmConfig { type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); @@ -316,6 +318,11 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = LocationToAccountId; + type MaxLockers = frame_support::traits::ConstU32<8>; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 57980c8fb840..455d588bbb7d 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -138,6 +138,8 @@ impl Config for XcmConfig { type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); @@ -165,6 +167,11 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = SovereignAccountOf; + type MaxLockers = frame_support::traits::ConstU32<8>; } parameter_types! { diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index e3ae354daf30..ef9958ecd522 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -146,6 +146,8 @@ impl Config for XcmConfig { type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); @@ -316,6 +318,11 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = LocationToAccountId; + type MaxLockers = frame_support::traits::ConstU32<8>; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 25fd22955341..93dcfd567265 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -138,6 +138,8 @@ impl Config for XcmConfig { type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = (); type SubscriptionService = (); type PalletInstancesInfo = (); @@ -165,6 +167,11 @@ impl pallet_xcm::Config for Runtime { type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = SovereignAccountOf; + type MaxLockers = frame_support::traits::ConstU32<8>; } parameter_types! { From 42b12dbfcf2a3a07039d63bd26168f18e5cd91b5 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 3 Mar 2022 04:06:04 -0800 Subject: [PATCH 063/231] Add simulator test for remote locking --- xcm/xcm-executor/src/traits/asset_lock.rs | 1 + xcm/xcm-simulator/example/src/lib.rs | 44 +++++++++++++++++++- xcm/xcm-simulator/example/src/relay_chain.rs | 4 +- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/xcm/xcm-executor/src/traits/asset_lock.rs b/xcm/xcm-executor/src/traits/asset_lock.rs index 315ba25cd614..8d030ed1d5c1 100644 --- a/xcm/xcm-executor/src/traits/asset_lock.rs +++ b/xcm/xcm-executor/src/traits/asset_lock.rs @@ -17,6 +17,7 @@ use sp_std::convert::Infallible; use xcm::prelude::*; +#[derive(Debug)] pub enum LockError { NotApplicable, WouldClobber, diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index da359f7c7958..85319f77cbc5 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -87,7 +87,11 @@ pub fn relay_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); pallet_balances::GenesisConfig:: { - balances: vec![(ALICE, INITIAL_BALANCE), (para_account_id(1), INITIAL_BALANCE)], + balances: vec![ + (ALICE, INITIAL_BALANCE), + (para_account_id(1), INITIAL_BALANCE), + (para_account_id(2), INITIAL_BALANCE), + ], } .assimilate_storage(&mut t) .unwrap(); @@ -226,6 +230,44 @@ mod tests { }); } + #[test] + fn remote_locking() { + MockNet::reset(); + + let locked_amount = 100; + + ParaB::execute_with(|| { + let message = Xcm(vec![ + WithdrawAsset((Here, locked_amount).into()), + buy_execution((Here, locked_amount)), + LockAsset { asset: (Here, locked_amount).into(), unlocker: Parachain(1).into() }, + ]); + assert_ok!(ParachainPalletXcm::send_xcm(Here, Parent, message.clone())); + }); + + Relay::execute_with(|| { + use pallet_balances::{BalanceLock, Reasons}; + assert_eq!( + relay_chain::Balances::locks(¶_account_id(2)), + vec![BalanceLock { + id: *b"py/xcmlk", + amount: locked_amount, + reasons: Reasons::All + }] + ); + }); + + ParaA::execute_with(|| { + assert_eq!( + parachain::MsgQueue::received_dmp(), + vec![Xcm(vec![NoteUnlockable { + owner: (Parent, Parachain(2)).into(), + asset: (Parent, locked_amount).into() + },])] + ); + }); + } + /// Scenario: /// A parachain transfers funds on the relay chain to another parachain account. /// diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 455d588bbb7d..407e43ee0f0b 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -138,7 +138,7 @@ impl Config for XcmConfig { type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); - type AssetLocker = (); + type AssetLocker = XcmPallet; type AssetExchanger = (); type AssetClaims = (); type SubscriptionService = (); @@ -168,7 +168,7 @@ impl pallet_xcm::Config for Runtime { const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; - type CurrencyMatcher = (); + type CurrencyMatcher = IsConcrete; type TrustedLockers = (); type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; From 0fbf0c70bf2c7bc369171673f96a338d537601d4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 3 Mar 2022 22:56:13 -0800 Subject: [PATCH 064/231] Fix tests --- xcm/xcm-simulator/example/src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index 85319f77cbc5..9e705145dd17 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -263,7 +263,7 @@ mod tests { vec![Xcm(vec![NoteUnlockable { owner: (Parent, Parachain(2)).into(), asset: (Parent, locked_amount).into() - },])] + }])] ); }); } @@ -293,7 +293,10 @@ mod tests { relay_chain::Balances::free_balance(para_account_id(1)), INITIAL_BALANCE - send_amount ); - assert_eq!(relay_chain::Balances::free_balance(para_account_id(2)), send_amount); + assert_eq!( + relay_chain::Balances::free_balance(para_account_id(2)), + INITIAL_BALANCE + send_amount + ); }); } @@ -336,7 +339,10 @@ mod tests { INITIAL_BALANCE - send_amount ); // Deposit executed - assert_eq!(relay_chain::Balances::free_balance(para_account_id(2)), send_amount); + assert_eq!( + relay_chain::Balances::free_balance(para_account_id(2)), + INITIAL_BALANCE + send_amount + ); }); // Check that QueryResponse message was received From 6fda480a38dc6eaeb9976e1c65956897d062e60e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 7 Mar 2022 09:15:41 +0100 Subject: [PATCH 065/231] Bump --- Cargo.lock | 324 ++++++++++++++++++++++++++--------------------------- 1 file changed, 162 insertions(+), 162 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f02a6391fd8..800973b38c08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -450,7 +450,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "beefy-primitives", "fnv", @@ -480,7 +480,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -503,12 +503,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "scale-info", @@ -2063,7 +2063,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", ] @@ -2081,7 +2081,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -2103,7 +2103,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "Inflector", "chrono", @@ -2144,7 +2144,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -2158,7 +2158,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -2186,7 +2186,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "bitflags", "frame-metadata", @@ -2215,7 +2215,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2227,7 +2227,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.3", @@ -2239,7 +2239,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "proc-macro2", "quote", @@ -2249,7 +2249,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2272,7 +2272,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -2283,7 +2283,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "log", @@ -2300,7 +2300,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -2315,7 +2315,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "sp-api", @@ -2324,7 +2324,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "sp-api", @@ -2520,7 +2520,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "chrono", "frame-election-provider-support", @@ -4975,7 +4975,7 @@ checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -4989,7 +4989,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5005,7 +5005,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5020,7 +5020,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5044,7 +5044,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5064,7 +5064,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-election-provider-support", "frame-support", @@ -5084,7 +5084,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5099,7 +5099,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "beefy-primitives", "frame-support", @@ -5115,7 +5115,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -5140,7 +5140,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5224,7 +5224,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5241,7 +5241,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5257,7 +5257,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5280,7 +5280,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5298,7 +5298,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5313,7 +5313,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5336,7 +5336,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5352,7 +5352,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5372,7 +5372,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5389,7 +5389,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5406,7 +5406,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5424,7 +5424,7 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5440,7 +5440,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5457,7 +5457,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5472,7 +5472,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5486,7 +5486,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5503,7 +5503,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5526,7 +5526,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5542,7 +5542,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5557,7 +5557,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5571,7 +5571,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5587,7 +5587,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5608,7 +5608,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5624,7 +5624,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5638,7 +5638,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5661,7 +5661,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -5672,7 +5672,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "log", "sp-arithmetic", @@ -5681,7 +5681,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5695,7 +5695,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5713,7 +5713,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5732,7 +5732,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-support", "frame-system", @@ -5749,7 +5749,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5766,7 +5766,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5777,7 +5777,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5794,7 +5794,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -5810,7 +5810,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-benchmarking", "frame-support", @@ -8272,7 +8272,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "env_logger 0.9.0", "jsonrpsee 0.8.0", @@ -8619,7 +8619,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "log", "sp-core", @@ -8630,7 +8630,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "futures 0.3.21", @@ -8657,7 +8657,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "futures-timer", @@ -8680,7 +8680,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8696,7 +8696,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.0", @@ -8713,7 +8713,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -8724,7 +8724,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "chrono", "clap", @@ -8762,7 +8762,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "fnv", "futures 0.3.21", @@ -8790,7 +8790,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "hash-db", "kvdb", @@ -8815,7 +8815,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "futures 0.3.21", @@ -8839,7 +8839,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "fork-tree", @@ -8882,7 +8882,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -8906,7 +8906,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8919,7 +8919,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "futures 0.3.21", @@ -8944,7 +8944,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "sc-client-api", "sp-authorship", @@ -8955,7 +8955,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "lazy_static", "lru 0.6.6", @@ -8982,7 +8982,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "environmental", "parity-scale-codec", @@ -8999,7 +8999,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "log", "parity-scale-codec", @@ -9015,7 +9015,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "cfg-if 1.0.0", "libc", @@ -9033,7 +9033,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "ahash", "async-trait", @@ -9073,7 +9073,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "finality-grandpa", "futures 0.3.21", @@ -9097,7 +9097,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "ansi_term", "futures 0.3.21", @@ -9114,7 +9114,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "hex", @@ -9129,7 +9129,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "asynchronous-codec 0.5.0", @@ -9178,7 +9178,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "ahash", "futures 0.3.21", @@ -9195,7 +9195,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "bytes 1.1.0", "fnv", @@ -9223,7 +9223,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "libp2p", @@ -9236,7 +9236,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9245,7 +9245,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "hash-db", @@ -9276,7 +9276,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9301,7 +9301,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9318,7 +9318,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "directories", @@ -9382,7 +9382,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "log", "parity-scale-codec", @@ -9396,7 +9396,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -9417,7 +9417,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "chrono", "futures 0.3.21", @@ -9435,7 +9435,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "ansi_term", "atty", @@ -9466,7 +9466,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -9477,7 +9477,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "futures-timer", @@ -9504,7 +9504,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "log", @@ -9517,7 +9517,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "futures-timer", @@ -10021,7 +10021,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "hash-db", "log", @@ -10038,7 +10038,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "blake2 0.10.2", "proc-macro-crate 1.1.3", @@ -10050,7 +10050,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "scale-info", @@ -10063,7 +10063,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "integer-sqrt", "num-traits", @@ -10078,7 +10078,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "scale-info", @@ -10091,7 +10091,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "parity-scale-codec", @@ -10103,7 +10103,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "sp-api", @@ -10115,7 +10115,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "log", @@ -10133,7 +10133,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "futures 0.3.21", @@ -10152,7 +10152,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "merlin", @@ -10175,7 +10175,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "scale-info", @@ -10189,7 +10189,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -10201,7 +10201,7 @@ dependencies = [ [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "base58", "bitflags", @@ -10247,7 +10247,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "blake2 0.10.2", "byteorder", @@ -10261,7 +10261,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "proc-macro2", "quote", @@ -10272,7 +10272,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "kvdb", "parking_lot 0.12.0", @@ -10281,7 +10281,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "proc-macro2", "quote", @@ -10291,7 +10291,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "environmental", "parity-scale-codec", @@ -10302,7 +10302,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "finality-grandpa", "log", @@ -10320,7 +10320,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10334,7 +10334,7 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "hash-db", @@ -10359,7 +10359,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "lazy_static", "sp-core", @@ -10370,7 +10370,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "futures 0.3.21", @@ -10387,7 +10387,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "thiserror", "zstd", @@ -10396,7 +10396,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "scale-info", @@ -10411,7 +10411,7 @@ dependencies = [ [[package]] name = "sp-npos-elections-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -10422,7 +10422,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "sp-api", "sp-core", @@ -10432,7 +10432,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "backtrace", "lazy_static", @@ -10442,7 +10442,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "rustc-hash", "serde", @@ -10452,7 +10452,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "either", "hash256-std-hasher", @@ -10474,7 +10474,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10491,7 +10491,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "Inflector", "proc-macro-crate 1.1.3", @@ -10503,7 +10503,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "serde", "serde_json", @@ -10512,7 +10512,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "scale-info", @@ -10526,7 +10526,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "scale-info", @@ -10537,7 +10537,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "hash-db", "log", @@ -10560,12 +10560,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10578,7 +10578,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "log", "sp-core", @@ -10591,7 +10591,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "futures-timer", @@ -10607,7 +10607,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "sp-std", @@ -10619,7 +10619,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "sp-api", "sp-runtime", @@ -10628,7 +10628,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "log", @@ -10644,7 +10644,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "hash-db", "memory-db", @@ -10660,7 +10660,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10677,7 +10677,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10688,7 +10688,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "impl-trait-for-tuples", "log", @@ -10889,7 +10889,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "platforms", ] @@ -10897,7 +10897,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.21", @@ -10919,7 +10919,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures-util", "hyper", @@ -10932,7 +10932,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "async-trait", "futures 0.3.21", @@ -10958,7 +10958,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "futures 0.3.21", "substrate-test-utils-derive", @@ -10968,7 +10968,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -10979,7 +10979,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "ansi_term", "build-helper", @@ -11638,7 +11638,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#32a4fe01f110a755bf22eb8f803cdfd7052d4f8b" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" dependencies = [ "clap", "jsonrpsee 0.4.1", From 3d5ab32275f73f6b25e87cd24c29ff6013b42f49 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 8 Mar 2022 10:58:56 +0100 Subject: [PATCH 066/231] XCM v3: Support for non-fungibles (#4950) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * NFT support and a test * New files. * Integration tests for sending NFTs * Formatting * Broken Cargo features * Use 2021 edition * Fixes * Formatting * Formatting * Update xcm/xcm-builder/src/asset_conversion.rs Co-authored-by: Keith Yeung * Update xcm/xcm-builder/src/nonfungibles_adapter.rs Co-authored-by: Keith Yeung * Update xcm/xcm-executor/src/lib.rs Co-authored-by: Keith Yeung * Fixes * Fixes * Fixes * Formatting * Fixes Co-authored-by: Bastian Köcher Co-authored-by: Keith Yeung --- Cargo.lock | 18 + runtime/kusama/src/xcm_config.rs | 4 +- runtime/parachains/src/ump/benchmarking.rs | 6 +- runtime/polkadot/src/xcm_config.rs | 4 +- runtime/westend/src/weights/xcm/mod.rs | 2 +- .../src/generic/benchmarking.rs | 2 +- xcm/pallet-xcm-benchmarks/src/mock.rs | 7 +- xcm/pallet-xcm/src/lib.rs | 46 +-- xcm/src/lib.rs | 2 +- xcm/src/v2/mod.rs | 20 +- xcm/src/v3/junction.rs | 12 +- xcm/src/v3/junctions.rs | 8 +- xcm/src/v3/mod.rs | 16 +- xcm/src/v3/multiasset.rs | 141 +++++++- xcm/src/v3/multilocation.rs | 8 +- xcm/xcm-builder/src/asset_conversion.rs | 149 +++++++++ xcm/xcm-builder/src/filter_asset_location.rs | 19 +- xcm/xcm-builder/src/fungibles_adapter.rs | 99 +----- xcm/xcm-builder/src/lib.rs | 17 +- .../{matches_fungible.rs => matches_token.rs} | 44 ++- xcm/xcm-builder/src/nonfungibles_adapter.rs | 252 ++++++++++++++ xcm/xcm-builder/src/test_utils.rs | 2 +- xcm/xcm-builder/src/tests/assets.rs | 214 ++++++------ xcm/xcm-builder/src/tests/basic.rs | 29 +- xcm/xcm-builder/src/tests/bridging/mod.rs | 2 +- .../tests/bridging/paid_remote_relay_relay.rs | 14 +- xcm/xcm-builder/src/tests/locking.rs | 67 ++-- xcm/xcm-builder/src/tests/mock.rs | 11 +- xcm/xcm-builder/src/tests/mod.rs | 8 +- xcm/xcm-builder/src/tests/origins.rs | 14 +- xcm/xcm-builder/src/tests/querying.rs | 2 +- xcm/xcm-builder/src/tests/transacting.rs | 11 +- xcm/xcm-builder/src/tests/weight.rs | 20 +- xcm/xcm-executor/src/config.rs | 16 +- xcm/xcm-executor/src/lib.rs | 36 +- .../src/traits/filter_asset_location.rs | 21 +- .../src/traits/matches_fungible.rs | 32 -- xcm/xcm-executor/src/traits/mod.rs | 19 +- ...matches_fungibles.rs => token_matching.rs} | 54 ++- xcm/xcm-executor/src/traits/transact_asset.rs | 10 +- xcm/xcm-simulator/example/Cargo.toml | 18 + xcm/xcm-simulator/example/src/lib.rs | 307 ++++++++++++++++-- xcm/xcm-simulator/example/src/parachain.rs | 103 +++++- xcm/xcm-simulator/example/src/relay_chain.rs | 62 +++- 44 files changed, 1439 insertions(+), 509 deletions(-) create mode 100644 xcm/xcm-builder/src/asset_conversion.rs rename xcm/xcm-builder/src/{matches_fungible.rs => matches_token.rs} (67%) create mode 100644 xcm/xcm-builder/src/nonfungibles_adapter.rs delete mode 100644 xcm/xcm-executor/src/traits/matches_fungible.rs rename xcm/xcm-executor/src/traits/{matches_fungibles.rs => token_matching.rs} (51%) diff --git a/Cargo.lock b/Cargo.lock index 800973b38c08..17d92e732d60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5791,6 +5791,21 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-uniques" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#f6679ddd31f68e9f1578064d58a246130c27026b" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -12634,7 +12649,9 @@ version = "0.9.17" dependencies = [ "frame-support", "frame-system", + "log", "pallet-balances", + "pallet-uniques", "pallet-xcm", "parity-scale-codec", "polkadot-core-primitives", @@ -12645,6 +12662,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-tracing", "xcm", "xcm-builder", "xcm-executor", diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index aab416f7f33d..8adb87b804a6 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -21,7 +21,7 @@ use super::{ Origin, ParaId, Runtime, WeightToFee, XcmPallet, }; use frame_support::{ - match_type, parameter_types, + match_types, parameter_types, traits::{Everything, Nothing}, weights::Weight, }; @@ -114,7 +114,7 @@ parameter_types! { pub type TrustedTeleporters = (xcm_builder::Case, xcm_builder::Case); -match_type! { +match_types! { pub type OnlyParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; diff --git a/runtime/parachains/src/ump/benchmarking.rs b/runtime/parachains/src/ump/benchmarking.rs index 2c132324d44a..0d38e77b7b71 100644 --- a/runtime/parachains/src/ump/benchmarking.rs +++ b/runtime/parachains/src/ump/benchmarking.rs @@ -42,7 +42,7 @@ fn queue_upward_msg( fn create_message_min_size(size: u32) -> Vec { // Create a message with an empty remark call to determine the encoding overhead let msg_size_empty_transact = VersionedXcm::::from(Xcm::(vec![Transact { - origin_type: OriginKind::SovereignAccount, + origin_kind: OriginKind::SovereignAccount, require_weight_at_most: Weight::MAX, call: frame_system::Call::::remark_with_event { remark: vec![] }.encode().into(), }])) @@ -54,7 +54,7 @@ fn create_message_min_size(size: u32) -> Vec { let mut remark = Vec::new(); remark.resize(size, 0u8); let msg = VersionedXcm::::from(Xcm::(vec![Transact { - origin_type: OriginKind::SovereignAccount, + origin_kind: OriginKind::SovereignAccount, require_weight_at_most: Weight::MAX, call: frame_system::Call::::remark_with_event { remark }.encode().into(), }])) @@ -69,7 +69,7 @@ fn create_message_overweight() -> Vec { // We use a `set_code` Call because it let call = frame_system::Call::::set_code { code: vec![] }; VersionedXcm::::from(Xcm::(vec![Transact { - origin_type: OriginKind::Superuser, + origin_kind: OriginKind::Superuser, require_weight_at_most: max_block_weight, call: call.encode().into(), }])) diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 7f67563bf319..d88596847983 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -21,7 +21,7 @@ use super::{ Origin, ParaId, Runtime, WeightToFee, XcmPallet, }; use frame_support::{ - match_type, parameter_types, + match_types, parameter_types, traits::{Everything, Nothing}, weights::Weight, }; @@ -108,7 +108,7 @@ parameter_types! { pub type TrustedTeleporters = (xcm_builder::Case,); -match_type! { +match_types! { pub type OnlyParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 77fba4396aaa..226328992e0f 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -98,7 +98,7 @@ impl XcmWeightInfo for WestendXcmWeight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( - _origin_type: &OriginKind, + _origin_kind: &OriginKind, _require_weight_at_most: &u64, _call: &DoubleEncoded, ) -> Weight { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index adc2d98a1bb0..2d3b4fe6ff91 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -63,7 +63,7 @@ benchmarks! { let fee_asset = Concrete(Here.into()); let instruction = Instruction::>::BuyExecution { - fees: (fee_asset, 100_000_000).into(), // should be something inside of holding + fees: (fee_asset, 100_000_000u128).into(), // should be something inside of holding weight_limit: WeightLimit::Unlimited, }; diff --git a/xcm/pallet-xcm-benchmarks/src/mock.rs b/xcm/pallet-xcm-benchmarks/src/mock.rs index 85bbea99d775..e2940ff83c4e 100644 --- a/xcm/pallet-xcm-benchmarks/src/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/mock.rs @@ -15,8 +15,7 @@ // along with Polkadot. If not, see . use crate::*; -use frame_support::{parameter_types, weights::Weight}; -use xcm_executor::traits::FilterAssetLocation; +use frame_support::{parameter_types, traits::ContainsPair, weights::Weight}; // An xcm sender/receiver akin to > /dev/null pub struct DevNull; @@ -67,8 +66,8 @@ parameter_types! { } pub struct AllAssetLocationsPass; -impl FilterAssetLocation for AllAssetLocationsPass { - fn filter_asset_location(_: &MultiAsset, _: &MultiLocation) -> bool { +impl ContainsPair for AllAssetLocationsPass { + fn contains(_: &MultiAsset, _: &MultiLocation) -> bool { true } } diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index e7f8c82630a7..c31bcc7c7c07 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -25,7 +25,7 @@ mod tests; use codec::{Decode, Encode, EncodeLike}; use frame_support::traits::{ - Contains, Currency, Defensive, EnsureOrigin, Get, LockableCurrency, OriginTrait, + Contains, ContainsPair, Currency, Defensive, EnsureOrigin, Get, LockableCurrency, OriginTrait, }; use scale_info::TypeInfo; use sp_runtime::{ @@ -82,48 +82,6 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(_); - /// A trait for querying whether a type can be said to "contain" a single pair-value. - pub trait ContainsPair { - /// Return `true` if this "contains" the pair-value `a, b`. - fn contains(a: &A, b: &B) -> bool; - } - - impl ContainsPair for frame_support::traits::Everything { - fn contains(_: &A, _: &B) -> bool { - true - } - } - - impl ContainsPair for frame_support::traits::Nothing { - fn contains(_: &A, _: &B) -> bool { - false - } - } - - #[impl_trait_for_tuples::impl_for_tuples(0, 30)] - impl ContainsPair for Tuple { - fn contains(a: &A, b: &B) -> bool { - for_tuples!( #( - if Tuple::contains(a, b) { return true } - )* ); - false - } - } - - /// Create a type which implements the `Contains` trait for a particular type with syntax similar - /// to `matches!`. - #[macro_export] - macro_rules! match_type { - ( pub type $n:ident: impl ContainsPair<$a:ty, $b:ty> = { $phead:pat_param $( | $ptail:pat )* } ; ) => { - pub struct $n; - impl $crate::traits::ContainsPair<$a, $b> for $n { - fn contains(a: &$a, b: &$b) -> bool { - matches!((a, b), $phead $( | $ptail )* ) - } - } - } - } - pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -1315,7 +1273,7 @@ impl Pallet { } else { None }; - log::trace!(target: "xcm::send_xcm", "dest: {:?}, message: {:?}", &dest, &message); + log::debug!(target: "xcm::send_xcm", "dest: {:?}, message: {:?}", &dest, &message); let (ticket, price) = validate_send::(dest, message)?; if let Some(fee_payer) = maybe_fee_payer { Self::charge_fees(fee_payer, price).map_err(|_| SendError::Fees)?; diff --git a/xcm/src/lib.rs b/xcm/src/lib.rs index e883f959b5b9..bef1fa7e29fe 100644 --- a/xcm/src/lib.rs +++ b/xcm/src/lib.rs @@ -561,5 +561,5 @@ pub trait GetWeight { #[test] fn conversion_works() { use latest::prelude::*; - let _: VersionedMultiAssets = (Here, 1).into(); + let _: VersionedMultiAssets = (Here, 1u128).into(); } diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index 4a787877fa95..813d0e95d15a 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -1026,10 +1026,12 @@ mod tests { #[test] fn basic_roundtrip_works() { - let xcm = - Xcm::<()>(vec![TransferAsset { assets: (Here, 1).into(), beneficiary: Here.into() }]); + let xcm = Xcm::<()>(vec![TransferAsset { + assets: (Here, 1u128).into(), + beneficiary: Here.into(), + }]); let old_xcm = - OldXcm::<()>::TransferAsset { assets: (Here, 1).into(), beneficiary: Here.into() }; + OldXcm::<()>::TransferAsset { assets: (Here, 1u128).into(), beneficiary: Here.into() }; assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); assert_eq!(new_xcm, xcm); @@ -1038,12 +1040,12 @@ mod tests { #[test] fn teleport_roundtrip_works() { let xcm = Xcm::<()>(vec![ - ReceiveTeleportedAsset((Here, 1).into()), + ReceiveTeleportedAsset((Here, 1u128).into()), ClearOrigin, DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Here.into() }, ]); let old_xcm: OldXcm<()> = OldXcm::<()>::ReceiveTeleportedAsset { - assets: (Here, 1).into(), + assets: (Here, 1u128).into(), effects: vec![OldOrder::DepositAsset { assets: Wild(All), max_assets: 1, @@ -1058,16 +1060,16 @@ mod tests { #[test] fn reserve_deposit_roundtrip_works() { let xcm = Xcm::<()>(vec![ - ReserveAssetDeposited((Here, 1).into()), + ReserveAssetDeposited((Here, 1u128).into()), ClearOrigin, - BuyExecution { fees: (Here, 1).into(), weight_limit: Some(1).into() }, + BuyExecution { fees: (Here, 1u128).into(), weight_limit: Some(1).into() }, DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Here.into() }, ]); let old_xcm: OldXcm<()> = OldXcm::<()>::ReserveAssetDeposited { - assets: (Here, 1).into(), + assets: (Here, 1u128).into(), effects: vec![ OldOrder::BuyExecution { - fees: (Here, 1).into(), + fees: (Here, 1u128).into(), debt: 1, weight: 0, instructions: vec![], diff --git a/xcm/src/v3/junction.rs b/xcm/src/v3/junction.rs index 60fbff43f229..e778df963591 100644 --- a/xcm/src/v3/junction.rs +++ b/xcm/src/v3/junction.rs @@ -71,7 +71,9 @@ impl From for Option { } /// An identifier of a pluralistic body. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, +)] pub enum BodyId { /// The only body in its context. Unit, @@ -115,7 +117,9 @@ impl TryFrom for BodyId { } /// A part of a pluralistic body. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, +)] pub enum BodyPart { /// The body's declaration, under whatever means it decides. Voice, @@ -176,7 +180,9 @@ impl TryFrom for BodyPart { /// A single item in a path to describe the relative location of a consensus system. /// /// Each item assumes a pre-existing location as its context and is defined in terms of it. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, +)] pub enum Junction { /// An indexed parachain belonging to and operated by the context. /// diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs index 88df3a0d3061..d958478ac50d 100644 --- a/xcm/src/v3/junctions.rs +++ b/xcm/src/v3/junctions.rs @@ -29,7 +29,9 @@ pub(crate) const MAX_JUNCTIONS: usize = 8; /// /// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for /// instructions on constructing parent junctions. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, +)] pub enum Junctions { /// The interpreting consensus system. Here, @@ -527,6 +529,10 @@ impl Junctions { } return self.at(prefix.len()) } + + pub fn starts_with(&self, prefix: &Junctions) -> bool { + prefix.len() <= self.len() && prefix.iter().zip(self.iter()).all(|(x, y)| x == y) + } } impl TryFrom for Junctions { diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 5e522e32baba..1e92ea4d79a1 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -1220,8 +1220,10 @@ mod tests { #[test] fn basic_roundtrip_works() { - let xcm = - Xcm::<()>(vec![TransferAsset { assets: (Here, 1).into(), beneficiary: Here.into() }]); + let xcm = Xcm::<()>(vec![TransferAsset { + assets: (Here, 1u128).into(), + beneficiary: Here.into(), + }]); let old_xcm = OldXcm::<()>(vec![OldInstruction::TransferAsset { assets: (OldHere, 1).into(), beneficiary: OldHere.into(), @@ -1234,7 +1236,7 @@ mod tests { #[test] fn teleport_roundtrip_works() { let xcm = Xcm::<()>(vec![ - ReceiveTeleportedAsset((Here, 1).into()), + ReceiveTeleportedAsset((Here, 1u128).into()), ClearOrigin, DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); @@ -1255,9 +1257,9 @@ mod tests { #[test] fn reserve_deposit_roundtrip_works() { let xcm = Xcm::<()>(vec![ - ReserveAssetDeposited((Here, 1).into()), + ReserveAssetDeposited((Here, 1u128).into()), ClearOrigin, - BuyExecution { fees: (Here, 1).into(), weight_limit: Some(1).into() }, + BuyExecution { fees: (Here, 1u128).into(), weight_limit: Some(1).into() }, DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); let old_xcm = OldXcm::<()>(vec![ @@ -1281,7 +1283,7 @@ mod tests { #[test] fn deposit_asset_roundtrip_works() { let xcm = Xcm::<()>(vec![ - WithdrawAsset((Here, 1).into()), + WithdrawAsset((Here, 1u128).into()), DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); let old_xcm = OldXcm::<()>(vec![ @@ -1300,7 +1302,7 @@ mod tests { #[test] fn deposit_reserve_asset_roundtrip_works() { let xcm = Xcm::<()>(vec![ - WithdrawAsset((Here, 1).into()), + WithdrawAsset((Here, 1u128).into()), DepositReserveAsset { assets: Wild(AllCounted(1)), dest: Here.into(), diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index 9762fd97c02a..c93ac0902789 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -39,7 +39,9 @@ use parity_scale_codec::{self as codec, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A general identifier for an instance of a non-fungible asset class. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, +)] pub enum AssetInstance { /// Undefined - used if the non-fungible asset class has only one instance. Undefined, @@ -107,6 +109,130 @@ impl From<[u8; 32]> for AssetInstance { } } +impl From for AssetInstance { + fn from(x: u8) -> Self { + Self::Index(x as u128) + } +} + +impl From for AssetInstance { + fn from(x: u16) -> Self { + Self::Index(x as u128) + } +} + +impl From for AssetInstance { + fn from(x: u32) -> Self { + Self::Index(x as u128) + } +} + +impl From for AssetInstance { + fn from(x: u64) -> Self { + Self::Index(x as u128) + } +} + +impl TryFrom for () { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Undefined => Ok(()), + _ => Err(()), + } + } +} + +impl TryFrom for [u8; 4] { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Array4(x) => Ok(x), + _ => Err(()), + } + } +} + +impl TryFrom for [u8; 8] { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Array8(x) => Ok(x), + _ => Err(()), + } + } +} + +impl TryFrom for [u8; 16] { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Array16(x) => Ok(x), + _ => Err(()), + } + } +} + +impl TryFrom for [u8; 32] { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Array32(x) => Ok(x), + _ => Err(()), + } + } +} + +impl TryFrom for u8 { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Index(x) => x.try_into().map_err(|_| ()), + _ => Err(()), + } + } +} + +impl TryFrom for u16 { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Index(x) => x.try_into().map_err(|_| ()), + _ => Err(()), + } + } +} + +impl TryFrom for u32 { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Index(x) => x.try_into().map_err(|_| ()), + _ => Err(()), + } + } +} + +impl TryFrom for u64 { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Index(x) => x.try_into().map_err(|_| ()), + _ => Err(()), + } + } +} + +impl TryFrom for u128 { + type Error = (); + fn try_from(x: AssetInstance) -> Result { + match x { + AssetInstance::Index(x) => Ok(x), + _ => Err(()), + } + } +} + /// Classification of whether an asset is fungible or not, along with a mandatory amount or instance. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] pub enum Fungibility { @@ -122,6 +248,13 @@ impl Fungibility { } } +impl From for Fungibility { + fn from(amount: i32) -> Fungibility { + debug_assert_ne!(amount, 0); + Fungibility::Fungible(amount as u128) + } +} + impl From for Fungibility { fn from(amount: u128) -> Fungibility { debug_assert_ne!(amount, 0); @@ -167,7 +300,9 @@ impl TryFrom for WildFungibility { } /// Classification of an asset being concrete or abstract. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, +)] pub enum AssetId { Concrete(MultiLocation), Abstract([u8; 32]), @@ -703,5 +838,5 @@ impl TryFrom<(OldMultiAssetFilter, u32)> for MultiAssetFilter { fn conversion_works() { use super::prelude::*; - let _: MultiAssets = (Here, 1).into(); + let _: MultiAssets = (Here, 1u128).into(); } diff --git a/xcm/src/v3/multilocation.rs b/xcm/src/v3/multilocation.rs index 6cd684afa147..f5d9256aacc3 100644 --- a/xcm/src/v3/multilocation.rs +++ b/xcm/src/v3/multilocation.rs @@ -51,7 +51,9 @@ use scale_info::TypeInfo; /// that a value is strictly an interior location, in those cases, `Junctions` may be used. /// /// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system. -#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo, MaxEncodedLen)] +#[derive( + Copy, Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo, MaxEncodedLen, +)] pub struct MultiLocation { /// The number of parent junctions at the beginning of this `MultiLocation`. pub parents: u8, @@ -268,6 +270,10 @@ impl MultiLocation { self.interior.match_and_split(&prefix.interior) } + pub fn starts_with(&self, prefix: &MultiLocation) -> bool { + self.parents == prefix.parents && self.interior.starts_with(&prefix.interior) + } + /// Mutate `self` so that it is suffixed with `suffix`. /// /// Does not modify `self` and returns `Err` with `suffix` in case of overflow. diff --git a/xcm/xcm-builder/src/asset_conversion.rs b/xcm/xcm-builder/src/asset_conversion.rs new file mode 100644 index 000000000000..1a13f1ffb444 --- /dev/null +++ b/xcm/xcm-builder/src/asset_conversion.rs @@ -0,0 +1,149 @@ +// Copyright 2022 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 . + +//! Adapters to work with `frame_support::traits::tokens::fungibles` through XCM. + +use frame_support::traits::Get; +use sp_std::{borrow::Borrow, marker::PhantomData, prelude::*, result}; +use xcm::latest::prelude::*; +use xcm_executor::traits::{Convert, Error as MatchError, MatchesFungibles, MatchesNonFungibles}; + +/// Converter struct implementing `AssetIdConversion` converting a numeric asset ID (must be `TryFrom/TryInto`) into +/// a `GeneralIndex` junction, prefixed by some `MultiLocation` value. The `MultiLocation` value will typically be a +/// `PalletInstance` junction. +pub struct AsPrefixedGeneralIndex( + PhantomData<(Prefix, AssetId, ConvertAssetId)>, +); +impl, AssetId: Clone, ConvertAssetId: Convert> + Convert for AsPrefixedGeneralIndex +{ + fn convert_ref(id: impl Borrow) -> result::Result { + let prefix = Prefix::get(); + let id = id.borrow(); + if prefix.parent_count() != id.parent_count() || + prefix + .interior() + .iter() + .enumerate() + .any(|(index, junction)| id.interior().at(index) != Some(junction)) + { + return Err(()) + } + match id.interior().at(prefix.interior().len()) { + Some(Junction::GeneralIndex(id)) => ConvertAssetId::convert_ref(id), + _ => Err(()), + } + } + fn reverse_ref(what: impl Borrow) -> result::Result { + let mut location = Prefix::get(); + let id = ConvertAssetId::reverse_ref(what)?; + location.push_interior(Junction::GeneralIndex(id)).map_err(|_| ())?; + Ok(location) + } +} + +pub struct ConvertedConcreteId( + PhantomData<(AssetId, Balance, ConvertAssetId, ConvertOther)>, +); +impl< + AssetId: Clone, + Balance: Clone, + ConvertAssetId: Convert, + ConvertBalance: Convert, + > MatchesFungibles + for ConvertedConcreteId +{ + fn matches_fungibles(a: &MultiAsset) -> result::Result<(AssetId, Balance), MatchError> { + let (amount, id) = match (&a.fun, &a.id) { + (Fungible(ref amount), Concrete(ref id)) => (amount, id), + _ => return Err(MatchError::AssetNotFound), + }; + let what = + ConvertAssetId::convert_ref(id).map_err(|_| MatchError::AssetIdConversionFailed)?; + let amount = ConvertBalance::convert_ref(amount) + .map_err(|_| MatchError::AmountToBalanceConversionFailed)?; + Ok((what, amount)) + } +} +impl< + ClassId: Clone, + InstanceId: Clone, + ConvertClassId: Convert, + ConvertInstanceId: Convert, + > MatchesNonFungibles + for ConvertedConcreteId +{ + fn matches_nonfungibles(a: &MultiAsset) -> result::Result<(ClassId, InstanceId), MatchError> { + let (instance, class) = match (&a.fun, &a.id) { + (NonFungible(ref instance), Concrete(ref class)) => (instance, class), + _ => return Err(MatchError::AssetNotFound), + }; + let what = + ConvertClassId::convert_ref(class).map_err(|_| MatchError::AssetIdConversionFailed)?; + let instance = ConvertInstanceId::convert_ref(instance) + .map_err(|_| MatchError::InstanceConversionFailed)?; + Ok((what, instance)) + } +} + +pub struct ConvertedAbstractId( + PhantomData<(AssetId, Balance, ConvertAssetId, ConvertOther)>, +); +impl< + AssetId: Clone, + Balance: Clone, + ConvertAssetId: Convert<[u8; 32], AssetId>, + ConvertBalance: Convert, + > MatchesFungibles + for ConvertedAbstractId +{ + fn matches_fungibles(a: &MultiAsset) -> result::Result<(AssetId, Balance), MatchError> { + let (amount, id) = match (&a.fun, &a.id) { + (Fungible(ref amount), Abstract(ref id)) => (amount, id), + _ => return Err(MatchError::AssetNotFound), + }; + let what = + ConvertAssetId::convert_ref(id).map_err(|_| MatchError::AssetIdConversionFailed)?; + let amount = ConvertBalance::convert_ref(amount) + .map_err(|_| MatchError::AmountToBalanceConversionFailed)?; + Ok((what, amount)) + } +} +impl< + ClassId: Clone, + InstanceId: Clone, + ConvertClassId: Convert<[u8; 32], ClassId>, + ConvertInstanceId: Convert, + > MatchesNonFungibles + for ConvertedAbstractId +{ + fn matches_nonfungibles(a: &MultiAsset) -> result::Result<(ClassId, InstanceId), MatchError> { + let (instance, class) = match (&a.fun, &a.id) { + (NonFungible(ref instance), Abstract(ref class)) => (instance, class), + _ => return Err(MatchError::AssetNotFound), + }; + let what = + ConvertClassId::convert_ref(class).map_err(|_| MatchError::AssetIdConversionFailed)?; + let instance = ConvertInstanceId::convert_ref(instance) + .map_err(|_| MatchError::InstanceConversionFailed)?; + Ok((what, instance)) + } +} + +#[deprecated = "Use `ConvertedConcreteId` instead"] +pub type ConvertedConcreteAssetId = ConvertedConcreteId; +#[deprecated = "Use `ConvertedAbstractId` instead"] +pub type ConvertedAbstractAssetId = ConvertedAbstractId; diff --git a/xcm/xcm-builder/src/filter_asset_location.rs b/xcm/xcm-builder/src/filter_asset_location.rs index cb404a4dbce9..1701988d624b 100644 --- a/xcm/xcm-builder/src/filter_asset_location.rs +++ b/xcm/xcm-builder/src/filter_asset_location.rs @@ -14,27 +14,28 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -//! Various implementations of `FilterAssetLocation`. +//! Various implementations of `ContainsPair`. -use frame_support::traits::Get; +use frame_support::traits::{ContainsPair, Get}; use sp_std::marker::PhantomData; use xcm::latest::{AssetId::Concrete, MultiAsset, MultiAssetFilter, MultiLocation}; -use xcm_executor::traits::FilterAssetLocation; /// Accepts an asset iff it is a native asset. pub struct NativeAsset; -impl FilterAssetLocation for NativeAsset { - fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { - log::trace!(target: "xcm::filter_asset_location", "NativeAsset asset: {:?}, origin: {:?}", asset, origin); +impl ContainsPair for NativeAsset { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { + log::trace!(target: "xcm::contains", "NativeAsset asset: {:?}, origin: {:?}", asset, origin); matches!(asset.id, Concrete(ref id) if id == origin) } } /// Accepts an asset if it is contained in the given `T`'s `Get` implementation. pub struct Case(PhantomData); -impl> FilterAssetLocation for Case { - fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { - log::trace!(target: "xcm::filter_asset_location", "Case asset: {:?}, origin: {:?}", asset, origin); +impl> ContainsPair + for Case +{ + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { + log::trace!(target: "xcm::contains", "Case asset: {:?}, origin: {:?}", asset, origin); let (a, o) = T::get(); a.matches(asset) && &o == origin } diff --git a/xcm/xcm-builder/src/fungibles_adapter.rs b/xcm/xcm-builder/src/fungibles_adapter.rs index cb7abd048d0d..c5e17bbdc2c2 100644 --- a/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/xcm/xcm-builder/src/fungibles_adapter.rs @@ -17,97 +17,10 @@ //! Adapters to work with `frame_support::traits::tokens::fungibles` through XCM. use frame_support::traits::{tokens::fungibles, Contains, Get}; -use sp_std::{borrow::Borrow, marker::PhantomData, prelude::*, result}; -use xcm::latest::{ - AssetId::{Abstract, Concrete}, - Error as XcmError, - Fungibility::Fungible, - Junction, MultiAsset, MultiLocation, Result, -}; +use sp_std::{marker::PhantomData, prelude::*, result}; +use xcm::latest::prelude::*; use xcm_executor::traits::{Convert, Error as MatchError, MatchesFungibles, TransactAsset}; -/// Converter struct implementing `AssetIdConversion` converting a numeric asset ID (must be `TryFrom/TryInto`) into -/// a `GeneralIndex` junction, prefixed by some `MultiLocation` value. The `MultiLocation` value will typically be a -/// `PalletInstance` junction. -pub struct AsPrefixedGeneralIndex( - PhantomData<(Prefix, AssetId, ConvertAssetId)>, -); -impl, AssetId: Clone, ConvertAssetId: Convert> - Convert for AsPrefixedGeneralIndex -{ - fn convert_ref(id: impl Borrow) -> result::Result { - let prefix = Prefix::get(); - let id = id.borrow(); - if prefix.parent_count() != id.parent_count() || - prefix - .interior() - .iter() - .enumerate() - .any(|(index, junction)| id.interior().at(index) != Some(junction)) - { - return Err(()) - } - match id.interior().at(prefix.interior().len()) { - Some(Junction::GeneralIndex(id)) => ConvertAssetId::convert_ref(id), - _ => Err(()), - } - } - fn reverse_ref(what: impl Borrow) -> result::Result { - let mut location = Prefix::get(); - let id = ConvertAssetId::reverse_ref(what)?; - location.push_interior(Junction::GeneralIndex(id)).map_err(|_| ())?; - Ok(location) - } -} - -pub struct ConvertedConcreteAssetId( - PhantomData<(AssetId, Balance, ConvertAssetId, ConvertBalance)>, -); -impl< - AssetId: Clone, - Balance: Clone, - ConvertAssetId: Convert, - ConvertBalance: Convert, - > MatchesFungibles - for ConvertedConcreteAssetId -{ - fn matches_fungibles(a: &MultiAsset) -> result::Result<(AssetId, Balance), MatchError> { - let (amount, id) = match (&a.fun, &a.id) { - (Fungible(ref amount), Concrete(ref id)) => (amount, id), - _ => return Err(MatchError::AssetNotFound), - }; - let what = - ConvertAssetId::convert_ref(id).map_err(|_| MatchError::AssetIdConversionFailed)?; - let amount = ConvertBalance::convert_ref(amount) - .map_err(|_| MatchError::AmountToBalanceConversionFailed)?; - Ok((what, amount)) - } -} - -pub struct ConvertedAbstractAssetId( - PhantomData<(AssetId, Balance, ConvertAssetId, ConvertBalance)>, -); -impl< - AssetId: Clone, - Balance: Clone, - ConvertAssetId: Convert<[u8; 32], AssetId>, - ConvertBalance: Convert, - > MatchesFungibles - for ConvertedAbstractAssetId -{ - fn matches_fungibles(a: &MultiAsset) -> result::Result<(AssetId, Balance), MatchError> { - let (amount, id) = match (&a.fun, &a.id) { - (Fungible(ref amount), Abstract(ref id)) => (amount, id), - _ => return Err(MatchError::AssetNotFound), - }; - let what = - ConvertAssetId::convert_ref(id).map_err(|_| MatchError::AssetIdConversionFailed)?; - let amount = ConvertBalance::convert_ref(amount) - .map_err(|_| MatchError::AmountToBalanceConversionFailed)?; - Ok((what, amount)) - } -} - pub struct FungiblesTransferAdapter( PhantomData<(Assets, Matcher, AccountIdConverter, AccountId)>, ); @@ -165,7 +78,7 @@ impl< CheckingAccount, > { - fn can_check_in(_origin: &MultiLocation, what: &MultiAsset) -> Result { + fn can_check_in(_origin: &MultiLocation, what: &MultiAsset) -> XcmResult { log::trace!( target: "xcm::fungibles_adapter", "can_check_in origin: {:?}, what: {:?}", @@ -216,7 +129,7 @@ impl< } } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> Result { + fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { log::trace!( target: "xcm::fungibles_adapter", "deposit_asset what: {:?}, who: {:?}", @@ -267,7 +180,7 @@ impl< > TransactAsset for FungiblesAdapter { - fn can_check_in(origin: &MultiLocation, what: &MultiAsset) -> Result { + fn can_check_in(origin: &MultiLocation, what: &MultiAsset) -> XcmResult { FungiblesMutateAdapter::< Assets, Matcher, @@ -300,7 +213,7 @@ impl< >::check_out(dest, what) } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> Result { + fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { FungiblesMutateAdapter::< Assets, Matcher, diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 1cde398c7713..e69dfbfbc6af 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -40,6 +40,11 @@ pub use origin_conversion::{ SignedToAccountId32, SovereignSignedViaLocation, }; +mod asset_conversion; +pub use asset_conversion::{AsPrefixedGeneralIndex, ConvertedAbstractId, ConvertedConcreteId}; +#[allow(deprecated)] +pub use asset_conversion::{ConvertedAbstractAssetId, ConvertedConcreteAssetId}; + mod barriers; pub use barriers::{ AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, @@ -50,9 +55,11 @@ mod currency_adapter; pub use currency_adapter::CurrencyAdapter; mod fungibles_adapter; -pub use fungibles_adapter::{ - AsPrefixedGeneralIndex, ConvertedAbstractAssetId, ConvertedConcreteAssetId, FungiblesAdapter, - FungiblesMutateAdapter, FungiblesTransferAdapter, +pub use fungibles_adapter::{FungiblesAdapter, FungiblesMutateAdapter, FungiblesTransferAdapter}; + +mod nonfungibles_adapter; +pub use nonfungibles_adapter::{ + NonFungiblesAdapter, NonFungiblesMutateAdapter, NonFungiblesTransferAdapter, }; mod weight; @@ -60,8 +67,8 @@ pub use weight::{ FixedRateOfFungible, FixedWeightBounds, TakeRevenue, UsingComponents, WeightInfoBounds, }; -mod matches_fungible; -pub use matches_fungible::{IsAbstract, IsConcrete}; +mod matches_token; +pub use matches_token::{IsAbstract, IsConcrete}; mod filter_asset_location; pub use filter_asset_location::{Case, NativeAsset}; diff --git a/xcm/xcm-builder/src/matches_fungible.rs b/xcm/xcm-builder/src/matches_token.rs similarity index 67% rename from xcm/xcm-builder/src/matches_fungible.rs rename to xcm/xcm-builder/src/matches_token.rs index d1ba33f6146e..aa0454fea8f0 100644 --- a/xcm/xcm-builder/src/matches_fungible.rs +++ b/xcm/xcm-builder/src/matches_token.rs @@ -17,14 +17,17 @@ //! Various implementations for the `MatchesFungible` trait. use frame_support::traits::Get; -use sp_runtime::traits::CheckedConversion; -use sp_std::{convert::TryFrom, marker::PhantomData}; +use sp_std::{ + convert::{TryFrom, TryInto}, + marker::PhantomData, +}; use xcm::latest::{ AssetId::{Abstract, Concrete}, - Fungibility::Fungible, + AssetInstance, + Fungibility::{Fungible, NonFungible}, MultiAsset, MultiLocation, }; -use xcm_executor::traits::MatchesFungible; +use xcm_executor::traits::{MatchesFungible, MatchesNonFungible}; /// Converts a `MultiAsset` into balance `B` if it is a concrete fungible with an id equal to that /// given by `T`'s `Get`. @@ -51,7 +54,16 @@ impl, B: TryFrom> MatchesFungible for IsConcrete< fn matches_fungible(a: &MultiAsset) -> Option { match (&a.id, &a.fun) { (Concrete(ref id), Fungible(ref amount)) if id == &T::get() => - CheckedConversion::checked_from(*amount), + (*amount).try_into().ok(), + _ => None, + } + } +} +impl, I: TryFrom> MatchesNonFungible for IsConcrete { + fn matches_nonfungible(a: &MultiAsset) -> Option { + match (&a.id, &a.fun) { + (Concrete(ref id), NonFungible(ref instance)) if id == &T::get() => + instance.clone().try_into().ok(), _ => None, } } @@ -64,16 +76,21 @@ impl, B: TryFrom> MatchesFungible for IsConcrete< /// ``` /// use xcm::latest::prelude::*; /// use xcm_builder::IsAbstract; -/// use xcm_executor::traits::MatchesFungible; +/// use xcm_executor::traits::{MatchesFungible, MatchesNonFungible}; /// /// frame_support::parameter_types! { /// pub TargetLocation: [u8; 32] = [7u8; 32]; /// } /// /// # fn main() { -/// let asset = ([7u8; 32], 999).into(); -/// // match `asset` if it is a concrete asset in `TargetLocation`. +/// let asset = ([7u8; 32], 999u128).into(); +/// // match `asset` if it is an abstract asset in `TargetLocation`. /// assert_eq!( as MatchesFungible>::matches_fungible(&asset), Some(999)); +/// let nft = ([7u8; 32], [42u8; 4]).into(); +/// assert_eq!( +/// as MatchesNonFungible<[u8; 4]>>::matches_nonfungible(&nft), +/// Some([42u8; 4]) +/// ); /// # } /// ``` pub struct IsAbstract(PhantomData); @@ -81,7 +98,16 @@ impl, B: TryFrom> MatchesFungible for IsAbstract { fn matches_fungible(a: &MultiAsset) -> Option { match (&a.id, &a.fun) { (Abstract(ref id), Fungible(ref amount)) if id == &T::get() => - CheckedConversion::checked_from(*amount), + (*amount).try_into().ok(), + _ => None, + } + } +} +impl, B: TryFrom> MatchesNonFungible for IsAbstract { + fn matches_nonfungible(a: &MultiAsset) -> Option { + match (&a.id, &a.fun) { + (Abstract(ref id), NonFungible(ref instance)) if id == &T::get() => + instance.clone().try_into().ok(), _ => None, } } diff --git a/xcm/xcm-builder/src/nonfungibles_adapter.rs b/xcm/xcm-builder/src/nonfungibles_adapter.rs new file mode 100644 index 000000000000..14a749022be0 --- /dev/null +++ b/xcm/xcm-builder/src/nonfungibles_adapter.rs @@ -0,0 +1,252 @@ +// Copyright 2022 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 . + +//! Adapters to work with `frame_support::traits::tokens::fungibles` through XCM. + +use frame_support::{ + ensure, + traits::{tokens::nonfungibles, Contains, Get}, +}; +use sp_std::{marker::PhantomData, prelude::*, result}; +use xcm::latest::prelude::*; +use xcm_executor::traits::{Convert, Error as MatchError, MatchesNonFungibles, TransactAsset}; + +pub struct NonFungiblesTransferAdapter( + PhantomData<(Assets, Matcher, AccountIdConverter, AccountId)>, +); +impl< + Assets: nonfungibles::Transfer, + Matcher: MatchesNonFungibles, + AccountIdConverter: Convert, + AccountId: Clone, // can't get away without it since Currency is generic over it. + > TransactAsset for NonFungiblesTransferAdapter +{ + fn transfer_asset( + what: &MultiAsset, + from: &MultiLocation, + to: &MultiLocation, + ) -> result::Result { + log::trace!( + target: "xcm::non_fungibles_adapter", + "transfer_asset what: {:?}, from: {:?}, to: {:?}", + what, from, to + ); + // Check we handle this asset. + let (class, instance) = Matcher::matches_nonfungibles(what)?; + let destination = AccountIdConverter::convert_ref(to) + .map_err(|()| MatchError::AccountIdConversionFailed)?; + Assets::transfer(&class, &instance, &destination) + .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; + Ok(what.clone().into()) + } +} + +pub struct NonFungiblesMutateAdapter< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, +>(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>); +impl< + Assets: nonfungibles::Mutate, + Matcher: MatchesNonFungibles, + AccountIdConverter: Convert, + AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. + CheckAsset: Contains, + CheckingAccount: Get>, + > TransactAsset + for NonFungiblesMutateAdapter< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + > +{ + fn can_check_in(_origin: &MultiLocation, what: &MultiAsset) -> XcmResult { + log::trace!( + target: "xcm::fungibles_adapter", + "can_check_in origin: {:?}, what: {:?}", + _origin, what + ); + // Check we handle this asset. + let (class, instance) = Matcher::matches_nonfungibles(what)?; + if CheckAsset::contains(&class) { + if let Some(checking_account) = CheckingAccount::get() { + // This is an asset whose teleports we track. + let owner = Assets::owner(&class, &instance); + ensure!(owner == Some(checking_account), XcmError::NotWithdrawable); + ensure!(Assets::can_transfer(&class, &instance), XcmError::NotWithdrawable); + } + } + Ok(()) + } + + fn check_in(_origin: &MultiLocation, what: &MultiAsset) { + log::trace!( + target: "xcm::fungibles_adapter", + "check_in origin: {:?}, what: {:?}", + _origin, what + ); + if let Ok((class, instance)) = Matcher::matches_nonfungibles(what) { + if CheckAsset::contains(&class) { + let ok = Assets::burn(&class, &instance, None).is_ok(); + debug_assert!( + ok, + "`can_check_in` must have returned `true` immediately prior; qed" + ); + } + } + } + + fn check_out(_dest: &MultiLocation, what: &MultiAsset) { + log::trace!( + target: "xcm::fungibles_adapter", + "check_out dest: {:?}, what: {:?}", + _dest, what + ); + if let Ok((class, instance)) = Matcher::matches_nonfungibles(what) { + if CheckAsset::contains(&class) { + if let Some(checking_account) = CheckingAccount::get() { + let ok = Assets::mint_into(&class, &instance, &checking_account).is_ok(); + debug_assert!(ok, "`mint_into` cannot generally fail; qed"); + } + } + } + } + + fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { + log::trace!( + target: "xcm::fungibles_adapter", + "deposit_asset what: {:?}, who: {:?}", + what, who, + ); + // Check we handle this asset. + let (class, instance) = Matcher::matches_nonfungibles(what)?; + let who = AccountIdConverter::convert_ref(who) + .map_err(|()| MatchError::AccountIdConversionFailed)?; + Assets::mint_into(&class, &instance, &who) + .map_err(|e| XcmError::FailedToTransactAsset(e.into())) + } + + fn withdraw_asset( + what: &MultiAsset, + who: &MultiLocation, + ) -> result::Result { + log::trace!( + target: "xcm::fungibles_adapter", + "withdraw_asset what: {:?}, who: {:?}", + what, who, + ); + // Check we handle this asset. + let who = AccountIdConverter::convert_ref(who) + .map_err(|()| MatchError::AccountIdConversionFailed)?; + let (class, instance) = Matcher::matches_nonfungibles(what)?; + Assets::burn(&class, &instance, Some(&who)) + .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; + Ok(what.clone().into()) + } +} + +pub struct NonFungiblesAdapter< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, +>(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>); +impl< + Assets: nonfungibles::Mutate + nonfungibles::Transfer, + Matcher: MatchesNonFungibles, + AccountIdConverter: Convert, + AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. + CheckAsset: Contains, + CheckingAccount: Get>, + > TransactAsset + for NonFungiblesAdapter +{ + fn can_check_in(origin: &MultiLocation, what: &MultiAsset) -> XcmResult { + NonFungiblesMutateAdapter::< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + >::can_check_in(origin, what) + } + + fn check_in(origin: &MultiLocation, what: &MultiAsset) { + NonFungiblesMutateAdapter::< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + >::check_in(origin, what) + } + + fn check_out(dest: &MultiLocation, what: &MultiAsset) { + NonFungiblesMutateAdapter::< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + >::check_out(dest, what) + } + + fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { + NonFungiblesMutateAdapter::< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + >::deposit_asset(what, who) + } + + fn withdraw_asset( + what: &MultiAsset, + who: &MultiLocation, + ) -> result::Result { + NonFungiblesMutateAdapter::< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + >::withdraw_asset(what, who) + } + + fn transfer_asset( + what: &MultiAsset, + from: &MultiLocation, + to: &MultiLocation, + ) -> result::Result { + NonFungiblesTransferAdapter::::transfer_asset( + what, from, to, + ) + } +} diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index bdca8f02ff99..ceb41aa409ac 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -25,7 +25,7 @@ use sp_std::vec::Vec; pub use xcm::latest::prelude::*; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ - traits::{ConvertOrigin, FilterAssetLocation, OnResponse, TransactAsset, UniversalLocation}, + traits::{ConvertOrigin, OnResponse, TransactAsset, UniversalLocation}, Assets, Config, }; diff --git a/xcm/xcm-builder/src/tests/assets.rs b/xcm/xcm-builder/src/tests/assets.rs index e3d4c9ab75fe..afec771cb0a8 100644 --- a/xcm/xcm-builder/src/tests/assets.rs +++ b/xcm/xcm-builder/src/tests/assets.rs @@ -19,79 +19,79 @@ use super::*; #[test] fn exchange_asset_should_work() { AllowUnpaidFrom::set(vec![Parent.into()]); - add_asset(Parent, (Parent, 1000)); - set_exchange_assets(vec![(Here, 100).into()]); + add_asset(Parent, (Parent, 1000u128)); + set_exchange_assets(vec![(Here, 100u128).into()]); let r = XcmExecutor::::execute_xcm( Parent, Xcm(vec![ - WithdrawAsset((Parent, 100).into()), + WithdrawAsset((Parent, 100u128).into()), SetAppendix( vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] .into(), ), ExchangeAsset { - give: Definite((Parent, 50).into()), - want: (Here, 50).into(), + give: Definite((Parent, 50u128).into()), + want: (Here, 50u128).into(), maximal: true, }, ]), 50, ); assert_eq!(r, Outcome::Complete(40)); - assert_eq!(asset_list(Parent), vec![(Here, 100).into(), (Parent, 950).into()]); - assert_eq!(exchange_assets(), vec![(Parent, 50).into()].into()); + assert_eq!(asset_list(Parent), vec![(Here, 100u128).into(), (Parent, 950u128).into()]); + assert_eq!(exchange_assets(), vec![(Parent, 50u128).into()].into()); } #[test] fn exchange_asset_without_maximal_should_work() { AllowUnpaidFrom::set(vec![Parent.into()]); add_asset(Parent, (Parent, 1000)); - set_exchange_assets(vec![(Here, 100).into()]); + set_exchange_assets(vec![(Here, 100u128).into()]); let r = XcmExecutor::::execute_xcm( Parent, Xcm(vec![ - WithdrawAsset((Parent, 100).into()), + WithdrawAsset((Parent, 100u128).into()), SetAppendix( vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] .into(), ), ExchangeAsset { - give: Definite((Parent, 50).into()), - want: (Here, 50).into(), + give: Definite((Parent, 50u128).into()), + want: (Here, 50u128).into(), maximal: false, }, ]), 50, ); assert_eq!(r, Outcome::Complete(40)); - assert_eq!(asset_list(Parent), vec![(Here, 50).into(), (Parent, 950).into()]); - assert_eq!(exchange_assets(), vec![(Here, 50).into(), (Parent, 50).into()].into()); + assert_eq!(asset_list(Parent), vec![(Here, 50u128).into(), (Parent, 950u128).into()]); + assert_eq!(exchange_assets(), vec![(Here, 50u128).into(), (Parent, 50u128).into()].into()); } #[test] fn exchange_asset_should_fail_when_no_deal_possible() { AllowUnpaidFrom::set(vec![Parent.into()]); add_asset(Parent, (Parent, 1000)); - set_exchange_assets(vec![(Here, 100).into()]); + set_exchange_assets(vec![(Here, 100u128).into()]); let r = XcmExecutor::::execute_xcm( Parent, Xcm(vec![ - WithdrawAsset((Parent, 150).into()), + WithdrawAsset((Parent, 150u128).into()), SetAppendix( vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] .into(), ), ExchangeAsset { - give: Definite((Parent, 150).into()), - want: (Here, 150).into(), + give: Definite((Parent, 150u128).into()), + want: (Here, 150u128).into(), maximal: false, }, ]), 50, ); assert_eq!(r, Outcome::Incomplete(40, XcmError::NoDeal)); - assert_eq!(asset_list(Parent), vec![(Parent, 1000).into()]); - assert_eq!(exchange_assets(), vec![(Here, 100).into()].into()); + assert_eq!(asset_list(Parent), vec![(Parent, 1000u128).into()]); + assert_eq!(exchange_assets(), vec![(Here, 100u128).into()].into()); } #[test] @@ -100,16 +100,16 @@ fn paying_reserve_deposit_should_work() { add_reserve(Parent.into(), (Parent, WildFungible).into()); WeightPrice::set((Parent.into(), 1_000_000_000_000)); - let fees = (Parent, 30).into(); + let fees = (Parent, 30u128).into(); let message = Xcm(vec![ - ReserveAssetDeposited((Parent, 100).into()), + ReserveAssetDeposited((Parent, 100u128).into()), BuyExecution { fees, weight_limit: Limited(30) }, DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); let weight_limit = 50; let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); assert_eq!(r, Outcome::Complete(30)); - assert_eq!(asset_list(Here), vec![(Parent, 70).into()]); + assert_eq!(asset_list(Here), vec![(Parent, 70u128).into()]); } #[test] @@ -122,14 +122,17 @@ fn transfer_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![TransferAsset { - assets: (Here, 100).into(), + assets: (Here, 100u128).into(), beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }]), 50, ); assert_eq!(r, Outcome::Complete(10)); - assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 100).into()]); - assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!( + asset_list(AccountIndex64 { index: 3, network: None }), + vec![(Here, 100u128).into()] + ); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(sent_xcm(), vec![]); } @@ -146,7 +149,7 @@ fn reserve_transfer_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![TransferReserveAsset { - assets: (Here, 100).into(), + assets: (Here, 100u128).into(), dest: Parachain(2).into(), xcm: Xcm::<()>(vec![DepositAsset { assets: AllCounted(1).into(), @@ -157,13 +160,13 @@ fn reserve_transfer_should_work() { ); assert_eq!(r, Outcome::Complete(10)); - assert_eq!(asset_list(Parachain(2)), vec![(Here, 100).into()]); + assert_eq!(asset_list(Parachain(2)), vec![(Here, 100u128).into()]); assert_eq!( sent_xcm(), vec![( Parachain(2).into(), Xcm::<()>(vec![ - ReserveAssetDeposited((Parent, 100).into()), + ReserveAssetDeposited((Parent, 100u128).into()), ClearOrigin, DepositAsset { assets: AllCounted(1).into(), beneficiary: three }, ]), @@ -181,22 +184,22 @@ fn burn_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - WithdrawAsset((Here, 1000).into()), - BurnAsset((Here, 100).into()), + WithdrawAsset((Here, 1000u128).into()), + BurnAsset((Here, 100u128).into()), DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, ]), 50, ); assert_eq!(r, Outcome::Complete(30)); - assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(sent_xcm(), vec![]); // Now they want to burn 1000 of them, which will actually only burn 900. let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - WithdrawAsset((Here, 900).into()), - BurnAsset((Here, 1000).into()), + WithdrawAsset((Here, 900u128).into()), + BurnAsset((Here, 1000u128).into()), DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, ]), 50, @@ -217,7 +220,7 @@ fn basic_asset_trap_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - WithdrawAsset((Here, 100).into()), + WithdrawAsset((Here, 100u128).into()), DepositAsset { assets: Wild(AllCounted(0)), // <<< 0 is an error. beneficiary: AccountIndex64 { index: 3, network: None }.into(), @@ -226,7 +229,7 @@ fn basic_asset_trap_should_work() { 20, ); assert_eq!(r, Outcome::Complete(25)); - assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); // Incorrect ticket doesn't work. @@ -234,7 +237,7 @@ fn basic_asset_trap_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(1).into() }, + ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(1).into() }, DepositAsset { assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: None }.into(), @@ -243,7 +246,7 @@ fn basic_asset_trap_should_work() { 20, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); - assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); @@ -252,7 +255,7 @@ fn basic_asset_trap_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(2), Xcm(vec![ - ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, + ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0u128).into() }, DepositAsset { assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: None }.into(), @@ -261,7 +264,7 @@ fn basic_asset_trap_should_work() { 20, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); - assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); @@ -270,7 +273,7 @@ fn basic_asset_trap_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - ClaimAsset { assets: (Here, 101).into(), ticket: GeneralIndex(0).into() }, + ClaimAsset { assets: (Here, 101u128).into(), ticket: GeneralIndex(0u128).into() }, DepositAsset { assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: None }.into(), @@ -279,14 +282,14 @@ fn basic_asset_trap_should_work() { 20, ); assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); - assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, + ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0u128).into() }, DepositAsset { assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: None }.into(), @@ -295,14 +298,17 @@ fn basic_asset_trap_should_work() { 20, ); assert_eq!(r, Outcome::Complete(20)); - assert_eq!(asset_list(Parachain(1)), vec![(Here, 900).into()]); - assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 100).into()]); + assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); + assert_eq!( + asset_list(AccountIndex64 { index: 3, network: None }), + vec![(Here, 100u128).into()] + ); // Same again doesn't work :-) let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - ClaimAsset { assets: (Here, 100).into(), ticket: GeneralIndex(0).into() }, + ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0u128).into() }, DepositAsset { assets: Wild(AllCounted(1)), beneficiary: AccountIndex64 { index: 3, network: None }.into(), @@ -318,28 +324,28 @@ fn max_assets_limit_should_work() { // we'll let them have message execution for free. AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); // Child parachain #1 owns 1000 tokens held by us in reserve. - add_asset(Parachain(1), ([1u8; 32], 1000)); - add_asset(Parachain(1), ([2u8; 32], 1000)); - add_asset(Parachain(1), ([3u8; 32], 1000)); - add_asset(Parachain(1), ([4u8; 32], 1000)); - add_asset(Parachain(1), ([5u8; 32], 1000)); - add_asset(Parachain(1), ([6u8; 32], 1000)); - add_asset(Parachain(1), ([7u8; 32], 1000)); - add_asset(Parachain(1), ([8u8; 32], 1000)); - add_asset(Parachain(1), ([9u8; 32], 1000)); + add_asset(Parachain(1), ([1u8; 32], 1000u128)); + add_asset(Parachain(1), ([2u8; 32], 1000u128)); + add_asset(Parachain(1), ([3u8; 32], 1000u128)); + add_asset(Parachain(1), ([4u8; 32], 1000u128)); + add_asset(Parachain(1), ([5u8; 32], 1000u128)); + add_asset(Parachain(1), ([6u8; 32], 1000u128)); + add_asset(Parachain(1), ([7u8; 32], 1000u128)); + add_asset(Parachain(1), ([8u8; 32], 1000u128)); + add_asset(Parachain(1), ([9u8; 32], 1000u128)); // Attempt to withdraw 8 (=2x4)different assets. This will succeed. let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - WithdrawAsset(([1u8; 32], 100).into()), - WithdrawAsset(([2u8; 32], 100).into()), - WithdrawAsset(([3u8; 32], 100).into()), - WithdrawAsset(([4u8; 32], 100).into()), - WithdrawAsset(([5u8; 32], 100).into()), - WithdrawAsset(([6u8; 32], 100).into()), - WithdrawAsset(([7u8; 32], 100).into()), - WithdrawAsset(([8u8; 32], 100).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([5u8; 32], 100u128).into()), + WithdrawAsset(([6u8; 32], 100u128).into()), + WithdrawAsset(([7u8; 32], 100u128).into()), + WithdrawAsset(([8u8; 32], 100u128).into()), ]), 100, ); @@ -349,15 +355,15 @@ fn max_assets_limit_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - WithdrawAsset(([1u8; 32], 100).into()), - WithdrawAsset(([2u8; 32], 100).into()), - WithdrawAsset(([3u8; 32], 100).into()), - WithdrawAsset(([4u8; 32], 100).into()), - WithdrawAsset(([5u8; 32], 100).into()), - WithdrawAsset(([6u8; 32], 100).into()), - WithdrawAsset(([7u8; 32], 100).into()), - WithdrawAsset(([8u8; 32], 100).into()), - WithdrawAsset(([9u8; 32], 100).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([5u8; 32], 100u128).into()), + WithdrawAsset(([6u8; 32], 100u128).into()), + WithdrawAsset(([7u8; 32], 100u128).into()), + WithdrawAsset(([8u8; 32], 100u128).into()), + WithdrawAsset(([9u8; 32], 100u128).into()), ]), 100, ); @@ -367,18 +373,18 @@ fn max_assets_limit_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - WithdrawAsset(([1u8; 32], 100).into()), - WithdrawAsset(([2u8; 32], 100).into()), - WithdrawAsset(([3u8; 32], 100).into()), - WithdrawAsset(([4u8; 32], 100).into()), - WithdrawAsset(([1u8; 32], 100).into()), - WithdrawAsset(([2u8; 32], 100).into()), - WithdrawAsset(([3u8; 32], 100).into()), - WithdrawAsset(([4u8; 32], 100).into()), - WithdrawAsset(([5u8; 32], 100).into()), - WithdrawAsset(([6u8; 32], 100).into()), - WithdrawAsset(([7u8; 32], 100).into()), - WithdrawAsset(([8u8; 32], 100).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([5u8; 32], 100u128).into()), + WithdrawAsset(([6u8; 32], 100u128).into()), + WithdrawAsset(([7u8; 32], 100u128).into()), + WithdrawAsset(([8u8; 32], 100u128).into()), ]), 200, ); @@ -388,18 +394,18 @@ fn max_assets_limit_should_work() { let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ - WithdrawAsset(([1u8; 32], 100).into()), - WithdrawAsset(([2u8; 32], 100).into()), - WithdrawAsset(([3u8; 32], 100).into()), - WithdrawAsset(([4u8; 32], 100).into()), - WithdrawAsset(([5u8; 32], 100).into()), - WithdrawAsset(([6u8; 32], 100).into()), - WithdrawAsset(([7u8; 32], 100).into()), - WithdrawAsset(([8u8; 32], 100).into()), - WithdrawAsset(([1u8; 32], 100).into()), - WithdrawAsset(([2u8; 32], 100).into()), - WithdrawAsset(([3u8; 32], 100).into()), - WithdrawAsset(([4u8; 32], 100).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([5u8; 32], 100u128).into()), + WithdrawAsset(([6u8; 32], 100u128).into()), + WithdrawAsset(([7u8; 32], 100u128).into()), + WithdrawAsset(([8u8; 32], 100u128).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), ]), 200, ); @@ -410,16 +416,16 @@ fn max_assets_limit_should_work() { Parachain(1), Xcm(vec![ WithdrawAsset(MultiAssets::from(vec![ - ([1u8; 32], 100).into(), - ([2u8; 32], 100).into(), - ([3u8; 32], 100).into(), - ([4u8; 32], 100).into(), - ([5u8; 32], 100).into(), - ([6u8; 32], 100).into(), - ([7u8; 32], 100).into(), - ([8u8; 32], 100).into(), + ([1u8; 32], 100u128).into(), + ([2u8; 32], 100u128).into(), + ([3u8; 32], 100u128).into(), + ([4u8; 32], 100u128).into(), + ([5u8; 32], 100u128).into(), + ([6u8; 32], 100u128).into(), + ([7u8; 32], 100u128).into(), + ([8u8; 32], 100u128).into(), ])), - WithdrawAsset(([1u8; 32], 100).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), ]), 200, ); diff --git a/xcm/xcm-builder/src/tests/basic.rs b/xcm/xcm-builder/src/tests/basic.rs index 1b611d5b6168..383385a9baad 100644 --- a/xcm/xcm-builder/src/tests/basic.rs +++ b/xcm/xcm-builder/src/tests/basic.rs @@ -19,10 +19,9 @@ use super::*; #[test] fn basic_setup_works() { add_reserve(Parent.into(), Wild((Parent, WildFungible).into())); - assert!(::IsReserve::filter_asset_location( - &(Parent, 100).into(), - &Parent.into(), - )); + assert!( + ::IsReserve::contains(&(Parent, 100u128).into(), &Parent.into(),) + ); assert_eq!(to_account(Parachain(1)), Ok(1001)); assert_eq!(to_account(Parachain(50)), Ok(1050)); @@ -42,8 +41,8 @@ fn basic_setup_works() { #[test] fn weigher_should_work() { let mut message = Xcm(vec![ - ReserveAssetDeposited((Parent, 100).into()), - BuyExecution { fees: (Parent, 1).into(), weight_limit: Limited(30) }, + ReserveAssetDeposited((Parent, 100u128).into()), + BuyExecution { fees: (Parent, 1u128).into(), weight_limit: Limited(30) }, DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); assert_eq!(::Weigher::weight(&mut message), Ok(30)); @@ -54,12 +53,12 @@ fn code_registers_should_work() { // we'll let them have message execution for free. AllowUnpaidFrom::set(vec![Here.into()]); // We own 1000 of our tokens. - add_asset(Here, (Here, 21)); + add_asset(Here, (Here, 21u128)); let mut message = Xcm(vec![ // Set our error handler - this will fire only on the second message, when there's an error SetErrorHandler(Xcm(vec![ TransferAsset { - assets: (Here, 2).into(), + assets: (Here, 2u128).into(), beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, // It was handled fine. @@ -67,17 +66,17 @@ fn code_registers_should_work() { ])), // Set the appendix - this will always fire. SetAppendix(Xcm(vec![TransferAsset { - assets: (Here, 4).into(), + assets: (Here, 4u128).into(), beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }])), // First xfer always works ok TransferAsset { - assets: (Here, 1).into(), + assets: (Here, 1u128).into(), beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, // Second xfer results in error on the second message - our error handler will fire. TransferAsset { - assets: (Here, 8).into(), + assets: (Here, 8u128).into(), beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, ]); @@ -87,13 +86,13 @@ fn code_registers_should_work() { let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); assert_eq!(r, Outcome::Complete(50)); // We don't pay the 20 weight for the error handler. - assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 13).into()]); - assert_eq!(asset_list(Here), vec![(Here, 8).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 13u128).into()]); + assert_eq!(asset_list(Here), vec![(Here, 8u128).into()]); assert_eq!(sent_xcm(), vec![]); let r = XcmExecutor::::execute_xcm(Here, message, limit); assert_eq!(r, Outcome::Complete(70)); // We pay the full weight here. - assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 20).into()]); - assert_eq!(asset_list(Here), vec![(Here, 1).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 20u128).into()]); + assert_eq!(asset_list(Here), vec![(Here, 1u128).into()]); assert_eq!(sent_xcm(), vec![]); } diff --git a/xcm/xcm-builder/src/tests/bridging/mod.rs b/xcm/xcm-builder/src/tests/bridging/mod.rs index 9bb5e13196c2..575cd7af7368 100644 --- a/xcm/xcm-builder/src/tests/bridging/mod.rs +++ b/xcm/xcm-builder/src/tests/bridging/mod.rs @@ -36,7 +36,7 @@ mod remote_relay_relay; parameter_types! { pub Local: NetworkId = ByGenesis([0; 32]); pub Remote: NetworkId = ByGenesis([1; 32]); - pub Price: MultiAssets = MultiAssets::from((Here, 100)); + pub Price: MultiAssets = MultiAssets::from((Here, 100u128)); } std::thread_local! { diff --git a/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs index 8336e03d1faa..f3b31582116c 100644 --- a/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs +++ b/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs @@ -28,7 +28,7 @@ parameter_types! { pub RelayUniversalLocation: Junctions = X1(GlobalConsensus(Local::get())); pub RemoteUniversalLocation: Junctions = X1(GlobalConsensus(Remote::get())); pub static BridgeTable: Vec<(NetworkId, MultiLocation, Option)> - = vec![(Remote::get(), MultiLocation::parent(), Some((Parent, 150).into()))]; + = vec![(Remote::get(), MultiLocation::parent(), Some((Parent, 150u128).into()))]; // ^^^ 100 to use the bridge (export) and 50 for the remote execution weight (5 instuctions // x 10 weight each). } @@ -63,10 +63,10 @@ fn sending_to_bridged_chain_works() { ); // Initialize the local relay so that our parachain has funds to pay for export. - add_asset(Parachain(100), (Here, 1000)); + add_asset(Parachain(100), (Here, 1000u128)); let msg = Xcm(vec![Trap(1)]); - assert_eq!(send_xcm::(dest, msg), Ok((Parent, 150).into())); + assert_eq!(send_xcm::(dest, msg), Ok((Parent, 150u128).into())); assert_eq!(TheBridge::service(), 1); assert_eq!( take_received_remote_messages(), @@ -81,7 +81,7 @@ fn sending_to_bridged_chain_works() { ); // The export cost 50 weight units (and thus 50 units of balance). - assert_eq!(asset_list(Parachain(100)), vec![(Here, 850).into()]); + assert_eq!(asset_list(Parachain(100)), vec![(Here, 850u128).into()]); } /// ```nocompile @@ -104,9 +104,9 @@ fn sending_to_parachain_of_bridged_chain_works() { ); // Initialize the local relay so that our parachain has funds to pay for export. - add_asset(Parachain(100), (Here, 1000)); + add_asset(Parachain(100), (Here, 1000u128)); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Parent, 150).into())); + assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Parent, 150u128).into())); assert_eq!(TheBridge::service(), 1); let expected = vec![( Parachain(100).into(), @@ -119,5 +119,5 @@ fn sending_to_parachain_of_bridged_chain_works() { assert_eq!(take_received_remote_messages(), expected); // The export cost 50 weight units (and thus 50 units of balance). - assert_eq!(asset_list(Parachain(100)), vec![(Here, 850).into()]); + assert_eq!(asset_list(Parachain(100)), vec![(Here, 850u128).into()]); } diff --git a/xcm/xcm-builder/src/tests/locking.rs b/xcm/xcm-builder/src/tests/locking.rs index 01cdb80f8ad5..d6afe08e4970 100644 --- a/xcm/xcm-builder/src/tests/locking.rs +++ b/xcm/xcm-builder/src/tests/locking.rs @@ -22,37 +22,40 @@ fn lock_roundtrip_should_work() { // Account #3 and Parachain #1 can execute for free AllowUnpaidFrom::set(vec![(3u64,).into(), (Parent, Parachain(1)).into()]); // Account #3 owns 1000 native parent tokens. - add_asset((3u64,), (Parent, 1000)); + add_asset((3u64,), (Parent, 1000u128)); // Sending a message costs 10 parent-tokens. - set_send_price((Parent, 10)); + set_send_price((Parent, 10u128)); // They want to lock 100 of the native parent tokens to be unlocked only by Parachain #1. let r = XcmExecutor::::execute_xcm( (3u64,), Xcm(vec![ - WithdrawAsset((Parent, 100).into()), + WithdrawAsset((Parent, 100u128).into()), SetAppendix( vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: (3u64,).into() }] .into(), ), - LockAsset { asset: (Parent, 100).into(), unlocker: (Parent, Parachain(1)).into() }, + LockAsset { asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into() }, ]), 50, ); assert_eq!(r, Outcome::Complete(40)); - assert_eq!(asset_list((3u64,)), vec![(Parent, 990).into()]); + assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); assert_eq!( sent_xcm(), vec![( (Parent, Parachain(1)).into(), - Xcm::<()>(vec![NoteUnlockable { owner: (3u64,).into(), asset: (Parent, 100).into() },]), + Xcm::<()>(vec![NoteUnlockable { + owner: (Parent, Parachain(42), 3u64).into(), + asset: (Parent, 100u128).into() + },]), )] ); assert_eq!( take_lock_trace(), vec![Lock { - asset: (Parent, 100).into(), + asset: (Parent, 100u128).into(), owner: (3u64,).into(), unlocker: (Parent, Parachain(1)).into(), }] @@ -61,7 +64,7 @@ fn lock_roundtrip_should_work() { // Now we'll unlock it. let r = XcmExecutor::::execute_xcm( (Parent, Parachain(1)), - Xcm(vec![UnlockAsset { asset: (Parent, 100).into(), target: (3u64,).into() }]), + Xcm(vec![UnlockAsset { asset: (Parent, 100u128).into(), target: (3u64,).into() }]), 50, ); assert_eq!(r, Outcome::Complete(10)); @@ -72,21 +75,21 @@ fn auto_fee_paying_should_work() { // Account #3 and Parachain #1 can execute for free AllowUnpaidFrom::set(vec![(3u64,).into()]); // Account #3 owns 1000 native parent tokens. - add_asset((3u64,), (Parent, 1000)); + add_asset((3u64,), (Parent, 1000u128)); // Sending a message costs 10 parent-tokens. - set_send_price((Parent, 10)); + set_send_price((Parent, 10u128)); // They want to lock 100 of the native parent tokens to be unlocked only by Parachain #1. let r = XcmExecutor::::execute_xcm( (3u64,), Xcm(vec![ SetFeesMode { jit_withdraw: true }, - LockAsset { asset: (Parent, 100).into(), unlocker: (Parent, Parachain(1)).into() }, + LockAsset { asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into() }, ]), 50, ); assert_eq!(r, Outcome::Complete(20)); - assert_eq!(asset_list((3u64,)), vec![(Parent, 990).into()]); + assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); } #[test] @@ -99,7 +102,7 @@ fn lock_should_fail_correctly() { let r = XcmExecutor::::execute_xcm( (3u64,), Xcm(vec![LockAsset { - asset: (Parent, 100).into(), + asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into(), }]), 50, @@ -109,16 +112,16 @@ fn lock_should_fail_correctly() { assert_eq!(take_lock_trace(), vec![]); // Account #3 owns 1000 native parent tokens. - add_asset((3u64,), (Parent, 1000)); + add_asset((3u64,), (Parent, 1000u128)); // But we require a price to be paid for the sending - set_send_price((Parent, 10)); + set_send_price((Parent, 10u128)); // #3 wants to lock 100 of the native parent tokens to be unlocked only by parachain ../#1, // but there's nothing to pay the fees for sending the notification message. let r = XcmExecutor::::execute_xcm( (3u64,), Xcm(vec![LockAsset { - asset: (Parent, 100).into(), + asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into(), }]), 50, @@ -133,21 +136,21 @@ fn remote_unlock_roundtrip_should_work() { // Account #3 can execute for free AllowUnpaidFrom::set(vec![(3u64,).into(), (Parent, Parachain(1)).into()]); // Account #3 owns 1000 native parent tokens. - add_asset((3u64,), (Parent, 1000)); + add_asset((3u64,), (Parent, 1000u128)); // Sending a message costs 10 parent-tokens. - set_send_price((Parent, 10)); + set_send_price((Parent, 10u128)); // We have been told by Parachain #1 that Account #3 has locked funds which we can unlock. let r = XcmExecutor::::execute_xcm( (Parent, Parachain(1)), - Xcm(vec![NoteUnlockable { asset: (Parent, 100).into(), owner: (3u64,).into() }]), + Xcm(vec![NoteUnlockable { asset: (Parent, 100u128).into(), owner: (3u64,).into() }]), 50, ); assert_eq!(r, Outcome::Complete(10)); assert_eq!( take_lock_trace(), vec![Note { - asset: (Parent, 100).into(), + asset: (Parent, 100u128).into(), owner: (3u64,).into(), locker: (Parent, Parachain(1)).into(), }] @@ -157,29 +160,35 @@ fn remote_unlock_roundtrip_should_work() { let r = XcmExecutor::::execute_xcm( (3u64,), Xcm(vec![ - WithdrawAsset((Parent, 100).into()), + WithdrawAsset((Parent, 100u128).into()), SetAppendix( vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: (3u64,).into() }] .into(), ), - RequestUnlock { asset: (Parent, 100).into(), locker: (Parent, Parachain(1)).into() }, + RequestUnlock { + asset: (Parent, 100u128).into(), + locker: (Parent, Parachain(1)).into(), + }, ]), 50, ); assert_eq!(r, Outcome::Complete(40)); - assert_eq!(asset_list((3u64,)), vec![(Parent, 990).into()]); + assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); assert_eq!( sent_xcm(), vec![( (Parent, Parachain(1)).into(), - Xcm::<()>(vec![UnlockAsset { target: (3u64,).into(), asset: (Parent, 100).into() },]), + Xcm::<()>(vec![UnlockAsset { + target: (3u64,).into(), + asset: (Parent, 100u128).into() + },]), )] ); assert_eq!( take_lock_trace(), vec![Reduce { - asset: (Parent, 100).into(), + asset: (Parent, 100u128).into(), owner: (3u64,).into(), locker: (Parent, Parachain(1)).into(), }] @@ -191,7 +200,7 @@ fn remote_unlock_should_fail_correctly() { // Account #3 can execute for free AllowUnpaidFrom::set(vec![(3u64,).into(), (Parent, Parachain(1)).into()]); // But we require a price to be paid for the sending - set_send_price((Parent, 10)); + set_send_price((Parent, 10u128)); // We want to unlock 100 of the native parent tokens which were locked for us on parachain. // This won't work as we don't have any record of them being locked for us. @@ -199,7 +208,7 @@ fn remote_unlock_should_fail_correctly() { let r = XcmExecutor::::execute_xcm( (3u64,), Xcm(vec![RequestUnlock { - asset: (Parent, 100).into(), + asset: (Parent, 100u128).into(), locker: (Parent, Parachain(1)).into(), }]), 50, @@ -211,7 +220,7 @@ fn remote_unlock_should_fail_correctly() { // We have been told by Parachain #1 that Account #3 has locked funds which we can unlock. let r = XcmExecutor::::execute_xcm( (Parent, Parachain(1)), - Xcm(vec![NoteUnlockable { asset: (Parent, 100).into(), owner: (3u64,).into() }]), + Xcm(vec![NoteUnlockable { asset: (Parent, 100u128).into(), owner: (3u64,).into() }]), 50, ); assert_eq!(r, Outcome::Complete(10)); @@ -223,7 +232,7 @@ fn remote_unlock_should_fail_correctly() { let r = XcmExecutor::::execute_xcm( (3u64,), Xcm(vec![RequestUnlock { - asset: (Parent, 100).into(), + asset: (Parent, 100u128).into(), locker: (Parent, Parachain(1)).into(), }]), 50, diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index bcaad110dd33..3972170ab15c 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -19,6 +19,7 @@ pub use crate::{ AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, LocationInverter, TakeWeightCredit, }; +use frame_support::traits::ContainsPair; pub use frame_support::{ dispatch::{ DispatchError, DispatchInfo, DispatchResultWithPostInfo, Dispatchable, Parameter, Weight, @@ -39,7 +40,7 @@ pub use xcm::latest::prelude::*; pub use xcm_executor::{ traits::{ AssetExchange, AssetLock, ConvertOrigin, Enact, ExportXcm, FeeManager, FeeReason, - FilterAssetLocation, LockError, OnResponse, TransactAsset, UniversalLocation, + LockError, OnResponse, TransactAsset, UniversalLocation, }, Assets, Config, }; @@ -283,15 +284,15 @@ pub fn clear_universal_aliases() { } pub struct TestIsReserve; -impl FilterAssetLocation for TestIsReserve { - fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { +impl ContainsPair for TestIsReserve { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { IS_RESERVE .with(|r| r.borrow().get(origin).map_or(false, |v| v.iter().any(|a| a.matches(asset)))) } } pub struct TestIsTeleporter; -impl FilterAssetLocation for TestIsTeleporter { - fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { +impl ContainsPair for TestIsTeleporter { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { IS_TELEPORTER .with(|r| r.borrow().get(origin).map_or(false, |v| v.iter().any(|a| a.matches(asset)))) } diff --git a/xcm/xcm-builder/src/tests/mod.rs b/xcm/xcm-builder/src/tests/mod.rs index da17f2d36e83..d49b207f73b1 100644 --- a/xcm/xcm-builder/src/tests/mod.rs +++ b/xcm/xcm-builder/src/tests/mod.rs @@ -16,8 +16,12 @@ use super::{test_utils::*, *}; use core::convert::TryInto; -use frame_support::{assert_err, traits::ConstU32, weights::constants::WEIGHT_PER_SECOND}; -use xcm_executor::{traits::*, Config, XcmExecutor}; +use frame_support::{ + assert_err, + traits::{ConstU32, ContainsPair}, + weights::constants::WEIGHT_PER_SECOND, +}; +use xcm_executor::{traits::prelude::*, Config, XcmExecutor}; mod mock; use mock::*; diff --git a/xcm/xcm-builder/src/tests/origins.rs b/xcm/xcm-builder/src/tests/origins.rs index 5dee287a559b..93569d9d0fb1 100644 --- a/xcm/xcm-builder/src/tests/origins.rs +++ b/xcm/xcm-builder/src/tests/origins.rs @@ -29,7 +29,7 @@ fn universal_origin_should_work() { Parachain(2), Xcm(vec![ UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, ]), 50, ); @@ -39,18 +39,18 @@ fn universal_origin_should_work() { Parachain(1), Xcm(vec![ UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, ]), 50, ); assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); - add_asset((Ancestor(2), GlobalConsensus(Kusama)), (Parent, 100)); + add_asset((Ancestor(2), GlobalConsensus(Kusama)), (Parent, 100u128)); let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, ]), 50, ); @@ -64,8 +64,10 @@ fn export_message_should_work() { AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); // Local parachain #1 issues a transfer asset on Polkadot Relay-chain, transfering 100 Planck to // Polkadot parachain #2. - let message = - Xcm(vec![TransferAsset { assets: (Here, 100).into(), beneficiary: Parachain(2).into() }]); + let message = Xcm(vec![TransferAsset { + assets: (Here, 100u128).into(), + beneficiary: Parachain(2).into(), + }]); let r = XcmExecutor::::execute_xcm( Parachain(1), Xcm(vec![ExportMessage { network: Polkadot, destination: Here, xcm: message.clone() }]), diff --git a/xcm/xcm-builder/src/tests/querying.rs b/xcm/xcm-builder/src/tests/querying.rs index 1b6e90e230d4..feb3259208ed 100644 --- a/xcm/xcm-builder/src/tests/querying.rs +++ b/xcm/xcm-builder/src/tests/querying.rs @@ -100,7 +100,7 @@ fn prepaid_result_of_query_should_get_free_execution() { // We put this in manually here, but normally this would be done at the point of crafting the message. expect_response(query_id, Parent.into()); - let the_response = Response::Assets((Parent, 100).into()); + let the_response = Response::Assets((Parent, 100u128).into()); let message = Xcm::(vec![QueryResponse { query_id, response: the_response.clone(), diff --git a/xcm/xcm-builder/src/tests/transacting.rs b/xcm/xcm-builder/src/tests/transacting.rs index 643a1054d8cb..009ba5ad96d1 100644 --- a/xcm/xcm-builder/src/tests/transacting.rs +++ b/xcm/xcm-builder/src/tests/transacting.rs @@ -62,13 +62,13 @@ fn transacting_should_refund_weight() { fn paid_transacting_should_refund_payment_for_unused_weight() { let one: MultiLocation = AccountIndex64 { index: 1, network: None }.into(); AllowPaidFrom::set(vec![one.clone()]); - add_asset(AccountIndex64 { index: 1, network: None }, (Parent, 100)); + add_asset(AccountIndex64 { index: 1, network: None }, (Parent, 100u128)); WeightPrice::set((Parent.into(), 1_000_000_000_000)); let origin = one.clone(); - let fees = (Parent, 100).into(); + let fees = (Parent, 100u128).into(); let message = Xcm::(vec![ - WithdrawAsset((Parent, 100).into()), // enough for 100 units of weight. + WithdrawAsset((Parent, 100u128).into()), // enough for 100 units of weight. BuyExecution { fees, weight_limit: Limited(100) }, Transact { origin_kind: OriginKind::Native, @@ -82,7 +82,10 @@ fn paid_transacting_should_refund_payment_for_unused_weight() { let weight_limit = 100; let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); assert_eq!(r, Outcome::Complete(60)); - assert_eq!(asset_list(AccountIndex64 { index: 1, network: None }), vec![(Parent, 40).into()]); + assert_eq!( + asset_list(AccountIndex64 { index: 1, network: None }), + vec![(Parent, 40u128).into()] + ); } #[test] diff --git a/xcm/xcm-builder/src/tests/weight.rs b/xcm/xcm-builder/src/tests/weight.rs index 6c2a5cf112f8..f0a3aaf57a1b 100644 --- a/xcm/xcm-builder/src/tests/weight.rs +++ b/xcm/xcm-builder/src/tests/weight.rs @@ -21,21 +21,21 @@ fn errors_should_return_unused_weight() { // we'll let them have message execution for free. AllowUnpaidFrom::set(vec![Here.into()]); // We own 1000 of our tokens. - add_asset(Here, (Here, 11)); + add_asset(Here, (Here, 11u128)); let mut message = Xcm(vec![ // First xfer results in an error on the last message only TransferAsset { - assets: (Here, 1).into(), + assets: (Here, 1u128).into(), beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, // Second xfer results in error third message and after TransferAsset { - assets: (Here, 2).into(), + assets: (Here, 2u128).into(), beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, // Third xfer results in error second message and after TransferAsset { - assets: (Here, 4).into(), + assets: (Here, 4u128).into(), beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }, ]); @@ -45,25 +45,25 @@ fn errors_should_return_unused_weight() { let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); assert_eq!(r, Outcome::Complete(30)); - assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 7).into()]); - assert_eq!(asset_list(Here), vec![(Here, 4).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 7u128).into()]); + assert_eq!(asset_list(Here), vec![(Here, 4u128).into()]); assert_eq!(sent_xcm(), vec![]); let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); assert_eq!(r, Outcome::Incomplete(30, XcmError::NotWithdrawable)); - assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 10).into()]); - assert_eq!(asset_list(Here), vec![(Here, 1).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 10u128).into()]); + assert_eq!(asset_list(Here), vec![(Here, 1u128).into()]); assert_eq!(sent_xcm(), vec![]); let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); - assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11u128).into()]); assert_eq!(asset_list(Here), vec![]); assert_eq!(sent_xcm(), vec![]); let r = XcmExecutor::::execute_xcm(Here, message, limit); assert_eq!(r, Outcome::Incomplete(10, XcmError::NotWithdrawable)); - assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11).into()]); + assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11u128).into()]); assert_eq!(asset_list(Here), vec![]); assert_eq!(sent_xcm(), vec![]); } diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 67b8ca3d72ab..23cc7e885764 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -16,15 +16,15 @@ use crate::traits::{ AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, - FilterAssetLocation, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, - VersionChangeNotifier, WeightBounds, WeightTrader, + OnResponse, ShouldExecute, TransactAsset, UniversalLocation, VersionChangeNotifier, + WeightBounds, WeightTrader, }; use frame_support::{ dispatch::{Dispatchable, Parameter}, - traits::{Contains, Get, PalletsInfoAccess}, + traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, weights::{GetDispatchInfo, PostDispatchInfo}, }; -use xcm::latest::{Junction, MultiLocation, SendXcm}; +use xcm::prelude::*; /// The trait to parameterize the `XcmExecutor`. pub trait Config { @@ -40,11 +40,11 @@ pub trait Config { /// How to get a call origin from a `OriginKind` value. type OriginConverter: ConvertOrigin<::Origin>; - /// Combinations of (Location, Asset) pairs which we trust as reserves. - type IsReserve: FilterAssetLocation; + /// Combinations of (Asset, Location) pairs which we trust as reserves. + type IsReserve: ContainsPair; - /// Combinations of (Location, Asset) pairs which we trust as teleporters. - type IsTeleporter: FilterAssetLocation; + /// Combinations of (Asset, Location) pairs which we trust as teleporters. + type IsTeleporter: ContainsPair; /// Means of inverting a location. type LocationInverter: UniversalLocation; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index fcd7f85b18ea..ec7f583128e9 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -19,7 +19,7 @@ use frame_support::{ dispatch::{Dispatchable, Weight}, ensure, - traits::{Contains, Get, PalletsInfoAccess}, + traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, weights::GetDispatchInfo, }; use parity_scale_codec::{Decode, Encode}; @@ -31,8 +31,8 @@ use xcm::latest::prelude::*; pub mod traits; use traits::{ validate_export, AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, Enact, - ExportXcm, FeeManager, FeeReason, FilterAssetLocation, OnResponse, ShouldExecute, - TransactAsset, UniversalLocation, VersionChangeNotifier, WeightBounds, WeightTrader, + ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, + VersionChangeNotifier, WeightBounds, WeightTrader, }; mod assets; @@ -192,7 +192,7 @@ impl ExecuteXcm for XcmExecutor { xcm_weight, &mut weight_credit, ) { - log::debug!( + log::trace!( target: "xcm::execute_xcm_in_credit", "Barrier blocked execution! Error: {:?}. (origin: {:?}, message: {:?}, weight_credit: {:?})", e, @@ -291,6 +291,7 @@ impl XcmExecutor { match &mut result { r @ Ok(()) => if let Err(e) = self.process_instruction(instr) { + log::trace!(target: "xcm::execute", "!!! ERROR: {:?}", e); *r = Err(ExecutorError { index: i as u32, xcm_error: e, weight: 0 }); }, Err(ref mut error) => @@ -323,7 +324,7 @@ impl XcmExecutor { // TODO: #2841 #REALWEIGHT We should deduct the cost of any instructions following // the error which didn't end up being executed. Some((_i, e)) => { - log::debug!(target: "xcm::execute_xcm_in_credit", "Execution errored at {:?}: {:?} (original_origin: {:?})", _i, e, self.original_origin); + log::trace!(target: "xcm::execute_xcm_in_credit", "Execution errored at {:?}: {:?} (original_origin: {:?})", _i, e, self.original_origin); Outcome::Incomplete(weight_used, e) }, } @@ -400,6 +401,11 @@ impl XcmExecutor { /// Process a single XCM instruction, mutating the state of the XCM virtual machine. fn process_instruction(&mut self, instr: Instruction) -> Result<(), XcmError> { + log::trace!( + target: "xcm::process_instruction", + "=== {:?}", + instr + ); match instr { WithdrawAsset(assets) => { // Take `assets` from the origin account (on-chain) and place in holding. @@ -416,7 +422,7 @@ impl XcmExecutor { for asset in assets.into_inner().into_iter() { // Must ensure that we recognise the asset as being managed by the origin. ensure!( - Config::IsReserve::filter_asset_location(&asset, &origin), + Config::IsReserve::contains(&asset, &origin), XcmError::UntrustedReserveLocation ); self.subsume_asset(asset)?; @@ -451,7 +457,7 @@ impl XcmExecutor { // We only trust the origin to send us assets that they identify as their // sovereign assets. ensure!( - Config::IsTeleporter::filter_asset_location(asset, &origin), + Config::IsTeleporter::contains(asset, &origin), XcmError::UntrustedTeleportLocation ); // We should check that the asset can actually be teleported in (for this to be in error, there @@ -731,11 +737,12 @@ impl XcmExecutor { }, LockAsset { asset, unlocker } => { let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); - let remote_asset = Self::try_reanchor(asset.clone(), &unlocker)?; + let (remote_asset, context) = Self::try_reanchor(asset.clone(), &unlocker)?; let lock_ticket = Config::AssetLocker::prepare_lock(unlocker.clone(), asset, origin.clone())?; - let msg = - Xcm::<()>(vec![NoteUnlockable { asset: remote_asset, owner: origin.clone() }]); + let owner = + origin.reanchored(&unlocker, &context).map_err(|_| XcmError::ReanchorFailed)?; + let msg = Xcm::<()>(vec![NoteUnlockable { asset: remote_asset, owner }]); let (ticket, price) = validate_send::(unlocker, msg)?; self.take_fee(price, FeeReason::LockAsset)?; lock_ticket.enact()?; @@ -754,7 +761,7 @@ impl XcmExecutor { }, RequestUnlock { asset, locker } => { let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); - let remote_asset = Self::try_reanchor(asset.clone(), &locker)?; + let remote_asset = Self::try_reanchor(asset.clone(), &locker)?.0; let reduce_ticket = Config::AssetLocker::prepare_reduce_unlockable( locker.clone(), asset, @@ -850,9 +857,12 @@ impl XcmExecutor { fn try_reanchor( asset: MultiAsset, destination: &MultiLocation, - ) -> Result { + ) -> Result<(MultiAsset, MultiLocation), XcmError> { let context = Config::LocationInverter::universal_location().into(); - asset.reanchored(&destination, &context).map_err(|()| XcmError::ReanchorFailed) + let asset = asset + .reanchored(&destination, &context) + .map_err(|()| XcmError::ReanchorFailed)?; + Ok((asset, context)) } /// NOTE: Any assets which were unable to be reanchored are introduced into `failed_bin`. diff --git a/xcm/xcm-executor/src/traits/filter_asset_location.rs b/xcm/xcm-executor/src/traits/filter_asset_location.rs index 31b9c47a828c..ec9fecbab640 100644 --- a/xcm/xcm-executor/src/traits/filter_asset_location.rs +++ b/xcm/xcm-executor/src/traits/filter_asset_location.rs @@ -14,28 +14,21 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use frame_support::traits::ContainsPair; use xcm::latest::{MultiAsset, MultiLocation}; /// Filters assets/location pairs. /// /// Can be amalgamated into tuples. If any item returns `true`, it short-circuits, else `false` is returned. +#[deprecated = "Use `frame_support::traits::ContainsPair` instead"] pub trait FilterAssetLocation { /// A filter to distinguish between asset/location pairs. - fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool; + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool; } -#[impl_trait_for_tuples::impl_for_tuples(30)] -impl FilterAssetLocation for Tuple { - fn filter_asset_location(what: &MultiAsset, origin: &MultiLocation) -> bool { - for_tuples!( #( - if Tuple::filter_asset_location(what, origin) { return true } - )* ); - log::trace!( - target: "xcm::filter_asset_location", - "got filtered: what: {:?}, origin: {:?}", - what, - origin, - ); - false +#[allow(deprecated)] +impl> FilterAssetLocation for T { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { + T::contains(asset, origin) } } diff --git a/xcm/xcm-executor/src/traits/matches_fungible.rs b/xcm/xcm-executor/src/traits/matches_fungible.rs deleted file mode 100644 index 4989f263a63d..000000000000 --- a/xcm/xcm-executor/src/traits/matches_fungible.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2020 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 . - -use xcm::latest::MultiAsset; - -pub trait MatchesFungible { - fn matches_fungible(a: &MultiAsset) -> Option; -} - -#[impl_trait_for_tuples::impl_for_tuples(30)] -impl MatchesFungible for Tuple { - fn matches_fungible(a: &MultiAsset) -> Option { - for_tuples!( #( - match Tuple::matches_fungible(a) { o @ Some(_) => return o, _ => () } - )* ); - log::trace!(target: "xcm::matches_fungible", "did not match fungible asset: {:?}", &a); - None - } -} diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index 293077d52201..4ad216effde6 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -31,11 +31,12 @@ pub use export::{export_xcm, validate_export, ExportXcm}; mod fee_manager; pub use fee_manager::{FeeManager, FeeReason}; mod filter_asset_location; +#[allow(deprecated)] pub use filter_asset_location::FilterAssetLocation; -mod matches_fungible; -pub use matches_fungible::MatchesFungible; -mod matches_fungibles; -pub use matches_fungibles::{Error, MatchesFungibles}; +mod token_matching; +pub use token_matching::{ + Error, MatchesFungible, MatchesFungibles, MatchesNonFungible, MatchesNonFungibles, +}; mod on_response; pub use on_response::{OnResponse, VersionChangeNotifier}; mod should_execute; @@ -44,3 +45,13 @@ mod transact_asset; pub use transact_asset::TransactAsset; mod weight; pub use weight::{WeightBounds, WeightTrader}; + +pub mod prelude { + pub use super::{ + export_xcm, validate_export, AssetExchange, AssetLock, ClaimAssets, Convert, ConvertOrigin, + Decoded, DropAssets, Enact, Encoded, Error, ExportXcm, FeeManager, FeeReason, Identity, + JustTry, LockError, MatchesFungible, MatchesFungibles, MatchesNonFungible, + MatchesNonFungibles, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, + VersionChangeNotifier, WeightBounds, WeightTrader, + }; +} diff --git a/xcm/xcm-executor/src/traits/matches_fungibles.rs b/xcm/xcm-executor/src/traits/token_matching.rs similarity index 51% rename from xcm/xcm-executor/src/traits/matches_fungibles.rs rename to xcm/xcm-executor/src/traits/token_matching.rs index f5baafdcd97a..befff6b1b726 100644 --- a/xcm/xcm-executor/src/traits/matches_fungibles.rs +++ b/xcm/xcm-executor/src/traits/token_matching.rs @@ -15,7 +15,37 @@ // along with Polkadot. If not, see . use sp_std::result; -use xcm::latest::{Error as XcmError, MultiAsset}; +use xcm::latest::prelude::*; + +pub trait MatchesFungible { + fn matches_fungible(a: &MultiAsset) -> Option; +} + +#[impl_trait_for_tuples::impl_for_tuples(30)] +impl MatchesFungible for Tuple { + fn matches_fungible(a: &MultiAsset) -> Option { + for_tuples!( #( + match Tuple::matches_fungible(a) { o @ Some(_) => return o, _ => () } + )* ); + log::trace!(target: "xcm::matches_fungible", "did not match fungible asset: {:?}", &a); + None + } +} + +pub trait MatchesNonFungible { + fn matches_nonfungible(a: &MultiAsset) -> Option; +} + +#[impl_trait_for_tuples::impl_for_tuples(30)] +impl MatchesNonFungible for Tuple { + fn matches_nonfungible(a: &MultiAsset) -> Option { + for_tuples!( #( + match Tuple::matches_nonfungible(a) { o @ Some(_) => return o, _ => () } + )* ); + log::trace!(target: "xcm::matches_non_fungible", "did not match non-fungible asset: {:?}", &a); + None + } +} /// Errors associated with [`MatchesFungibles`] operation. pub enum Error { @@ -25,8 +55,10 @@ pub enum Error { AccountIdConversionFailed, /// `u128` amount to currency `Balance` conversion failed. AmountToBalanceConversionFailed, - /// `MultiLocation` to `AssetId` conversion failed. + /// `MultiLocation` to `AssetId`/`ClassId` conversion failed. AssetIdConversionFailed, + /// `AssetInstance` to non-fungibles instance ID conversion failed. + InstanceConversionFailed, } impl From for XcmError { @@ -38,6 +70,7 @@ impl From for XcmError { Error::AmountToBalanceConversionFailed => FailedToTransactAsset("AmountToBalanceConversionFailed"), Error::AssetIdConversionFailed => FailedToTransactAsset("AssetIdConversionFailed"), + Error::InstanceConversionFailed => FailedToTransactAsset("InstanceConversionFailed"), } } } @@ -47,7 +80,7 @@ pub trait MatchesFungibles { } #[impl_trait_for_tuples::impl_for_tuples(30)] -impl MatchesFungibles for Tuple { +impl MatchesFungibles for Tuple { fn matches_fungibles(a: &MultiAsset) -> result::Result<(AssetId, Balance), Error> { for_tuples!( #( match Tuple::matches_fungibles(a) { o @ Ok(_) => return o, _ => () } @@ -56,3 +89,18 @@ impl MatchesFungibles for Tupl Err(Error::AssetNotFound) } } + +pub trait MatchesNonFungibles { + fn matches_nonfungibles(a: &MultiAsset) -> result::Result<(AssetId, Instance), Error>; +} + +#[impl_trait_for_tuples::impl_for_tuples(30)] +impl MatchesNonFungibles for Tuple { + fn matches_nonfungibles(a: &MultiAsset) -> result::Result<(AssetId, Instance), Error> { + for_tuples!( #( + match Tuple::matches_nonfungibles(a) { o @ Ok(_) => return o, _ => () } + )* ); + log::trace!(target: "xcm::matches_non_fungibles", "did not match fungibles asset: {:?}", &a); + Err(Error::AssetNotFound) + } +} diff --git a/xcm/xcm-executor/src/traits/transact_asset.rs b/xcm/xcm-executor/src/traits/transact_asset.rs index 78e2180ed7a4..7a933275a45a 100644 --- a/xcm/xcm-executor/src/traits/transact_asset.rs +++ b/xcm/xcm-executor/src/traits/transact_asset.rs @@ -95,7 +95,7 @@ pub trait TransactAsset { to: &MultiLocation, ) -> Result { match Self::transfer_asset(asset, from, to) { - Err(XcmError::Unimplemented) => { + Err(XcmError::AssetNotFound | XcmError::Unimplemented) => { let assets = Self::withdraw_asset(asset, from)?; // Not a very forgiving attitude; once we implement roll-backs then it'll be nicer. Self::deposit_asset(asset, to)?; @@ -273,7 +273,7 @@ mod tests { (UnimplementedTransactor, NotFoundTransactor, UnimplementedTransactor); assert_eq!( - MultiTransactor::deposit_asset(&(Here, 1).into(), &Here.into()), + MultiTransactor::deposit_asset(&(Here, 1u128).into(), &Here.into()), Err(XcmError::AssetNotFound) ); } @@ -282,7 +282,7 @@ mod tests { fn unimplemented_and_not_found_continue_iteration() { type MultiTransactor = (UnimplementedTransactor, NotFoundTransactor, SuccessfulTransactor); - assert_eq!(MultiTransactor::deposit_asset(&(Here, 1).into(), &Here.into()), Ok(()),); + assert_eq!(MultiTransactor::deposit_asset(&(Here, 1u128).into(), &Here.into()), Ok(()),); } #[test] @@ -290,7 +290,7 @@ mod tests { type MultiTransactor = (OverflowTransactor, SuccessfulTransactor); assert_eq!( - MultiTransactor::deposit_asset(&(Here, 1).into(), &Here.into()), + MultiTransactor::deposit_asset(&(Here, 1u128).into(), &Here.into()), Err(XcmError::Overflow) ); } @@ -299,6 +299,6 @@ mod tests { fn success_stops_iteration() { type MultiTransactor = (SuccessfulTransactor, OverflowTransactor); - assert_eq!(MultiTransactor::deposit_asset(&(Here, 1).into(), &Here.into()), Ok(()),); + assert_eq!(MultiTransactor::deposit_asset(&(Here, 1u128).into(), &Here.into()), Ok(()),); } } diff --git a/xcm/xcm-simulator/example/Cargo.toml b/xcm/xcm-simulator/example/Cargo.toml index 1ec8601ea2c7..6c0263996467 100644 --- a/xcm/xcm-simulator/example/Cargo.toml +++ b/xcm/xcm-simulator/example/Cargo.toml @@ -8,14 +8,17 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0" } scale-info = { version = "2.0.0", features = ["derive"] } +log = { version = "0.4.14", default-features = false } frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-uniques = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } xcm = { path = "../../" } xcm-simulator = { path = "../" } @@ -25,3 +28,18 @@ pallet-xcm = { path = "../../pallet-xcm" } polkadot-core-primitives = { path = "../../../core-primitives" } polkadot-runtime-parachains = { path = "../../../runtime/parachains" } polkadot-parachain = { path = "../../../parachain" } + +[features] +default = [] +runtime-benchmarks = [ + "frame-system/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-uniques/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", + "xcm/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", + "polkadot-parachain/runtime-benchmarks", +] diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index 9e705145dd17..d9c08a5f369f 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -17,8 +17,9 @@ mod parachain; mod relay_chain; -use polkadot_parachain::primitives::Id as ParaId; -use sp_runtime::traits::AccountIdConversion; +use frame_support::sp_tracing; +use xcm::prelude::*; +use xcm_executor::traits::Convert; use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain}; pub const ALICE: sp_runtime::AccountId32 = sp_runtime::AccountId32::new([0u8; 32]); @@ -60,8 +61,29 @@ decl_test_network! { } } -pub fn para_account_id(id: u32) -> relay_chain::AccountId { - ParaId::from(id).into_account() +pub fn parent_account_id() -> parachain::AccountId { + let location = (Parent,); + parachain::LocationToAccountId::convert(location.into()).unwrap() +} + +pub fn child_account_id(para: u32) -> relay_chain::AccountId { + let location = (Parachain(para),); + relay_chain::LocationToAccountId::convert(location.into()).unwrap() +} + +pub fn child_account_account_id(para: u32, who: sp_runtime::AccountId32) -> relay_chain::AccountId { + let location = (Parachain(para), AccountId32 { network: None, id: who.into() }); + relay_chain::LocationToAccountId::convert(location.into()).unwrap() +} + +pub fn sibling_account_account_id(para: u32, who: sp_runtime::AccountId32) -> parachain::AccountId { + let location = (Parent, Parachain(para), AccountId32 { network: None, id: who.into() }); + parachain::LocationToAccountId::convert(location.into()).unwrap() +} + +pub fn parent_account_account_id(who: sp_runtime::AccountId32) -> parachain::AccountId { + let location = (Parent, AccountId32 { network: None, id: who.into() }); + parachain::LocationToAccountId::convert(location.into()).unwrap() } pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { @@ -69,12 +91,15 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(ALICE, INITIAL_BALANCE)] } - .assimilate_storage(&mut t) - .unwrap(); + pallet_balances::GenesisConfig:: { + balances: vec![(ALICE, INITIAL_BALANCE), (parent_account_id(), INITIAL_BALANCE)], + } + .assimilate_storage(&mut t) + .unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| { + sp_tracing::try_init_simple(); System::set_block_number(1); MsgQueue::set_para_id(para_id.into()); }); @@ -82,22 +107,26 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { } pub fn relay_ext() -> sp_io::TestExternalities { - use relay_chain::{Runtime, System}; + use relay_chain::{Origin, Runtime, System, Uniques}; let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![ (ALICE, INITIAL_BALANCE), - (para_account_id(1), INITIAL_BALANCE), - (para_account_id(2), INITIAL_BALANCE), + (child_account_id(1), INITIAL_BALANCE), + (child_account_id(2), INITIAL_BALANCE), ], } .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); - ext.execute_with(|| System::set_block_number(1)); + ext.execute_with(|| { + System::set_block_number(1); + assert_eq!(Uniques::force_create(Origin::root(), 1, ALICE, true), Ok(())); + assert_eq!(Uniques::mint(Origin::signed(ALICE), 1, 42, child_account_id(1)), Ok(())); + }); ext } @@ -110,7 +139,7 @@ mod tests { use codec::Encode; use frame_support::assert_ok; - use xcm::latest::{prelude::*, QueryResponseInfo}; + use xcm::latest::QueryResponseInfo; use xcm_simulator::TestExt; // Helper function for forming buy execution message @@ -118,6 +147,13 @@ mod tests { BuyExecution { fees: fees.into(), weight_limit: Unlimited } } + #[test] + fn remote_account_ids_work() { + child_account_account_id(1, ALICE); + sibling_account_account_id(1, ALICE); + parent_account_account_id(ALICE); + } + #[test] fn dmp() { MockNet::reset(); @@ -216,7 +252,7 @@ mod tests { 0, )); assert_eq!( - parachain::Balances::free_balance(¶_account_id(1)), + parachain::Balances::free_balance(&child_account_id(1)), INITIAL_BALANCE + withdraw_amount ); }); @@ -237,18 +273,17 @@ mod tests { let locked_amount = 100; ParaB::execute_with(|| { - let message = Xcm(vec![ - WithdrawAsset((Here, locked_amount).into()), - buy_execution((Here, locked_amount)), - LockAsset { asset: (Here, locked_amount).into(), unlocker: Parachain(1).into() }, - ]); + let message = Xcm(vec![LockAsset { + asset: (Here, locked_amount).into(), + unlocker: (Parachain(1),).into(), + }]); assert_ok!(ParachainPalletXcm::send_xcm(Here, Parent, message.clone())); }); Relay::execute_with(|| { use pallet_balances::{BalanceLock, Reasons}; assert_eq!( - relay_chain::Balances::locks(¶_account_id(2)), + relay_chain::Balances::locks(&child_account_id(2)), vec![BalanceLock { id: *b"py/xcmlk", amount: locked_amount, @@ -268,6 +303,232 @@ mod tests { }); } + /// Scenario: + /// A parachain transfers an NFT resident on the relay chain to another parachain account. + /// + /// Asserts that the parachain accounts are updated as expected. + #[test] + fn withdraw_and_deposit_nft() { + MockNet::reset(); + + Relay::execute_with(|| { + assert_eq!(relay_chain::Uniques::owner(1, 42), Some(child_account_id(1))); + }); + + ParaA::execute_with(|| { + let message = Xcm(vec![TransferAsset { + assets: (GeneralIndex(1), 42u32).into(), + beneficiary: Parachain(2).into(), + }]); + // Send withdraw and deposit + assert_ok!(ParachainPalletXcm::send_xcm(Here, Parent, message)); + }); + + Relay::execute_with(|| { + assert_eq!(relay_chain::Uniques::owner(1, 42), Some(child_account_id(2))); + }); + } + + /// Scenario: + /// The relay-chain teleports an NFT to a parachain. + /// + /// Asserts that the parachain accounts are updated as expected. + #[test] + fn teleport_nft() { + MockNet::reset(); + + Relay::execute_with(|| { + // Mint the NFT (1, 69) and give it to our "parachain#1 alias". + assert_ok!(relay_chain::Uniques::mint( + relay_chain::Origin::signed(ALICE), + 1, + 69, + child_account_account_id(1, ALICE), + )); + // The parachain#1 alias of Alice is what must hold it on the Relay-chain for it to be + // withdrawable by Alice on the parachain. + assert_eq!( + relay_chain::Uniques::owner(1, 69), + Some(child_account_account_id(1, ALICE)) + ); + }); + ParaA::execute_with(|| { + assert_ok!(parachain::ForeignUniques::force_create( + parachain::Origin::root(), + (Parent, GeneralIndex(1)).into(), + ALICE, + false, + )); + assert_eq!( + parachain::ForeignUniques::owner((Parent, GeneralIndex(1)).into(), 69u32.into()), + None, + ); + assert_eq!(parachain::Balances::reserved_balance(&ALICE), 0); + + // IRL Alice would probably just execute this locally on the Relay-chain, but we can't + // easily do that here since we only send between chains. + let message = Xcm(vec![ + WithdrawAsset((GeneralIndex(1), 69u32).into()), + InitiateTeleport { + assets: AllCounted(1).into(), + dest: Parachain(1).into(), + xcm: Xcm(vec![DepositAsset { + assets: AllCounted(1).into(), + beneficiary: (AccountId32 { id: ALICE.into(), network: None },).into(), + }]), + }, + ]); + // Send teleport + let alice = AccountId32 { id: ALICE.into(), network: None }; + assert_ok!(ParachainPalletXcm::send_xcm(alice, Parent, message)); + }); + ParaA::execute_with(|| { + assert_eq!( + parachain::ForeignUniques::owner((Parent, GeneralIndex(1)).into(), 69u32.into()), + Some(ALICE), + ); + assert_eq!(parachain::Balances::reserved_balance(&ALICE), 1000); + }); + Relay::execute_with(|| { + assert_eq!(relay_chain::Uniques::owner(1, 69), None); + }); + } + + /// Scenario: + /// The relay-chain transfers an NFT into a parachain's sovereign account, who then mints a + /// trustless-backed-derivated locally. + /// + /// Asserts that the parachain accounts are updated as expected. + #[test] + fn reserve_asset_transfer_nft() { + sp_tracing::init_for_tests(); + MockNet::reset(); + + Relay::execute_with(|| { + assert_ok!(relay_chain::Uniques::force_create( + relay_chain::Origin::root(), + 2, + ALICE, + false + )); + assert_ok!(relay_chain::Uniques::mint( + relay_chain::Origin::signed(ALICE), + 2, + 69, + child_account_account_id(1, ALICE) + )); + assert_eq!( + relay_chain::Uniques::owner(2, 69), + Some(child_account_account_id(1, ALICE)) + ); + }); + ParaA::execute_with(|| { + assert_ok!(parachain::ForeignUniques::force_create( + parachain::Origin::root(), + (Parent, GeneralIndex(2)).into(), + ALICE, + false, + )); + assert_eq!( + parachain::ForeignUniques::owner((Parent, GeneralIndex(2)).into(), 69u32.into()), + None, + ); + assert_eq!(parachain::Balances::reserved_balance(&ALICE), 0); + + let message = Xcm(vec![ + WithdrawAsset((GeneralIndex(2), 69u32).into()), + DepositReserveAsset { + assets: AllCounted(1).into(), + dest: Parachain(1).into(), + xcm: Xcm(vec![DepositAsset { + assets: AllCounted(1).into(), + beneficiary: (AccountId32 { id: ALICE.into(), network: None },).into(), + }]), + }, + ]); + // Send transfer + let alice = AccountId32 { id: ALICE.into(), network: None }; + assert_ok!(ParachainPalletXcm::send_xcm(alice, Parent, message)); + }); + ParaA::execute_with(|| { + log::debug!(target: "xcm-exceutor", "Hello"); + assert_eq!( + parachain::ForeignUniques::owner((Parent, GeneralIndex(2)).into(), 69u32.into()), + Some(ALICE), + ); + assert_eq!(parachain::Balances::reserved_balance(&ALICE), 1000); + }); + + Relay::execute_with(|| { + assert_eq!(relay_chain::Uniques::owner(2, 69), Some(child_account_id(1))); + }); + } + + /// Scenario: + /// The relay-chain creates an asset class on a parachain and then Alice transfers her NFT into + /// that parachain's sovereign account, who then mints a trustless-backed-derivative locally. + /// + /// Asserts that the parachain accounts are updated as expected. + #[test] + fn reserve_asset_class_create_and_reserve_transfer() { + MockNet::reset(); + + Relay::execute_with(|| { + assert_ok!(relay_chain::Uniques::force_create( + relay_chain::Origin::root(), + 2, + ALICE, + false + )); + assert_ok!(relay_chain::Uniques::mint( + relay_chain::Origin::signed(ALICE), + 2, + 69, + child_account_account_id(1, ALICE) + )); + assert_eq!( + relay_chain::Uniques::owner(2, 69), + Some(child_account_account_id(1, ALICE)) + ); + + let message = Xcm(vec![Transact { + origin_kind: OriginKind::Xcm, + require_weight_at_most: 1_000_000_000, + call: parachain::Call::from(pallet_uniques::Call::::create { + class: (Parent, 2u64).into(), + admin: parent_account_id(), + }) + .encode() + .into(), + }]); + // Send creation. + assert_ok!(RelayChainPalletXcm::send_xcm(Here, Parachain(1), message)); + }); + ParaA::execute_with(|| { + // Then transfer + let message = Xcm(vec![ + WithdrawAsset((GeneralIndex(2), 69u32).into()), + DepositReserveAsset { + assets: AllCounted(1).into(), + dest: Parachain(1).into(), + xcm: Xcm(vec![DepositAsset { + assets: AllCounted(1).into(), + beneficiary: (AccountId32 { id: ALICE.into(), network: None },).into(), + }]), + }, + ]); + let alice = AccountId32 { id: ALICE.into(), network: None }; + assert_ok!(ParachainPalletXcm::send_xcm(alice, Parent, message)); + }); + ParaA::execute_with(|| { + assert_eq!(parachain::Balances::reserved_balance(&parent_account_id()), 1000); + assert_eq!( + parachain::ForeignUniques::class_owner((Parent, 2u64).into()), + Some(parent_account_id()) + ); + }); + } + /// Scenario: /// A parachain transfers funds on the relay chain to another parachain account. /// @@ -290,11 +551,11 @@ mod tests { Relay::execute_with(|| { assert_eq!( - relay_chain::Balances::free_balance(para_account_id(1)), + relay_chain::Balances::free_balance(child_account_id(1)), INITIAL_BALANCE - send_amount ); assert_eq!( - relay_chain::Balances::free_balance(para_account_id(2)), + relay_chain::Balances::free_balance(child_account_id(2)), INITIAL_BALANCE + send_amount ); }); @@ -335,12 +596,12 @@ mod tests { Relay::execute_with(|| { // Withdraw executed assert_eq!( - relay_chain::Balances::free_balance(para_account_id(1)), + relay_chain::Balances::free_balance(child_account_id(1)), INITIAL_BALANCE - send_amount ); // Deposit executed assert_eq!( - relay_chain::Balances::free_balance(para_account_id(2)), + relay_chain::Balances::free_balance(child_account_id(2)), INITIAL_BALANCE + send_amount ); }); diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index f7f8588fe382..ac322dddb499 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -19,7 +19,7 @@ use codec::{Decode, Encode}; use frame_support::{ construct_runtime, parameter_types, - traits::{Everything, Nothing}, + traits::{EnsureOrigin, EnsureOriginWithArg, Everything, EverythingBut, Nothing}, weights::{constants::WEIGHT_PER_SECOND, Weight}, }; use sp_core::H256; @@ -37,12 +37,22 @@ use polkadot_parachain::primitives::{ }; use xcm::{latest::prelude::*, VersionedXcm}; use xcm_builder::{ - AccountId32Aliases, AllowUnpaidExecutionFrom, CurrencyAdapter as XcmCurrencyAdapter, - EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, LocationInverter, - NativeAsset, ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, + Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, ConvertedConcreteId, + CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, + IsConcrete, LocationInverter, NativeAsset, NonFungiblesAdapter, ParentIsPreset, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, +}; +use xcm_executor::{ + traits::{Convert, JustTry}, + Config, XcmExecutor, }; -use xcm_executor::{Config, XcmExecutor}; + +pub type SovereignAccountOf = ( + SiblingParachainConvertsVia, + AccountId32Aliases, + ParentIsPreset, +); pub type AccountId = AccountId32; pub type Balance = u128; @@ -96,6 +106,58 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; } +#[cfg(feature = "runtime-benchmarks")] +pub struct UniquesHelper; +#[cfg(feature = "runtime-benchmarks")] +impl pallet_uniques::BenchmarkHelper for UniquesHelper { + fn class(i: u16) -> MultiLocation { + GeneralIndex(i as u128).into() + } + fn instance(i: u16) -> AssetInstance { + AssetInstance::Index(i as u128) + } +} + +impl pallet_uniques::Config for Runtime { + type Event = Event; + type ClassId = MultiLocation; + type InstanceId = AssetInstance; + type Currency = Balances; + type CreateOrigin = ForeignCreators; + type ForceOrigin = frame_system::EnsureRoot; + type ClassDeposit = frame_support::traits::ConstU128<1_000>; + type InstanceDeposit = frame_support::traits::ConstU128<1_000>; + type MetadataDepositBase = frame_support::traits::ConstU128<1_000>; + type AttributeDepositBase = frame_support::traits::ConstU128<1_000>; + type DepositPerByte = frame_support::traits::ConstU128<1>; + type StringLimit = frame_support::traits::ConstU32<64>; + type KeyLimit = frame_support::traits::ConstU32<64>; + type ValueLimit = frame_support::traits::ConstU32<128>; + type WeightInfo = (); + #[cfg(feature = "runtime-benchmarks")] + type Helper = UniquesHelper; +} + +// `EnsureOriginWithArg` impl for `CreateOrigin` which allows only XCM origins +// which are locations containing the class location. +pub struct ForeignCreators; +impl EnsureOriginWithArg for ForeignCreators { + type Success = AccountId; + + fn try_origin(o: Origin, a: &MultiLocation) -> sp_std::result::Result { + let origin_location = pallet_xcm::EnsureXcm::::try_origin(o.clone())?; + if !a.starts_with(&origin_location) { + return Err(o) + } + SovereignAccountOf::convert(origin_location).map_err(|_| o) + } + + #[cfg(feature = "runtime-benchmarks")] + fn successful_origin(a: &MultiLocation) -> Origin { + pallet_xcm::Origin::Xcm(a.clone()).into() + } +} + parameter_types! { pub const ReservedXcmpWeight: Weight = WEIGHT_PER_SECOND / 4; pub const ReservedDmpWeight: Weight = WEIGHT_PER_SECOND / 4; @@ -111,6 +173,7 @@ pub type LocationToAccountId = ( ParentIsPreset, SiblingParachainConvertsVia, AccountId32Aliases, + Account32Hash<(), AccountId>, ); pub type XcmOriginToCallOrigin = ( @@ -124,22 +187,41 @@ parameter_types! { pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; + pub ForeignPrefix: MultiLocation = (Parent,).into(); } -pub type LocalAssetTransactor = - XcmCurrencyAdapter, LocationToAccountId, AccountId, ()>; +pub type LocalAssetTransactor = ( + XcmCurrencyAdapter, LocationToAccountId, AccountId, ()>, + NonFungiblesAdapter< + ForeignUniques, + ConvertedConcreteId, + SovereignAccountOf, + AccountId, + Nothing, + (), + >, +); pub type XcmRouter = super::ParachainXcmRouter; pub type Barrier = AllowUnpaidExecutionFrom; +parameter_types! { + pub NftCollectionOne: MultiAssetFilter + = Wild(AllOf { fun: WildNonFungible, id: Concrete((Parent, GeneralIndex(1)).into()) }); + pub NftCollectionOneForRelay: (MultiAssetFilter, MultiLocation) + = (NftCollectionOne::get(), (Parent,).into()); +} +pub type TrustedTeleporters = xcm_builder::Case; +pub type TrustedReserves = EverythingBut>; + pub struct XcmConfig; impl Config for XcmConfig { type Call = Call; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; type OriginConverter = XcmOriginToCallOrigin; - type IsReserve = NativeAsset; - type IsTeleporter = (); + type IsReserve = (NativeAsset, TrustedReserves); + type IsTeleporter = TrustedTeleporters; type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; @@ -338,5 +420,6 @@ construct_runtime!( Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, MsgQueue: mock_msg_queue::{Pallet, Storage, Event}, PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin}, + ForeignUniques: pallet_uniques::{Pallet, Call, Storage, Event}, } ); diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 5bf0613b5e28..256780e0c692 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -18,7 +18,7 @@ use frame_support::{ construct_runtime, parameter_types, - traits::{Everything, Nothing}, + traits::{AsEnsureOriginWithArg, Everything, Nothing}, weights::Weight, }; use sp_core::H256; @@ -28,12 +28,13 @@ use polkadot_parachain::primitives::Id as ParaId; use polkadot_runtime_parachains::{configuration, origin, shared, ump}; use xcm::latest::prelude::*; use xcm_builder::{ - AccountId32Aliases, AllowUnpaidExecutionFrom, ChildParachainAsNative, - ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete, - LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, + ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, + ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, + FixedWeightBounds, IsConcrete, LocationInverter, NonFungiblesAdapter, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; -use xcm_executor::{Config, XcmExecutor}; +use xcm_executor::{traits::JustTry, Config, XcmExecutor}; pub type AccountId = AccountId32; pub type Balance = u128; @@ -87,6 +88,26 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; } +impl pallet_uniques::Config for Runtime { + type Event = Event; + type ClassId = u32; + type InstanceId = u32; + type Currency = Balances; + type CreateOrigin = AsEnsureOriginWithArg>; + type ForceOrigin = frame_system::EnsureRoot; + type ClassDeposit = frame_support::traits::ConstU128<1_000>; + type InstanceDeposit = frame_support::traits::ConstU128<1_000>; + type MetadataDepositBase = frame_support::traits::ConstU128<1_000>; + type AttributeDepositBase = frame_support::traits::ConstU128<1_000>; + type DepositPerByte = frame_support::traits::ConstU128<1>; + type StringLimit = frame_support::traits::ConstU32<64>; + type KeyLimit = frame_support::traits::ConstU32<64>; + type ValueLimit = frame_support::traits::ConstU32<128>; + type WeightInfo = (); + #[cfg(feature = "runtime-benchmarks")] + type Helper = (); +} + impl shared::Config for Runtime {} impl configuration::Config for Runtime { @@ -101,14 +122,26 @@ parameter_types! { pub UnitWeightCost: Weight = 1_000; } -pub type SovereignAccountOf = - (ChildParachainConvertsVia, AccountId32Aliases); +pub type LocationToAccountId = ( + ChildParachainConvertsVia, + AccountId32Aliases, + Account32Hash<(), AccountId>, +); -pub type LocalAssetTransactor = - XcmCurrencyAdapter, SovereignAccountOf, AccountId, ()>; +pub type LocalAssetTransactor = ( + XcmCurrencyAdapter, LocationToAccountId, AccountId, ()>, + NonFungiblesAdapter< + Uniques, + ConvertedConcreteId, JustTry>, + LocationToAccountId, + AccountId, + Nothing, + (), + >, +); type LocalOriginConverter = ( - SovereignSignedViaLocation, + SovereignSignedViaLocation, ChildParachainAsNative, SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, @@ -116,7 +149,7 @@ type LocalOriginConverter = ( parameter_types! { pub const BaseXcmWeight: Weight = 1_000; - pub KsmPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1); + pub TokensPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1_000_000_000_000); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -135,7 +168,7 @@ impl Config for XcmConfig { type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = FixedRateOfFungible; + type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); type AssetLocker = XcmPallet; @@ -170,7 +203,7 @@ impl pallet_xcm::Config for Runtime { type Currency = Balances; type CurrencyMatcher = IsConcrete; type TrustedLockers = (); - type SovereignAccountOf = SovereignAccountOf; + type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; } @@ -202,5 +235,6 @@ construct_runtime!( ParasOrigin: origin::{Pallet, Origin}, ParasUmp: ump::{Pallet, Call, Storage, Event}, XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin}, + Uniques: pallet_uniques::{Pallet, Call, Storage, Event}, } ); From c117f99aea240bf81c80dd603f29f087aad8132a Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 8 Mar 2022 23:27:29 +0100 Subject: [PATCH 067/231] XCM v3: Context & ID hash (#4756) * send_xcm returns message hash * cargo fmt * Create topic register and instructions * Fix weights * Use tabs * Sketch out XcmContext * Fix doc test * Add the XCM context as a parameter to executor trait fns * Fixes * Add XcmContext parameter * Revert adding context as an arg to SendXcm trait methods * Revert adding context argument to ConvertOrigin trait methods * cargo fmt * Do not change the API of XcmExecutor::execute * Fixes * Fixes * Fixes * Fixes * Remove convenience method * Fixes * Fixes * cargo fmt * Fixes * Add benchmarks for XCM topic instructions * cargo run --quiet --profile=production --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=pallet_xcm_benchmarks::generic --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs * Remove context argument on FilterAssetLocation * Fixes * Remove unused import * Fixes * Fixes * Fixes * Accept XCM hash parameter in ExecuteXcm trait methods * cargo fmt * Properly enable sp-io/std * Fixes * default-features = false * Fixes * Fixes * Fixes * Make XcmContext optional in withdraw_asset * Fixes * Fixes * Fixes * Modify tests to check for the correct XCM hash * Small refactor * cargo fmt * Check for expected hash in xcm-builder unit tests * Add doc comment for the optionality of the XCM context in withdraw_asset * Update xcm/src/v3/traits.rs * Update xcm/src/v3/traits.rs * Store XcmContext and avoid rebuilding * Use ref for XcmContext * Formatting * Fix incorrect hash CC @KiChjang * Refactor and make clear fake hashes * Fixes * Fixes * Fixes * Fix broken hashing * Docs * Fixes * Fixes * Fixes * Formatting * Fixes * Fixes * Fixes * Remove unknowable hash * Formatting * Use message hash for greater identifiability * Formatting * Fixes * Formatting Co-authored-by: Keith Yeung Co-authored-by: Parity Bot --- Cargo.lock | 1 + .../bin/rialto-parachain/runtime/src/lib.rs | 2 +- runtime/common/src/xcm_sender.rs | 4 +- runtime/parachains/src/ump.rs | 2 +- runtime/test-runtime/src/xcm_config.rs | 12 +- runtime/westend/src/weights/xcm/mod.rs | 6 + .../xcm/pallet_xcm_benchmarks_generic.rs | 60 +-- xcm/Cargo.toml | 4 +- xcm/pallet-xcm-benchmarks/Cargo.toml | 5 +- .../src/fungible/benchmarking.rs | 44 +- .../src/generic/benchmarking.rs | 85 +++- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 8 +- xcm/pallet-xcm-benchmarks/src/lib.rs | 2 +- xcm/pallet-xcm-benchmarks/src/mock.rs | 5 +- xcm/pallet-xcm/Cargo.toml | 12 +- xcm/pallet-xcm/src/lib.rs | 42 +- xcm/pallet-xcm/src/mock.rs | 17 +- xcm/pallet-xcm/src/tests.rs | 98 ++-- xcm/src/v3/mod.rs | 43 +- xcm/src/v3/traits.rs | 46 +- xcm/xcm-builder/Cargo.toml | 1 + xcm/xcm-builder/src/currency_adapter.rs | 16 +- xcm/xcm-builder/src/fungibles_adapter.rs | 36 +- xcm/xcm-builder/src/nonfungibles_adapter.rs | 56 ++- xcm/xcm-builder/src/test_utils.rs | 18 +- xcm/xcm-builder/src/tests/assets.rs | 454 ++++++++---------- xcm/xcm-builder/src/tests/basic.rs | 6 +- .../src/tests/bridging/local_para_para.rs | 8 +- .../src/tests/bridging/local_relay_relay.rs | 8 +- xcm/xcm-builder/src/tests/bridging/mod.rs | 24 +- .../tests/bridging/paid_remote_relay_relay.rs | 5 +- .../src/tests/bridging/remote_para_para.rs | 12 +- .../bridging/remote_para_para_via_relay.rs | 12 +- .../src/tests/bridging/remote_relay_relay.rs | 7 +- xcm/xcm-builder/src/tests/expecting.rs | 200 ++++---- xcm/xcm-builder/src/tests/locking.rs | 172 +++---- xcm/xcm-builder/src/tests/mock.rs | 65 ++- xcm/xcm-builder/src/tests/origins.rs | 61 ++- xcm/xcm-builder/src/tests/querying.rs | 113 ++--- xcm/xcm-builder/src/tests/transacting.rs | 81 ++-- .../src/tests/version_subscriptions.rs | 32 +- xcm/xcm-builder/src/tests/weight.rs | 10 +- xcm/xcm-builder/src/universal_exports.rs | 17 +- xcm/xcm-builder/tests/mock/mod.rs | 26 +- xcm/xcm-builder/tests/scenarios.rs | 216 ++++----- xcm/xcm-executor/src/lib.rs | 208 +++++--- xcm/xcm-executor/src/traits/drop_assets.rs | 30 +- xcm/xcm-executor/src/traits/export.rs | 12 +- xcm/xcm-executor/src/traits/on_response.rs | 19 +- xcm/xcm-executor/src/traits/transact_asset.rs | 158 ++++-- xcm/xcm-simulator/example/src/parachain.rs | 22 +- xcm/xcm-simulator/fuzzer/src/parachain.rs | 5 +- xcm/xcm-simulator/src/lib.rs | 17 +- 53 files changed, 1452 insertions(+), 1173 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17d92e732d60..1005704e4e49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12552,6 +12552,7 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", + "sp-io", "xcm-procedural", ] diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index 7660597892b0..50caa47ccf21 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -349,7 +349,7 @@ parameter_types! { pub const MaxAuthorities: u32 = 100_000; } -match_type! { +match_types! { pub type ParentOrParentsUnitPlurality: impl Contains = { MultiLocation { parents: 1, interior: Here } | MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) } diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index f93fa4944dfa..1502c5ec72a3 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -59,8 +59,10 @@ impl SendXcm fn deliver( (config, para, blob): (HostConfiguration, ParaId, Vec), - ) -> Result<(), SendError> { + ) -> Result { + let hash = sp_io::hashing::blake2_256(&blob[..]); >::queue_downward_message(&config, para, blob) + .map(|()| hash) .map_err(|_| SendError::Transport(&"Error placing into DMP queue")) } } diff --git a/runtime/parachains/src/ump.rs b/runtime/parachains/src/ump.rs index 3ccb51a3329c..38e977828499 100644 --- a/runtime/parachains/src/ump.rs +++ b/runtime/parachains/src/ump.rs @@ -133,7 +133,7 @@ impl, C: Config> UmpSink for XcmSi }, Ok((Ok(xcm_message), weight_used)) => { let xcm_junction = Junction::Parachain(origin.into()); - let outcome = XcmExecutor::execute_xcm(xcm_junction, xcm_message, max_weight); + let outcome = XcmExecutor::execute_xcm(xcm_junction, xcm_message, id, max_weight); match outcome { Outcome::Error(XcmError::WeightLimitReached(required)) => Err((id, required)), outcome => { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index c6643bc7aeab..cd0ac5137bd0 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -45,8 +45,8 @@ impl SendXcm for DoNothingRouter { fn validate(_dest: &mut Option, _msg: &mut Option>) -> SendResult<()> { Ok(((), MultiAssets::new())) } - fn deliver(_: ()) -> Result<(), SendError> { - Ok(()) + fn deliver(_: ()) -> Result { + Ok([0; 32]) } } @@ -54,11 +54,15 @@ pub type Barrier = AllowUnpaidExecutionFrom; pub struct DummyAssetTransactor; impl TransactAsset for DummyAssetTransactor { - fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation) -> XcmResult { + fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation, _context: &XcmContext) -> XcmResult { Ok(()) } - fn withdraw_asset(_what: &MultiAsset, _who: &MultiLocation) -> Result { + fn withdraw_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _maybe_context: Option<&XcmContext>, + ) -> Result { let asset: MultiAsset = (Parent, 100_000).into(); Ok(asset.into()) } diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 226328992e0f..85bcd7f60472 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -238,4 +238,10 @@ impl XcmWeightInfo for WestendXcmWeight { fn set_fees_mode(_: &bool) -> Weight { Weight::MAX // todo fix } + fn set_topic(_topic: &[u8; 32]) -> Weight { + XcmGeneric::::set_topic() + } + fn clear_topic() -> Weight { + XcmGeneric::::clear_topic() + } } diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index bd881fd41a81..0c5ab409be77 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,11 +17,11 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-12-20, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 +//! DATE: 2022-02-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// target/production/polkadot // benchmark // --chain=westend-dev // --steps=50 @@ -51,38 +51,38 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_holding() -> Weight { - (35_446_000 as Weight) + (24_000_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn buy_execution() -> Weight { - (5_228_000 as Weight) + (3_377_000 as Weight) } // Storage: XcmPallet Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (18_708_000 as Weight) + (12_418_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } pub(crate) fn transact() -> Weight { - (20_401_000 as Weight) + (12_795_000 as Weight) } pub(crate) fn refund_surplus() -> Weight { - (5_238_000 as Weight) + (3_485_000 as Weight) } pub(crate) fn set_error_handler() -> Weight { - (5_104_000 as Weight) + (3_314_000 as Weight) } pub(crate) fn set_appendix() -> Weight { - (5_095_000 as Weight) + (3_334_000 as Weight) } pub(crate) fn clear_error() -> Weight { - (5_010_000 as Weight) + (3_240_000 as Weight) } pub(crate) fn descend_origin() -> Weight { - (6_368_000 as Weight) + (4_339_000 as Weight) } pub(crate) fn clear_origin() -> Weight { - (5_011_000 as Weight) + (3_338_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -90,18 +90,18 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_error() -> Weight { - (27_823_000 as Weight) + (20_469_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: XcmPallet AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (12_402_000 as Weight) + (7_749_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } pub(crate) fn trap() -> Weight { - (5_022_000 as Weight) + (3_271_000 as Weight) } // Storage: XcmPallet VersionNotifyTargets (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -110,13 +110,13 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (32_492_000 as Weight) + (22_263_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: XcmPallet VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (7_777_000 as Weight) + (5_366_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -125,21 +125,21 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (37_066_000 as Weight) + (23_659_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn burn_asset() -> Weight { - (7_935_000 as Weight) + (4_910_000 as Weight) } pub(crate) fn expect_asset() -> Weight { - (5_237_000 as Weight) + (3_488_000 as Weight) } pub(crate) fn expect_origin() -> Weight { - (5_245_000 as Weight) + (3_400_000 as Weight) } pub(crate) fn expect_error() -> Weight { - (5_062_000 as Weight) + (3_358_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -147,12 +147,12 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn query_pallet() -> Weight { - (28_876_000 as Weight) + (21_841_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn expect_pallet() -> Weight { - (5_526_000 as Weight) + (3_716_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -160,11 +160,17 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_transact_status() -> Weight { - (27_889_000 as Weight) + (20_503_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn clear_transact_status() -> Weight { - (5_100_000 as Weight) + (3_270_000 as Weight) + } + pub(crate) fn set_topic() -> Weight { + (3_269_000 as Weight) + } + pub(crate) fn clear_topic() -> Weight { + (3_268_000 as Weight) } } diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index 9cc64e0f0980..96caab669cc5 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -7,8 +7,9 @@ edition = "2021" [dependencies] impl-trait-for-tuples = "0.2.2" -parity-scale-codec = { version = "3.0.0", default-features = false, features = [ "derive" ] } +parity-scale-codec = { version = "3.0.0", default-features = false, features = [ "derive", "max-encoded-len" ] } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } derivative = {version = "2.2.0", default-features = false, features = [ "use_core" ] } log = { version = "0.4.14", default-features = false } xcm-procedural = { path = "procedural" } @@ -20,4 +21,5 @@ runtime-benchmarks = [] std = [ "parity-scale-codec/std", "scale-info/std", + "sp-io/std" ] diff --git a/xcm/pallet-xcm-benchmarks/Cargo.toml b/xcm/pallet-xcm-benchmarks/Cargo.toml index bfb7d5641570..2007ce1efefb 100644 --- a/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -24,7 +24,6 @@ log = "0.4.0" pallet-balances = { branch = "master", git = "https://github.com/paritytech/substrate" } pallet-assets = { branch = "master", git = "https://github.com/paritytech/substrate" } sp-core = { branch = "master", git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "master", git = "https://github.com/paritytech/substrate" } sp-tracing = { branch = "master", git = "https://github.com/paritytech/substrate" } xcm-builder = { path = "../xcm-builder" } xcm = { path = ".." } @@ -41,6 +40,8 @@ std = [ "frame-benchmarking/std", "frame-support/std", "frame-system/std", + "sp-io/std", "sp-runtime/std", - "sp-std/std" + "sp-std/std", + "xcm-executor/std" ] diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 916da48c4a96..110f4993c369 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -44,7 +44,15 @@ benchmarks_instance_pallet! { let worst_case_holding = T::worst_case_holding(0); let asset = T::get_multi_asset(); - >::deposit_asset(&asset, &sender_location).unwrap(); + >::deposit_asset( + &asset, + &sender_location, + &XcmContext { + origin: Some(sender_location.clone()), + message_hash: [0; 32], + topic: None, + }, + ).unwrap(); // check the assets of origin. assert!(!T::TransactAsset::balance(&sender_account).is_zero()); @@ -53,7 +61,7 @@ benchmarks_instance_pallet! { let instruction = Instruction::>::WithdrawAsset(vec![asset.clone()].into()); let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // check one of the assets of origin. assert!(T::TransactAsset::balance(&sender_account).is_zero()); @@ -69,14 +77,22 @@ benchmarks_instance_pallet! { let dest_location = T::valid_destination()?; let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap(); - >::deposit_asset(&asset, &sender_location).unwrap(); + >::deposit_asset( + &asset, + &sender_location, + &XcmContext { + origin: Some(sender_location.clone()), + message_hash: [0; 32], + topic: None, + }, + ).unwrap(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); let mut executor = new_executor::(sender_location); let instruction = Instruction::TransferAsset { assets, beneficiary: dest_location }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert!(T::TransactAsset::balance(&sender_account).is_zero()); assert!(!T::TransactAsset::balance(&dest_account).is_zero()); @@ -88,7 +104,15 @@ benchmarks_instance_pallet! { let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap(); let asset = T::get_multi_asset(); - >::deposit_asset(&asset, &sender_location).unwrap(); + >::deposit_asset( + &asset, + &sender_location, + &XcmContext { + origin: Some(sender_location.clone()), + message_hash: [0; 32], + topic: None, + }, + ).unwrap(); let assets: MultiAssets = vec![ asset ].into(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); @@ -100,7 +124,7 @@ benchmarks_instance_pallet! { }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert!(T::TransactAsset::balance(&sender_account).is_zero()); assert!(!T::TransactAsset::balance(&dest_account).is_zero()); @@ -129,7 +153,7 @@ benchmarks_instance_pallet! { let instruction = Instruction::ReceiveTeleportedAsset(assets.clone()); let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm).map_err(|_| { + executor.bench_process(xcm).map_err(|_| { BenchmarkError::Override( BenchmarkResult::from_weight(T::BlockWeights::get().max_block) ) @@ -158,7 +182,7 @@ benchmarks_instance_pallet! { }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // dest should have received some asset. assert!(!T::TransactAsset::balance(&dest_account).is_zero()) @@ -185,7 +209,7 @@ benchmarks_instance_pallet! { }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // dest should have received some asset. assert!(!T::TransactAsset::balance(&dest_account).is_zero()) @@ -210,7 +234,7 @@ benchmarks_instance_pallet! { }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { if let Some(checked_account) = T::CheckedAccount::get() { // teleport checked account should have received some asset. diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 2d3b4fe6ff91..88743c0347ef 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -47,7 +47,7 @@ benchmarks! { let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // The completion of execution above is enough to validate this is completed. } @@ -69,7 +69,7 @@ benchmarks! { let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { } @@ -89,7 +89,7 @@ benchmarks! { let instruction = Instruction::ReserveAssetDeposited(multiassets.clone()); let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm).map_err(|_| BenchmarkError::Skip)?; + executor.bench_process(xcm).map_err(|_| BenchmarkError::Skip)?; } verify { assert_eq!(executor.holding(), &multiassets.into()); } @@ -102,7 +102,7 @@ benchmarks! { let instruction = Instruction::QueryResponse { query_id, response, max_weight, querier }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // The assert above is enough to show this XCM succeeded } @@ -127,7 +127,7 @@ benchmarks! { let num_events = frame_system::Pallet::::events().len(); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // TODO make better assertion? #4426 let num_events2 = frame_system::Pallet::::events().len(); @@ -144,7 +144,7 @@ benchmarks! { let instruction = Instruction::>::RefundSurplus; let xcm = Xcm(vec![instruction]); } : { - let result = executor.execute(xcm)?; + let result = executor.bench_process(xcm)?; } verify { assert_eq!(executor.total_surplus(), &1337); assert_eq!(executor.total_refunded(), &1337); @@ -155,7 +155,7 @@ benchmarks! { let instruction = Instruction::>::SetErrorHandler(Xcm(vec![])); let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert_eq!(executor.error_handler(), &Xcm(vec![])); } @@ -166,7 +166,7 @@ benchmarks! { let instruction = Instruction::>::SetAppendix(appendix); let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert_eq!(executor.appendix(), &Xcm(vec![])); } @@ -177,7 +177,7 @@ benchmarks! { let instruction = Instruction::>::ClearError; let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert!(executor.error().is_none()) } @@ -188,7 +188,7 @@ benchmarks! { let instruction = Instruction::DescendOrigin(who.clone()); let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert_eq!( executor.origin(), @@ -204,7 +204,7 @@ benchmarks! { let instruction = Instruction::ClearOrigin; let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert_eq!(executor.origin(), &None); } @@ -221,7 +221,7 @@ benchmarks! { }); let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // the execution succeeding is all we need to verify this xcm was successful } @@ -235,6 +235,11 @@ benchmarks! { ::AssetTrap::drop_assets( &origin, assets.clone().into(), + &XcmContext { + origin: Some(origin.clone()), + message_hash: [0; 32], + topic: None, + }, ); // Assets should be in the trap now. @@ -243,7 +248,7 @@ benchmarks! { let instruction = Instruction::ClaimAsset { assets: assets.clone(), ticket }; let xcm = Xcm(vec![instruction]); } :{ - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert!(executor.holding().ensure_contains(&assets).is_ok()); } @@ -255,7 +260,7 @@ benchmarks! { // In order to access result in the verification below, it needs to be defined here. let mut _result = Ok(()); } : { - _result = executor.execute(xcm); + _result = executor.bench_process(xcm); } verify { assert!(matches!(_result, Err(ExecutorError { xcm_error: XcmError::Trap(10), @@ -272,7 +277,7 @@ benchmarks! { let instruction = Instruction::SubscribeVersion { query_id, max_response_weight }; let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert!(::SubscriptionService::is_subscribed(&origin)); } @@ -286,7 +291,12 @@ benchmarks! { ::SubscriptionService::start( &origin, query_id, - max_response_weight + max_response_weight, + &XcmContext { + origin: Some(origin.clone()), + message_hash: [0; 32], + topic: None, + }, ).map_err(|_| "Could not start subscription")?; assert!(::SubscriptionService::is_subscribed(&origin)); @@ -294,7 +304,7 @@ benchmarks! { let instruction = Instruction::UnsubscribeVersion; let xcm = Xcm(vec![instruction]); } : { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert!(!::SubscriptionService::is_subscribed(&origin)); } @@ -308,7 +318,7 @@ benchmarks! { let instruction = Instruction::InitiateReserveWithdraw { assets: assets_filter, reserve, xcm: Xcm(vec![]) }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // The execute completing successfully is as good as we can check. // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 @@ -324,7 +334,7 @@ benchmarks! { let instruction = Instruction::BurnAsset(assets.into()); let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert!(executor.holding().is_empty()); } @@ -339,7 +349,7 @@ benchmarks! { let instruction = Instruction::ExpectAsset(assets.into()); let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // `execute` completing successfully is as good as we can check. } @@ -352,7 +362,7 @@ benchmarks! { let xcm = Xcm(vec![instruction]); let mut _result = Ok(()); }: { - _result = executor.execute(xcm); + _result = executor.bench_process(xcm); } verify { assert!(matches!(_result, Err(ExecutorError { xcm_error: XcmError::ExpectationFalse, @@ -368,7 +378,7 @@ benchmarks! { let xcm = Xcm(vec![instruction]); let mut _result = Ok(()); }: { - _result = executor.execute(xcm); + _result = executor.bench_process(xcm); } verify { assert!(matches!(_result, Err(ExecutorError { xcm_error: XcmError::ExpectationFalse, @@ -388,7 +398,7 @@ benchmarks! { }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 } @@ -405,7 +415,7 @@ benchmarks! { }; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // the execution succeeding is all we need to verify this xcm was successful } @@ -425,7 +435,7 @@ benchmarks! { }); let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 } @@ -437,11 +447,34 @@ benchmarks! { let instruction = Instruction::ClearTransactStatus; let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm)?; + executor.bench_process(xcm)?; } verify { assert_eq!(executor.transact_status(), &MaybeErrorCode::Success); } + set_topic { + let mut executor = new_executor::(Default::default()); + + let instruction = Instruction::SetTopic([1; 32]); + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + assert_eq!(executor.topic(), &Some([1; 32])); + } + + clear_topic { + let mut executor = new_executor::(Default::default()); + executor.set_topic(Some([2; 32])); + + let instruction = Instruction::ClearTopic; + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + assert_eq!(executor.topic(), &None); + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 052714204989..52f6e4528c58 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -84,11 +84,15 @@ impl frame_system::Config for Test { /// The benchmarks in this pallet should never need an asset transactor to begin with. pub struct NoAssetTransactor; impl xcm_executor::traits::TransactAsset for NoAssetTransactor { - fn deposit_asset(_: &MultiAsset, _: &MultiLocation) -> Result<(), XcmError> { + fn deposit_asset(_: &MultiAsset, _: &MultiLocation, _: &XcmContext) -> Result<(), XcmError> { unreachable!(); } - fn withdraw_asset(_: &MultiAsset, _: &MultiLocation) -> Result { + fn withdraw_asset( + _: &MultiAsset, + _: &MultiLocation, + _: Option<&XcmContext>, + ) -> Result { unreachable!(); } } diff --git a/xcm/pallet-xcm-benchmarks/src/lib.rs b/xcm/pallet-xcm-benchmarks/src/lib.rs index 8db2496e0b7d..4759199c7d63 100644 --- a/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -89,7 +89,7 @@ pub fn asset_instance_from(x: u32) -> AssetInstance { } pub fn new_executor(origin: MultiLocation) -> ExecutorOf { - ExecutorOf::::new(origin) + ExecutorOf::::new(origin, [0; 32]) } /// Build a multi-location from an account id. diff --git a/xcm/pallet-xcm-benchmarks/src/mock.rs b/xcm/pallet-xcm-benchmarks/src/mock.rs index e2940ff83c4e..84fc9fb9e7b4 100644 --- a/xcm/pallet-xcm-benchmarks/src/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/mock.rs @@ -24,8 +24,8 @@ impl xcm::opaque::latest::SendXcm for DevNull { fn validate(_: &mut Option, _: &mut Option>) -> SendResult<()> { Ok(((), MultiAssets::new())) } - fn deliver(_: ()) -> Result<(), SendError> { - Ok(()) + fn deliver(_: ()) -> Result { + Ok([0; 32]) } } @@ -39,6 +39,7 @@ impl xcm_executor::traits::OnResponse for DevNull { _: Option<&MultiLocation>, _: Response, _: Weight, + _: &XcmContext, ) -> Weight { 0 } diff --git a/xcm/pallet-xcm/Cargo.toml b/xcm/pallet-xcm/Cargo.toml index df3d5c8ccadc..23e5febf00cc 100644 --- a/xcm/pallet-xcm/Cargo.toml +++ b/xcm/pallet-xcm/Cargo.toml @@ -11,12 +11,12 @@ serde = { version = "1.0.136", optional = true, features = ["derive"] } log = { version = "0.4.14", default-features = false } impl-trait-for-tuples = "0.2.2" -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } xcm = { path = "..", default-features = false } xcm-executor = { path = "../xcm-executor", default-features = false } @@ -24,8 +24,8 @@ xcm-executor = { path = "../xcm-executor", default-features = false } [dev-dependencies] pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } polkadot-runtime-parachains = { path = "../../runtime/parachains" } -xcm-builder = { path = "../xcm-builder" } polkadot-parachain = { path = "../../parachain" } +xcm-builder = { path = "../xcm-builder" } [features] default = ["std"] @@ -34,8 +34,8 @@ std = [ "scale-info/std", "serde", "sp-std/std", - "sp-io/std", "sp-core/std", + "sp-io/std", "sp-runtime/std", "frame-support/std", "frame-system/std", diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index c31bcc7c7c07..5a388982c788 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -768,6 +768,7 @@ pub mod pallet { max_weight: Weight, ) -> DispatchResultWithPostInfo { let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let hash = message.using_encoded(sp_io::hashing::blake2_256); let message = (*message).try_into().map_err(|()| Error::::BadVersion)?; let value = (origin_location, message); ensure!(T::XcmExecuteFilter::contains(&value), Error::::Filtered); @@ -775,6 +776,7 @@ pub mod pallet { let outcome = T::XcmExecutor::execute_xcm_in_credit( origin_location, message, + hash, max_weight, max_weight, ); @@ -1014,8 +1016,9 @@ impl Pallet { let mut message = Xcm(vec![TransferReserveAsset { assets, dest, xcm }]); let weight = T::Weigher::weight(&mut message).map_err(|()| Error::::UnweighableMessage)?; + let hash = message.using_encoded(sp_io::hashing::blake2_256); let outcome = - T::XcmExecutor::execute_xcm_in_credit(origin_location, message, weight, weight); + T::XcmExecutor::execute_xcm_in_credit(origin_location, message, hash, weight, weight); Self::deposit_event(Event::Attempted(outcome)); Ok(()) } @@ -1072,8 +1075,9 @@ impl Pallet { Xcm(vec![WithdrawAsset(assets), InitiateTeleport { assets: Wild(All), dest, xcm }]); let weight = T::Weigher::weight(&mut message).map_err(|()| Error::::UnweighableMessage)?; + let hash = message.using_encoded(sp_io::hashing::blake2_256); let outcome = - T::XcmExecutor::execute_xcm_in_credit(origin_location, message, weight, weight); + T::XcmExecutor::execute_xcm_in_credit(origin_location, message, hash, weight, weight); Self::deposit_event(Event::Attempted(outcome)); Ok(()) } @@ -1152,7 +1156,7 @@ impl Pallet { let message = Xcm(vec![QueryResponse { query_id, response, max_weight, querier: None }]); let event = match send_xcm::(new_key.clone(), message) { - Ok(cost) => { + Ok((_hash, cost)) => { let value = (query_id, max_weight, xcm_version); VersionNotifyTargets::::insert(XCM_VERSION, key, value); Event::VersionChangeNotified(new_key, xcm_version, cost) @@ -1201,7 +1205,7 @@ impl Pallet { querier: None, }]); let event = match send_xcm::(new_key.clone(), message) { - Ok(cost) => { + Ok((_hash, cost)) => { VersionNotifyTargets::::insert( XCM_VERSION, versioned_key, @@ -1236,7 +1240,7 @@ impl Pallet { }); // TODO #3735: Correct weight. let instruction = SubscribeVersion { query_id, max_response_weight: 0 }; - let cost = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; + let (_hash, cost) = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; Self::deposit_event(Event::VersionNotifyRequested(dest, cost)); VersionNotifiers::::insert(XCM_VERSION, &versioned_dest, query_id); let query_status = @@ -1251,7 +1255,7 @@ impl Pallet { let versioned_dest = LatestVersionedMultiLocation(&dest); let query_id = VersionNotifiers::::take(XCM_VERSION, versioned_dest) .ok_or(XcmError::InvalidLocation)?; - let cost = send_xcm::(dest.clone(), Xcm(vec![UnsubscribeVersion]))?; + let (_hash, cost) = send_xcm::(dest.clone(), Xcm(vec![UnsubscribeVersion]))?; Self::deposit_event(Event::VersionNotifyUnrequested(dest, cost)); Queries::::remove(query_id); Ok(()) @@ -1264,7 +1268,7 @@ impl Pallet { interior: impl Into, dest: impl Into, mut message: Xcm<()>, - ) -> Result<(), SendError> { + ) -> Result { let interior = interior.into(); let dest = dest.into(); let maybe_fee_payer = if interior != Junctions::Here { @@ -1278,8 +1282,7 @@ impl Pallet { if let Some(fee_payer) = maybe_fee_payer { Self::charge_fees(fee_payer, price).map_err(|_| SendError::Fees)?; } - T::XcmRouter::deliver(ticket)?; - Ok(()) + T::XcmRouter::deliver(ticket) } pub fn check_account() -> T::AccountId { @@ -1663,7 +1666,12 @@ impl VersionChangeNotifier for Pallet { /// /// If the `location` has an ongoing notification and when this function is called, then an /// error should be returned. - fn start(dest: &MultiLocation, query_id: QueryId, max_weight: u64) -> XcmResult { + fn start( + dest: &MultiLocation, + query_id: QueryId, + max_weight: u64, + _context: &XcmContext, + ) -> XcmResult { let versioned_dest = LatestVersionedMultiLocation(dest); let already = VersionNotifyTargets::::contains_key(XCM_VERSION, versioned_dest); ensure!(!already, XcmError::InvalidLocation); @@ -1671,7 +1679,7 @@ impl VersionChangeNotifier for Pallet { let xcm_version = T::AdvertisedXcmVersion::get(); let response = Response::Version(xcm_version); let instruction = QueryResponse { query_id, response, max_weight, querier: None }; - let cost = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; + let (_hash, cost) = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; Self::deposit_event(Event::::VersionNotifyStarted(dest.clone(), cost)); let value = (query_id, max_weight, xcm_version); @@ -1681,7 +1689,7 @@ impl VersionChangeNotifier for Pallet { /// Stop notifying `location` should the XCM change. This is a no-op if there was never a /// subscription. - fn stop(dest: &MultiLocation) -> XcmResult { + fn stop(dest: &MultiLocation, _context: &XcmContext) -> XcmResult { VersionNotifyTargets::::remove(XCM_VERSION, LatestVersionedMultiLocation(dest)); Ok(()) } @@ -1694,7 +1702,7 @@ impl VersionChangeNotifier for Pallet { } impl DropAssets for Pallet { - fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight { + fn drop_assets(origin: &MultiLocation, assets: Assets, _context: &XcmContext) -> Weight { if assets.is_empty() { return 0 } @@ -1708,7 +1716,12 @@ impl DropAssets for Pallet { } impl ClaimAssets for Pallet { - fn claim_assets(origin: &MultiLocation, ticket: &MultiLocation, assets: &MultiAssets) -> bool { + fn claim_assets( + origin: &MultiLocation, + ticket: &MultiLocation, + assets: &MultiAssets, + _context: &XcmContext, + ) -> bool { let mut versioned = VersionedMultiAssets::from(assets.clone()); match (ticket.parents, &ticket.interior) { (0, X1(GeneralIndex(i))) => @@ -1755,6 +1768,7 @@ impl OnResponse for Pallet { querier: Option<&MultiLocation>, response: Response, max_weight: Weight, + _context: &XcmContext, ) -> Weight { match (response, Queries::::get(query_id)) { ( diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 1c394fe963d3..0e86483d6792 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use codec::Encode; use frame_support::{ construct_runtime, parameter_types, traits::{Everything, Nothing}, @@ -24,7 +25,7 @@ use polkadot_runtime_parachains::origin; use sp_core::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; pub use sp_std::{cell::RefCell, fmt::Debug, marker::PhantomData}; -use xcm::latest::prelude::*; +use xcm::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, Case, ChildParachainAsNative, ChildParachainConvertsVia, @@ -164,9 +165,10 @@ impl SendXcm for TestSendXcm { let pair = (dest.take().unwrap(), msg.take().unwrap()); Ok((pair, MultiAssets::new())) } - fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result { + let hash = fake_message_hash(&pair.1); SENT_XCM.with(|q| q.borrow_mut().push(pair)); - Ok(()) + Ok(hash) } } /// Sender that returns error if `X8` junction and stops routing @@ -184,9 +186,10 @@ impl SendXcm for TestSendXcmErrX8 { Ok(((dest, msg), MultiAssets::new())) } } - fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result { + let hash = fake_message_hash(&pair.1); SENT_XCM.with(|q| q.borrow_mut().push(pair)); - Ok(()) + Ok(hash) } } @@ -372,3 +375,7 @@ pub(crate) fn new_test_ext_with_balances( ext.execute_with(|| System::set_block_number(1)); ext } + +pub(crate) fn fake_message_hash(message: &Xcm) -> XcmHash { + message.using_encoded(sp_io::hashing::blake2_256) +} diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index 5739f57f0a97..69b804fb9804 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -77,16 +77,15 @@ fn report_outcome_notify_works() { }; assert_eq!(crate::Queries::::iter().collect::>(), vec![(0, status)]); - let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID), - Xcm(vec![QueryResponse { - query_id: 0, - response: Response::ExecutionResult(None), - max_weight: 1_000_000, - querier: Some(querier), - }]), - 1_000_000_000, - ); + let message = Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: 1_000_000, + querier: Some(querier), + }]); + let hash = fake_message_hash(&message); + let r = + XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, 1_000_000_000); assert_eq!(r, Outcome::Complete(1_000)); assert_eq!( last_events(2), @@ -134,16 +133,15 @@ fn report_outcome_works() { }; assert_eq!(crate::Queries::::iter().collect::>(), vec![(0, status)]); - let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID), - Xcm(vec![QueryResponse { - query_id: 0, - response: Response::ExecutionResult(None), - max_weight: 0, - querier: Some(querier), - }]), - 1_000_000_000, - ); + let message = Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: 0, + querier: Some(querier), + }]); + let hash = fake_message_hash(&message); + let r = + XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, 1_000_000_000); assert_eq!(r, Outcome::Complete(1_000)); assert_eq!( last_event(), @@ -174,14 +172,17 @@ fn custom_querier_works() { assert_eq!(crate::Queries::::iter().collect::>(), vec![(0, status)]); // Supplying no querier when one is expected will fail + let message = Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: 0, + querier: None, + }]); + let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm_in_credit( AccountId32 { network: None, id: ALICE.into() }, - Xcm(vec![QueryResponse { - query_id: 0, - response: Response::ExecutionResult(None), - max_weight: 0, - querier: None, - }]), + message, + hash, 1_000_000_000, 1_000, ); @@ -197,14 +198,17 @@ fn custom_querier_works() { ); // Supplying the wrong querier will also fail + let message = Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: 0, + querier: Some(MultiLocation::here()), + }]); + let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm_in_credit( AccountId32 { network: None, id: ALICE.into() }, - Xcm(vec![QueryResponse { - query_id: 0, - response: Response::ExecutionResult(None), - max_weight: 0, - querier: Some(MultiLocation::here()), - }]), + message, + hash, 1_000_000_000, 1_000, ); @@ -220,14 +224,17 @@ fn custom_querier_works() { ); // Multiple failures should not have changed the query state + let message = Xcm(vec![QueryResponse { + query_id: 0, + response: Response::ExecutionResult(None), + max_weight: 0, + querier: Some(querier), + }]); + let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm( AccountId32 { network: None, id: ALICE.into() }, - Xcm(vec![QueryResponse { - query_id: 0, - response: Response::ExecutionResult(None), - max_weight: 0, - querier: Some(querier), - }]), + message, + hash, 1_000_000_000, ); assert_eq!(r, Outcome::Complete(1_000)); @@ -815,7 +822,8 @@ fn subscription_side_works() { let remote: MultiLocation = Parachain(1000).into(); let weight = BaseXcmWeight::get(); let message = Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: 0 }]); - let r = XcmExecutor::::execute_xcm(remote.clone(), message, weight); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(remote.clone(), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); let instr = QueryResponse { @@ -949,7 +957,8 @@ fn subscriber_side_subscription_works() { querier: None, }, ]); - let r = XcmExecutor::::execute_xcm(remote.clone(), message, weight); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(remote.clone(), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); assert_eq!(take_sent_xcm(), vec![]); @@ -966,7 +975,8 @@ fn subscriber_side_subscription_works() { querier: None, }, ]); - let r = XcmExecutor::::execute_xcm(remote.clone(), message, weight); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(remote.clone(), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); // This message can now be sent to remote as it's v2. @@ -1026,7 +1036,8 @@ fn auto_subscription_works() { querier: None, }, ]); - let r = XcmExecutor::::execute_xcm(remote0.clone(), message, weight); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(remote0.clone(), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); // This message can now be sent to remote0 as it's v2. @@ -1056,7 +1067,8 @@ fn auto_subscription_works() { querier: None, }, ]); - let r = XcmExecutor::::execute_xcm(remote1.clone(), message, weight); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(remote1.clone(), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); // v2 messages cannot be sent to remote1... diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 1e92ea4d79a1..f8dc413a858f 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -45,7 +45,7 @@ pub use multilocation::{ }; pub use traits::{ send_xcm, validate_send, Error, ExecuteXcm, Outcome, PreparedMessage, Result, SendError, - SendResult, SendXcm, Unwrappable, Weight, + SendResult, SendXcm, Unwrappable, Weight, XcmHash, }; // These parts of XCM v2 are unchanged in XCM v3, and are re-imported here. pub use super::v2::{OriginKind, WeightLimit}; @@ -184,7 +184,7 @@ pub mod prelude { WeightLimit::{self, *}, WildFungibility::{self, Fungible as WildFungible, NonFungible as WildNonFungible}, WildMultiAsset::{self, *}, - XcmWeightInfo, VERSION as XCM_VERSION, + XcmContext, XcmHash, XcmWeightInfo, VERSION as XCM_VERSION, }; } pub use super::{Instruction, Xcm}; @@ -329,6 +329,25 @@ pub struct QueryResponseInfo { pub max_weight: Weight, } +/// Contextual data pertaining to a specific list of XCM instructions. +#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug)] +pub struct XcmContext { + /// The `MultiLocation` origin of the corresponding XCM. + pub origin: Option, + /// The hash of the XCM. + pub message_hash: XcmHash, + /// The topic of the XCM. + pub topic: Option<[u8; 32]>, +} + +impl XcmContext { + /// Constructor which sets the message hash to the supplied parameter and leaves the origin and + /// topic unset. + pub fn with_message_hash(message_hash: XcmHash) -> XcmContext { + XcmContext { origin: None, message_hash, topic: None } + } +} + /// Cross-Consensus Message: A message from one consensus system to another. /// /// Consensus systems that may send and receive messages include blockchains and smart contracts. @@ -944,6 +963,22 @@ pub enum Instruction { /// /// Errors: SetFeesMode { jit_withdraw: bool }, + + /// Set the Topic Register. + /// + /// Safety: No concerns. + /// + /// Kind: *Instruction* + /// + /// Errors: + SetTopic([u8; 32]), + + /// Clear the Topic Register. + /// + /// Kind: *Instruction* + /// + /// Errors: None. + ClearTopic, } impl Xcm { @@ -1015,6 +1050,8 @@ impl Instruction { NoteUnlockable { asset, owner } => NoteUnlockable { asset, owner }, RequestUnlock { asset, locker } => RequestUnlock { asset, locker }, SetFeesMode { jit_withdraw } => SetFeesMode { jit_withdraw }, + SetTopic(topic) => SetTopic(topic), + ClearTopic => ClearTopic, } } } @@ -1078,6 +1115,8 @@ impl> GetWeight for Instruction { NoteUnlockable { asset, owner } => W::note_unlockable(asset, owner), RequestUnlock { asset, locker } => W::request_unlock(asset, locker), SetFeesMode { jit_withdraw } => W::set_fees_mode(jit_withdraw), + SetTopic(topic) => W::set_topic(topic), + ClearTopic => W::clear_topic(), } } } diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 357ebfc391ce..b5b3f6adaff2 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -246,15 +246,17 @@ pub trait ExecuteXcm { fn execute( origin: impl Into, pre: Self::Prepared, + hash: XcmHash, weight_credit: Weight, ) -> Outcome; - /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is - /// a basic hard-limit and the implementation may place further restrictions or requirements on weight and - /// other aspects. + /// Execute some XCM `message` with the message `hash` from `origin` using no more than `weight_limit` weight. + /// The weight limit is a basic hard-limit and the implementation may place further restrictions or requirements + /// on weight and other aspects. fn execute_xcm( origin: impl Into, message: Xcm, + hash: XcmHash, weight_limit: Weight, ) -> Outcome { let origin = origin.into(); @@ -265,16 +267,17 @@ pub trait ExecuteXcm { message, weight_limit, ); - Self::execute_xcm_in_credit(origin, message, weight_limit, 0) + Self::execute_xcm_in_credit(origin, message, hash, weight_limit, 0) } - /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. + /// Execute some XCM `message` with the message `hash` from `origin` using no more than `weight_limit` weight. /// /// Some amount of `weight_credit` may be provided which, depending on the implementation, may allow /// execution without associated payment. fn execute_xcm_in_credit( origin: impl Into, message: Xcm, + hash: XcmHash, weight_limit: Weight, weight_credit: Weight, ) -> Outcome { @@ -286,7 +289,7 @@ pub trait ExecuteXcm { if xcm_weight > weight_limit { return Outcome::Error(Error::WeightLimitReached(xcm_weight)) } - Self::execute(origin, pre, weight_credit) + Self::execute(origin, pre, hash, weight_credit) } /// Deduct some `fees` to the sovereign account of the given `location` and place them as per @@ -306,7 +309,7 @@ impl ExecuteXcm for () { fn prepare(message: Xcm) -> result::Result> { Err(message) } - fn execute(_: impl Into, _: Self::Prepared, _: Weight) -> Outcome { + fn execute(_: impl Into, _: Self::Prepared, _: XcmHash, _: Weight) -> Outcome { unreachable!() } fn charge_fees(_location: impl Into, _fees: MultiAssets) -> Result { @@ -340,6 +343,9 @@ pub enum SendError { Fees, } +/// A hash type for identifying messages. +pub type XcmHash = [u8; 32]; + /// Result value when attempting to send an XCM message. pub type SendResult = result::Result<(T, MultiAssets), SendError>; @@ -372,8 +378,9 @@ impl Unwrappable for Option { /// /// # Example /// ```rust -/// # use xcm::v3::prelude::*; /// # use parity_scale_codec::Encode; +/// # use xcm::v3::prelude::*; +/// # use xcm::VersionedXcm; /// # use std::convert::Infallible; /// /// /// A sender that only passes the message through and does nothing. @@ -383,7 +390,7 @@ impl Unwrappable for Option { /// fn validate(_: &mut Option, _: &mut Option>) -> SendResult { /// Err(SendError::NotApplicable) /// } -/// fn deliver(_: Infallible) -> Result<(), SendError> { +/// fn deliver(_: Infallible) -> Result { /// unreachable!() /// } /// } @@ -398,8 +405,8 @@ impl Unwrappable for Option { /// _ => Err(SendError::Unroutable), /// } /// } -/// fn deliver(_: ()) -> Result<(), SendError> { -/// Ok(()) +/// fn deliver(_: ()) -> Result { +/// Ok([0; 32]) /// } /// } /// @@ -413,8 +420,8 @@ impl Unwrappable for Option { /// _ => Err(SendError::NotApplicable), /// } /// } -/// fn deliver(_: ()) -> Result<(), SendError> { -/// Ok(()) +/// fn deliver(_: ()) -> Result { +/// Ok([0; 32]) /// } /// } /// @@ -426,6 +433,7 @@ impl Unwrappable for Option { /// require_weight_at_most: 0, /// call: call.into(), /// }]); +/// let message_hash = message.using_encoded(sp_io::hashing::blake2_256); /// /// // Sender2 will block this. /// assert!(send_xcm::<(Sender1, Sender2, Sender3)>(Parent.into(), message.clone()).is_err()); @@ -453,7 +461,7 @@ pub trait SendXcm { ) -> SendResult; /// Actually carry out the delivery operation for a previously validated message sending. - fn deliver(ticket: Self::Ticket) -> result::Result<(), SendError>; + fn deliver(ticket: Self::Ticket) -> result::Result; } #[impl_trait_for_tuples::impl_for_tuples(30)] @@ -486,7 +494,7 @@ impl SendXcm for Tuple { } } - fn deliver(one_ticket: Self::Ticket) -> result::Result<(), SendError> { + fn deliver(one_ticket: Self::Ticket) -> result::Result { for_tuples!( #( if let Some(validated) = one_ticket.Tuple { return Tuple::deliver(validated); @@ -513,8 +521,8 @@ pub fn validate_send(dest: MultiLocation, msg: Xcm<()>) -> SendResul pub fn send_xcm( dest: MultiLocation, msg: Xcm<()>, -) -> result::Result { - let (ticket, price) = T::validate(&mut Some(dest), &mut Some(msg))?; - T::deliver(ticket)?; - Ok(price) +) -> result::Result<(XcmHash, MultiAssets), SendError> { + let (ticket, price) = T::validate(&mut Some(dest), &mut Some(msg.clone()))?; + let hash = T::deliver(ticket)?; + Ok((hash, price)) } diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index 93fce90aadbe..1eee8c45a5a8 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -44,6 +44,7 @@ std = [ "sp-io/std", "sp-runtime/std", "frame-support/std", + "frame-system/std", "polkadot-parachain/std", "pallet-transaction-payment/std", ] diff --git a/xcm/xcm-builder/src/currency_adapter.rs b/xcm/xcm-builder/src/currency_adapter.rs index fb616a961bdf..d85f371bd346 100644 --- a/xcm/xcm-builder/src/currency_adapter.rs +++ b/xcm/xcm-builder/src/currency_adapter.rs @@ -19,7 +19,7 @@ use frame_support::traits::{ExistenceRequirement::AllowDeath, Get, WithdrawReasons}; use sp_runtime::traits::{CheckedSub, SaturatedConversion}; use sp_std::{convert::TryInto, marker::PhantomData, result}; -use xcm::latest::{Error as XcmError, MultiAsset, MultiLocation, Result}; +use xcm::latest::{Error as XcmError, MultiAsset, MultiLocation, Result, XcmContext}; use xcm_executor::{ traits::{Convert, MatchesFungible, TransactAsset}, Assets, @@ -101,7 +101,7 @@ impl< > TransactAsset for CurrencyAdapter { - fn can_check_in(_origin: &MultiLocation, what: &MultiAsset) -> Result { + fn can_check_in(_origin: &MultiLocation, what: &MultiAsset, _context: &XcmContext) -> Result { log::trace!(target: "xcm::currency_adapter", "can_check_in origin: {:?}, what: {:?}", _origin, what); // Check we handle this asset. let amount: Currency::Balance = @@ -121,7 +121,7 @@ impl< Ok(()) } - fn check_in(_origin: &MultiLocation, what: &MultiAsset) { + fn check_in(_origin: &MultiLocation, what: &MultiAsset, _context: &XcmContext) { log::trace!(target: "xcm::currency_adapter", "check_in origin: {:?}, what: {:?}", _origin, what); if let Some(amount) = Matcher::matches_fungible(what) { if let Some(checked_account) = CheckedAccount::get() { @@ -140,7 +140,7 @@ impl< } } - fn check_out(_dest: &MultiLocation, what: &MultiAsset) { + fn check_out(_dest: &MultiLocation, what: &MultiAsset, _context: &XcmContext) { log::trace!(target: "xcm::currency_adapter", "check_out dest: {:?}, what: {:?}", _dest, what); if let Some(amount) = Matcher::matches_fungible(what) { if let Some(checked_account) = CheckedAccount::get() { @@ -149,7 +149,7 @@ impl< } } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> Result { + fn deposit_asset(what: &MultiAsset, who: &MultiLocation, _context: &XcmContext) -> Result { log::trace!(target: "xcm::currency_adapter", "deposit_asset what: {:?}, who: {:?}", what, who); // Check we handle this asset. let amount: u128 = @@ -162,7 +162,11 @@ impl< Ok(()) } - fn withdraw_asset(what: &MultiAsset, who: &MultiLocation) -> result::Result { + fn withdraw_asset( + what: &MultiAsset, + who: &MultiLocation, + _maybe_context: Option<&XcmContext>, + ) -> result::Result { log::trace!(target: "xcm::currency_adapter", "withdraw_asset what: {:?}, who: {:?}", what, who); // Check we handle this asset. let amount: u128 = diff --git a/xcm/xcm-builder/src/fungibles_adapter.rs b/xcm/xcm-builder/src/fungibles_adapter.rs index c5e17bbdc2c2..be8e9d27cfaa 100644 --- a/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/xcm/xcm-builder/src/fungibles_adapter.rs @@ -35,6 +35,7 @@ impl< what: &MultiAsset, from: &MultiLocation, to: &MultiLocation, + _context: &XcmContext, ) -> result::Result { log::trace!( target: "xcm::fungibles_adapter", @@ -78,7 +79,11 @@ impl< CheckingAccount, > { - fn can_check_in(_origin: &MultiLocation, what: &MultiAsset) -> XcmResult { + fn can_check_in( + _origin: &MultiLocation, + what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { log::trace!( target: "xcm::fungibles_adapter", "can_check_in origin: {:?}, what: {:?}", @@ -96,7 +101,7 @@ impl< Ok(()) } - fn check_in(_origin: &MultiLocation, what: &MultiAsset) { + fn check_in(_origin: &MultiLocation, what: &MultiAsset, _context: &XcmContext) { log::trace!( target: "xcm::fungibles_adapter", "check_in origin: {:?}, what: {:?}", @@ -114,7 +119,7 @@ impl< } } - fn check_out(_dest: &MultiLocation, what: &MultiAsset) { + fn check_out(_dest: &MultiLocation, what: &MultiAsset, _context: &XcmContext) { log::trace!( target: "xcm::fungibles_adapter", "check_out dest: {:?}, what: {:?}", @@ -129,7 +134,7 @@ impl< } } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { + fn deposit_asset(what: &MultiAsset, who: &MultiLocation, _context: &XcmContext) -> XcmResult { log::trace!( target: "xcm::fungibles_adapter", "deposit_asset what: {:?}, who: {:?}", @@ -146,6 +151,7 @@ impl< fn withdraw_asset( what: &MultiAsset, who: &MultiLocation, + _maybe_context: Option<&XcmContext>, ) -> result::Result { log::trace!( target: "xcm::fungibles_adapter", @@ -180,7 +186,7 @@ impl< > TransactAsset for FungiblesAdapter { - fn can_check_in(origin: &MultiLocation, what: &MultiAsset) -> XcmResult { + fn can_check_in(origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult { FungiblesMutateAdapter::< Assets, Matcher, @@ -188,10 +194,10 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::can_check_in(origin, what) + >::can_check_in(origin, what, context) } - fn check_in(origin: &MultiLocation, what: &MultiAsset) { + fn check_in(origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) { FungiblesMutateAdapter::< Assets, Matcher, @@ -199,10 +205,10 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::check_in(origin, what) + >::check_in(origin, what, context) } - fn check_out(dest: &MultiLocation, what: &MultiAsset) { + fn check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) { FungiblesMutateAdapter::< Assets, Matcher, @@ -210,10 +216,10 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::check_out(dest, what) + >::check_out(dest, what, context) } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { + fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { FungiblesMutateAdapter::< Assets, Matcher, @@ -221,12 +227,13 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::deposit_asset(what, who) + >::deposit_asset(what, who, context) } fn withdraw_asset( what: &MultiAsset, who: &MultiLocation, + maybe_context: Option<&XcmContext>, ) -> result::Result { FungiblesMutateAdapter::< Assets, @@ -235,16 +242,17 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::withdraw_asset(what, who) + >::withdraw_asset(what, who, maybe_context) } fn transfer_asset( what: &MultiAsset, from: &MultiLocation, to: &MultiLocation, + context: &XcmContext, ) -> result::Result { FungiblesTransferAdapter::::transfer_asset( - what, from, to, + what, from, to, context, ) } } diff --git a/xcm/xcm-builder/src/nonfungibles_adapter.rs b/xcm/xcm-builder/src/nonfungibles_adapter.rs index 14a749022be0..d717145cc4fc 100644 --- a/xcm/xcm-builder/src/nonfungibles_adapter.rs +++ b/xcm/xcm-builder/src/nonfungibles_adapter.rs @@ -38,11 +38,12 @@ impl< what: &MultiAsset, from: &MultiLocation, to: &MultiLocation, + context: &XcmContext, ) -> result::Result { log::trace!( target: "xcm::non_fungibles_adapter", - "transfer_asset what: {:?}, from: {:?}, to: {:?}", - what, from, to + "transfer_asset what: {:?}, from: {:?}, to: {:?}, context: {:?}", + what, from, to, context, ); // Check we handle this asset. let (class, instance) = Matcher::matches_nonfungibles(what)?; @@ -79,11 +80,11 @@ impl< CheckingAccount, > { - fn can_check_in(_origin: &MultiLocation, what: &MultiAsset) -> XcmResult { + fn can_check_in(_origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult { log::trace!( target: "xcm::fungibles_adapter", - "can_check_in origin: {:?}, what: {:?}", - _origin, what + "can_check_in origin: {:?}, what: {:?}, context: {:?}", + _origin, what, context, ); // Check we handle this asset. let (class, instance) = Matcher::matches_nonfungibles(what)?; @@ -98,11 +99,11 @@ impl< Ok(()) } - fn check_in(_origin: &MultiLocation, what: &MultiAsset) { + fn check_in(_origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) { log::trace!( target: "xcm::fungibles_adapter", - "check_in origin: {:?}, what: {:?}", - _origin, what + "check_in origin: {:?}, what: {:?}, context: {:?}", + _origin, what, context, ); if let Ok((class, instance)) = Matcher::matches_nonfungibles(what) { if CheckAsset::contains(&class) { @@ -115,11 +116,11 @@ impl< } } - fn check_out(_dest: &MultiLocation, what: &MultiAsset) { + fn check_out(_dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) { log::trace!( target: "xcm::fungibles_adapter", - "check_out dest: {:?}, what: {:?}", - _dest, what + "check_out dest: {:?}, what: {:?}, context: {:?}", + _dest, what, context, ); if let Ok((class, instance)) = Matcher::matches_nonfungibles(what) { if CheckAsset::contains(&class) { @@ -131,11 +132,11 @@ impl< } } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { + fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { log::trace!( target: "xcm::fungibles_adapter", - "deposit_asset what: {:?}, who: {:?}", - what, who, + "deposit_asset what: {:?}, who: {:?}, context: {:?}", + what, who, context, ); // Check we handle this asset. let (class, instance) = Matcher::matches_nonfungibles(what)?; @@ -148,11 +149,12 @@ impl< fn withdraw_asset( what: &MultiAsset, who: &MultiLocation, + maybe_context: Option<&XcmContext>, ) -> result::Result { log::trace!( target: "xcm::fungibles_adapter", - "withdraw_asset what: {:?}, who: {:?}", - what, who, + "withdraw_asset what: {:?}, who: {:?}, maybe_context: {:?}", + what, who, maybe_context, ); // Check we handle this asset. let who = AccountIdConverter::convert_ref(who) @@ -182,7 +184,7 @@ impl< > TransactAsset for NonFungiblesAdapter { - fn can_check_in(origin: &MultiLocation, what: &MultiAsset) -> XcmResult { + fn can_check_in(origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult { NonFungiblesMutateAdapter::< Assets, Matcher, @@ -190,10 +192,10 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::can_check_in(origin, what) + >::can_check_in(origin, what, context) } - fn check_in(origin: &MultiLocation, what: &MultiAsset) { + fn check_in(origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) { NonFungiblesMutateAdapter::< Assets, Matcher, @@ -201,10 +203,10 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::check_in(origin, what) + >::check_in(origin, what, context) } - fn check_out(dest: &MultiLocation, what: &MultiAsset) { + fn check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) { NonFungiblesMutateAdapter::< Assets, Matcher, @@ -212,10 +214,10 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::check_out(dest, what) + >::check_out(dest, what, context) } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { + fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { NonFungiblesMutateAdapter::< Assets, Matcher, @@ -223,12 +225,13 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::deposit_asset(what, who) + >::deposit_asset(what, who, context) } fn withdraw_asset( what: &MultiAsset, who: &MultiLocation, + maybe_context: Option<&XcmContext>, ) -> result::Result { NonFungiblesMutateAdapter::< Assets, @@ -237,16 +240,17 @@ impl< AccountId, CheckAsset, CheckingAccount, - >::withdraw_asset(what, who) + >::withdraw_asset(what, who, maybe_context) } fn transfer_asset( what: &MultiAsset, from: &MultiLocation, to: &MultiLocation, + context: &XcmContext, ) -> result::Result { NonFungiblesTransferAdapter::::transfer_asset( - what, from, to, + what, from, to, context, ) } } diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index ceb41aa409ac..f75edc47661c 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -37,13 +37,18 @@ parameter_types! { pub struct TestSubscriptionService; impl VersionChangeNotifier for TestSubscriptionService { - fn start(location: &MultiLocation, query_id: QueryId, max_weight: u64) -> XcmResult { + fn start( + location: &MultiLocation, + query_id: QueryId, + max_weight: u64, + _context: &XcmContext, + ) -> XcmResult { let mut r = SubscriptionRequests::get(); r.push((location.clone(), Some((query_id, max_weight)))); SubscriptionRequests::set(r); Ok(()) } - fn stop(location: &MultiLocation) -> XcmResult { + fn stop(location: &MultiLocation, _context: &XcmContext) -> XcmResult { let mut r = SubscriptionRequests::get(); r.retain(|(l, _q)| l != location); r.push((location.clone(), None)); @@ -63,7 +68,7 @@ parameter_types! { pub struct TestAssetTrap; impl DropAssets for TestAssetTrap { - fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight { + fn drop_assets(origin: &MultiLocation, assets: Assets, _context: &XcmContext) -> Weight { let mut t: Vec<(MultiLocation, MultiAssets)> = TrappedAssets::get(); t.push((origin.clone(), assets.into())); TrappedAssets::set(t); @@ -72,7 +77,12 @@ impl DropAssets for TestAssetTrap { } impl ClaimAssets for TestAssetTrap { - fn claim_assets(origin: &MultiLocation, ticket: &MultiLocation, what: &MultiAssets) -> bool { + fn claim_assets( + origin: &MultiLocation, + ticket: &MultiLocation, + what: &MultiAssets, + _context: &XcmContext, + ) -> bool { let mut t: Vec<(MultiLocation, MultiAssets)> = TrappedAssets::get(); if let (0, X1(GeneralIndex(i))) = (ticket.parents, &ticket.interior) { if let Some((l, a)) = t.get(*i as usize) { diff --git a/xcm/xcm-builder/src/tests/assets.rs b/xcm/xcm-builder/src/tests/assets.rs index afec771cb0a8..e78047988e04 100644 --- a/xcm/xcm-builder/src/tests/assets.rs +++ b/xcm/xcm-builder/src/tests/assets.rs @@ -21,22 +21,19 @@ fn exchange_asset_should_work() { AllowUnpaidFrom::set(vec![Parent.into()]); add_asset(Parent, (Parent, 1000u128)); set_exchange_assets(vec![(Here, 100u128).into()]); - let r = XcmExecutor::::execute_xcm( - Parent, - Xcm(vec![ - WithdrawAsset((Parent, 100u128).into()), - SetAppendix( - vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] - .into(), - ), - ExchangeAsset { - give: Definite((Parent, 50u128).into()), - want: (Here, 50u128).into(), - maximal: true, - }, - ]), - 50, - ); + let message = Xcm(vec![ + WithdrawAsset((Parent, 100u128).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }].into(), + ), + ExchangeAsset { + give: Definite((Parent, 50u128).into()), + want: (Here, 50u128).into(), + maximal: true, + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, 50); assert_eq!(r, Outcome::Complete(40)); assert_eq!(asset_list(Parent), vec![(Here, 100u128).into(), (Parent, 950u128).into()]); assert_eq!(exchange_assets(), vec![(Parent, 50u128).into()].into()); @@ -45,24 +42,21 @@ fn exchange_asset_should_work() { #[test] fn exchange_asset_without_maximal_should_work() { AllowUnpaidFrom::set(vec![Parent.into()]); - add_asset(Parent, (Parent, 1000)); + add_asset(Parent, (Parent, 1000u128)); set_exchange_assets(vec![(Here, 100u128).into()]); - let r = XcmExecutor::::execute_xcm( - Parent, - Xcm(vec![ - WithdrawAsset((Parent, 100u128).into()), - SetAppendix( - vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] - .into(), - ), - ExchangeAsset { - give: Definite((Parent, 50u128).into()), - want: (Here, 50u128).into(), - maximal: false, - }, - ]), - 50, - ); + let message = Xcm(vec![ + WithdrawAsset((Parent, 100u128).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }].into(), + ), + ExchangeAsset { + give: Definite((Parent, 50).into()), + want: (Here, 50u128).into(), + maximal: false, + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, 50); assert_eq!(r, Outcome::Complete(40)); assert_eq!(asset_list(Parent), vec![(Here, 50u128).into(), (Parent, 950u128).into()]); assert_eq!(exchange_assets(), vec![(Here, 50u128).into(), (Parent, 50u128).into()].into()); @@ -71,24 +65,21 @@ fn exchange_asset_without_maximal_should_work() { #[test] fn exchange_asset_should_fail_when_no_deal_possible() { AllowUnpaidFrom::set(vec![Parent.into()]); - add_asset(Parent, (Parent, 1000)); + add_asset(Parent, (Parent, 1000u128)); set_exchange_assets(vec![(Here, 100u128).into()]); - let r = XcmExecutor::::execute_xcm( - Parent, - Xcm(vec![ - WithdrawAsset((Parent, 150u128).into()), - SetAppendix( - vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }] - .into(), - ), - ExchangeAsset { - give: Definite((Parent, 150u128).into()), - want: (Here, 150u128).into(), - maximal: false, - }, - ]), - 50, - ); + let message = Xcm(vec![ + WithdrawAsset((Parent, 150u128).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: Parent.into() }].into(), + ), + ExchangeAsset { + give: Definite((Parent, 150u128).into()), + want: (Here, 150u128).into(), + maximal: false, + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, 50); assert_eq!(r, Outcome::Incomplete(40, XcmError::NoDeal)); assert_eq!(asset_list(Parent), vec![(Parent, 1000u128).into()]); assert_eq!(exchange_assets(), vec![(Here, 100u128).into()].into()); @@ -106,8 +97,9 @@ fn paying_reserve_deposit_should_work() { BuyExecution { fees, weight_limit: Limited(30) }, DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); + let hash = fake_message_hash(&message); let weight_limit = 50; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(30)); assert_eq!(asset_list(Here), vec![(Parent, 70u128).into()]); } @@ -119,14 +111,12 @@ fn transfer_should_work() { // Child parachain #1 owns 1000 tokens held by us in reserve. add_asset(Parachain(1), (Here, 1000)); // They want to transfer 100 of them to their sibling parachain #2 - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![TransferAsset { - assets: (Here, 100u128).into(), - beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), - }]), - 50, - ); + let message = Xcm(vec![TransferAsset { + assets: (Here, 100u128).into(), + beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); assert_eq!( asset_list(AccountIndex64 { index: 3, network: None }), @@ -146,32 +136,26 @@ fn reserve_transfer_should_work() { // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 // and let them know to hand it to account #3. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![TransferReserveAsset { - assets: (Here, 100u128).into(), - dest: Parachain(2).into(), - xcm: Xcm::<()>(vec![DepositAsset { - assets: AllCounted(1).into(), - beneficiary: three.clone(), - }]), + let message = Xcm(vec![TransferReserveAsset { + assets: (Here, 100u128).into(), + dest: Parachain(2).into(), + xcm: Xcm::<()>(vec![DepositAsset { + assets: AllCounted(1).into(), + beneficiary: three.clone(), }]), - 50, - ); + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); - assert_eq!(asset_list(Parachain(2)), vec![(Here, 100u128).into()]); - assert_eq!( - sent_xcm(), - vec![( - Parachain(2).into(), - Xcm::<()>(vec![ - ReserveAssetDeposited((Parent, 100u128).into()), - ClearOrigin, - DepositAsset { assets: AllCounted(1).into(), beneficiary: three }, - ]), - )] - ); + let expected_msg = Xcm::<()>(vec![ + ReserveAssetDeposited((Parent, 100u128).into()), + ClearOrigin, + DepositAsset { assets: AllCounted(1).into(), beneficiary: three }, + ]); + let expected_hash = fake_message_hash(&expected_msg); + assert_eq!(asset_list(Parachain(2)), vec![(Here, 100).into()]); + assert_eq!(sent_xcm(), vec![(Parachain(2).into(), expected_msg, expected_hash)]); } #[test] @@ -181,29 +165,25 @@ fn burn_should_work() { // Child parachain #1 owns 1000 tokens held by us in reserve. add_asset(Parachain(1), (Here, 1000)); // They want to burn 100 of them - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((Here, 1000u128).into()), - BurnAsset((Here, 100u128).into()), - DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, - ]), - 50, - ); + let message = Xcm(vec![ + WithdrawAsset((Here, 1000u128).into()), + BurnAsset((Here, 100u128).into()), + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(30)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(sent_xcm(), vec![]); // Now they want to burn 1000 of them, which will actually only burn 900. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((Here, 900u128).into()), - BurnAsset((Here, 1000u128).into()), - DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, - ]), - 50, - ); + let message = Xcm(vec![ + WithdrawAsset((Here, 900u128).into()), + BurnAsset((Here, 1000u128).into()), + DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(30)); assert_eq!(asset_list(Parachain(1)), vec![]); assert_eq!(sent_xcm(), vec![]); @@ -217,86 +197,76 @@ fn basic_asset_trap_should_work() { // Child parachain #1 owns 1000 tokens held by us in reserve. add_asset(Parachain(1), (Here, 1000)); // They want to transfer 100 of them to their sibling parachain #2 but have a problem - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset((Here, 100u128).into()), - DepositAsset { - assets: Wild(AllCounted(0)), // <<< 0 is an error. - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); + let message = Xcm(vec![ + WithdrawAsset((Here, 100u128).into()), + DepositAsset { + assets: Wild(AllCounted(0)), // <<< 0 is an error. + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); assert_eq!(r, Outcome::Complete(25)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); // Incorrect ticket doesn't work. + let message = Xcm(vec![ + ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(1).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]); + let hash = fake_message_hash(&message); let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(1).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); // Incorrect origin doesn't work. + let message = Xcm(vec![ + ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]); + let hash = fake_message_hash(&message); let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm( - Parachain(2), - Xcm(vec![ - ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0u128).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); + let r = XcmExecutor::::execute_xcm(Parachain(2), message, hash, 20); assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); // Incorrect assets doesn't work. + let message = Xcm(vec![ + ClaimAsset { assets: (Here, 101u128).into(), ticket: GeneralIndex(0).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]); + let hash = fake_message_hash(&message); let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - ClaimAsset { assets: (Here, 101u128).into(), ticket: GeneralIndex(0u128).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0u128).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); + let message = Xcm(vec![ + ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); assert_eq!(r, Outcome::Complete(20)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!( @@ -305,17 +275,15 @@ fn basic_asset_trap_should_work() { ); // Same again doesn't work :-) - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0u128).into() }, - DepositAsset { - assets: Wild(AllCounted(1)), - beneficiary: AccountIndex64 { index: 3, network: None }.into(), - }, - ]), - 20, - ); + let message = Xcm(vec![ + ClaimAsset { assets: (Here, 100u128).into(), ticket: GeneralIndex(0).into() }, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: AccountIndex64 { index: 3, network: None }.into(), + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); } @@ -335,99 +303,89 @@ fn max_assets_limit_should_work() { add_asset(Parachain(1), ([9u8; 32], 1000u128)); // Attempt to withdraw 8 (=2x4)different assets. This will succeed. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset(([1u8; 32], 100u128).into()), - WithdrawAsset(([2u8; 32], 100u128).into()), - WithdrawAsset(([3u8; 32], 100u128).into()), - WithdrawAsset(([4u8; 32], 100u128).into()), - WithdrawAsset(([5u8; 32], 100u128).into()), - WithdrawAsset(([6u8; 32], 100u128).into()), - WithdrawAsset(([7u8; 32], 100u128).into()), - WithdrawAsset(([8u8; 32], 100u128).into()), - ]), - 100, - ); + let message = Xcm(vec![ + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([5u8; 32], 100u128).into()), + WithdrawAsset(([6u8; 32], 100u128).into()), + WithdrawAsset(([7u8; 32], 100u128).into()), + WithdrawAsset(([8u8; 32], 100u128).into()), + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 100); assert_eq!(r, Outcome::Complete(85)); // Attempt to withdraw 9 different assets will fail. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset(([1u8; 32], 100u128).into()), - WithdrawAsset(([2u8; 32], 100u128).into()), - WithdrawAsset(([3u8; 32], 100u128).into()), - WithdrawAsset(([4u8; 32], 100u128).into()), - WithdrawAsset(([5u8; 32], 100u128).into()), - WithdrawAsset(([6u8; 32], 100u128).into()), - WithdrawAsset(([7u8; 32], 100u128).into()), - WithdrawAsset(([8u8; 32], 100u128).into()), - WithdrawAsset(([9u8; 32], 100u128).into()), - ]), - 100, - ); + let message = Xcm(vec![ + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([5u8; 32], 100u128).into()), + WithdrawAsset(([6u8; 32], 100u128).into()), + WithdrawAsset(([7u8; 32], 100u128).into()), + WithdrawAsset(([8u8; 32], 100u128).into()), + WithdrawAsset(([9u8; 32], 100u128).into()), + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 100); assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); // Attempt to withdraw 4 different assets and then the same 4 and then a different 4 will succeed. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset(([1u8; 32], 100u128).into()), - WithdrawAsset(([2u8; 32], 100u128).into()), - WithdrawAsset(([3u8; 32], 100u128).into()), - WithdrawAsset(([4u8; 32], 100u128).into()), - WithdrawAsset(([1u8; 32], 100u128).into()), - WithdrawAsset(([2u8; 32], 100u128).into()), - WithdrawAsset(([3u8; 32], 100u128).into()), - WithdrawAsset(([4u8; 32], 100u128).into()), - WithdrawAsset(([5u8; 32], 100u128).into()), - WithdrawAsset(([6u8; 32], 100u128).into()), - WithdrawAsset(([7u8; 32], 100u128).into()), - WithdrawAsset(([8u8; 32], 100u128).into()), - ]), - 200, - ); + let message = Xcm(vec![ + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([5u8; 32], 100u128).into()), + WithdrawAsset(([6u8; 32], 100u128).into()), + WithdrawAsset(([7u8; 32], 100u128).into()), + WithdrawAsset(([8u8; 32], 100u128).into()), + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 200); assert_eq!(r, Outcome::Complete(125)); // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset(([1u8; 32], 100u128).into()), - WithdrawAsset(([2u8; 32], 100u128).into()), - WithdrawAsset(([3u8; 32], 100u128).into()), - WithdrawAsset(([4u8; 32], 100u128).into()), - WithdrawAsset(([5u8; 32], 100u128).into()), - WithdrawAsset(([6u8; 32], 100u128).into()), - WithdrawAsset(([7u8; 32], 100u128).into()), - WithdrawAsset(([8u8; 32], 100u128).into()), - WithdrawAsset(([1u8; 32], 100u128).into()), - WithdrawAsset(([2u8; 32], 100u128).into()), - WithdrawAsset(([3u8; 32], 100u128).into()), - WithdrawAsset(([4u8; 32], 100u128).into()), - ]), - 200, - ); + let message = Xcm(vec![ + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + WithdrawAsset(([5u8; 32], 100u128).into()), + WithdrawAsset(([6u8; 32], 100u128).into()), + WithdrawAsset(([7u8; 32], 100u128).into()), + WithdrawAsset(([8u8; 32], 100u128).into()), + WithdrawAsset(([1u8; 32], 100u128).into()), + WithdrawAsset(([2u8; 32], 100u128).into()), + WithdrawAsset(([3u8; 32], 100u128).into()), + WithdrawAsset(([4u8; 32], 100u128).into()), + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 200); assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - WithdrawAsset(MultiAssets::from(vec![ - ([1u8; 32], 100u128).into(), - ([2u8; 32], 100u128).into(), - ([3u8; 32], 100u128).into(), - ([4u8; 32], 100u128).into(), - ([5u8; 32], 100u128).into(), - ([6u8; 32], 100u128).into(), - ([7u8; 32], 100u128).into(), - ([8u8; 32], 100u128).into(), - ])), - WithdrawAsset(([1u8; 32], 100u128).into()), - ]), - 200, - ); + let message = Xcm(vec![ + WithdrawAsset(MultiAssets::from(vec![ + ([1u8; 32], 100u128).into(), + ([2u8; 32], 100u128).into(), + ([3u8; 32], 100u128).into(), + ([4u8; 32], 100u128).into(), + ([5u8; 32], 100u128).into(), + ([6u8; 32], 100u128).into(), + ([7u8; 32], 100u128).into(), + ([8u8; 32], 100u128).into(), + ])), + WithdrawAsset(([1u8; 32], 100u128).into()), + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 200); assert_eq!(r, Outcome::Incomplete(25, XcmError::HoldingWouldOverflow)); } diff --git a/xcm/xcm-builder/src/tests/basic.rs b/xcm/xcm-builder/src/tests/basic.rs index 383385a9baad..ea378e849873 100644 --- a/xcm/xcm-builder/src/tests/basic.rs +++ b/xcm/xcm-builder/src/tests/basic.rs @@ -84,13 +84,15 @@ fn code_registers_should_work() { let limit = ::Weigher::weight(&mut message).unwrap(); assert_eq!(limit, 70); - let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); + let hash = fake_message_hash(&message); + + let r = XcmExecutor::::execute_xcm(Here, message.clone(), hash, limit); assert_eq!(r, Outcome::Complete(50)); // We don't pay the 20 weight for the error handler. assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 13u128).into()]); assert_eq!(asset_list(Here), vec![(Here, 8u128).into()]); assert_eq!(sent_xcm(), vec![]); - let r = XcmExecutor::::execute_xcm(Here, message, limit); + let r = XcmExecutor::::execute_xcm(Here, message, hash, limit); assert_eq!(r, Outcome::Complete(70)); // We pay the full weight here. assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 20u128).into()]); assert_eq!(asset_list(Here), vec![(Here, 1u128).into()]); diff --git a/xcm/xcm-builder/src/tests/bridging/local_para_para.rs b/xcm/xcm-builder/src/tests/bridging/local_para_para.rs index 0e6bcfd4b6dd..396aa81d792f 100644 --- a/xcm/xcm-builder/src/tests/bridging/local_para_para.rs +++ b/xcm/xcm-builder/src/tests/bridging/local_para_para.rs @@ -42,7 +42,7 @@ type Router = LocalUnpaidExporter, Un fn sending_to_bridged_chain_works() { let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Parent, Remote::get(), Parachain(1)).into(); - assert_eq!(send_xcm::(dest, msg), Ok((Here, 100).into())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, (Here, 100).into()); assert_eq!(TheBridge::service(), 1); assert_eq!( take_received_remote_messages(), @@ -69,8 +69,9 @@ fn sending_to_bridged_chain_works() { /// ``` #[test] fn sending_to_parachain_of_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Parent, Remote::get(), Parachain(1000)).into(); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Here, 100).into())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, (Here, 100).into()); assert_eq!(TheBridge::service(), 1); let expected = vec![( (Parent, Parachain(1000)).into(), @@ -95,8 +96,9 @@ fn sending_to_parachain_of_bridged_chain_works() { /// ``` #[test] fn sending_to_relay_chain_of_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Parent, Remote::get()).into(); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Here, 100).into())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, (Here, 100).into()); assert_eq!(TheBridge::service(), 1); let expected = vec![( Parent.into(), diff --git a/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs index 244458f363fd..7fd5de2b2719 100644 --- a/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs +++ b/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs @@ -37,7 +37,10 @@ type Router = LocalUnpaidExporter, Un #[test] fn sending_to_bridged_chain_works() { let msg = Xcm(vec![Trap(1)]); - assert_eq!(send_xcm::((Parent, Remote::get()).into(), msg), Ok((Here, 100).into())); + assert_eq!( + send_xcm::((Parent, Remote::get()).into(), msg).unwrap().1, + (Here, 100).into() + ); assert_eq!(TheBridge::service(), 1); assert_eq!( take_received_remote_messages(), @@ -57,8 +60,9 @@ fn sending_to_bridged_chain_works() { /// ``` #[test] fn sending_to_parachain_of_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Remote::get(), Parachain(1000)).into(); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Here, 100).into())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, (Here, 100).into()); assert_eq!(TheBridge::service(), 1); let expected = vec![(Parachain(1000).into(), Xcm(vec![UniversalOrigin(Local::get().into()), Trap(1)]))]; diff --git a/xcm/xcm-builder/src/tests/bridging/mod.rs b/xcm/xcm-builder/src/tests/bridging/mod.rs index 575cd7af7368..f145fc2d4d0c 100644 --- a/xcm/xcm-builder/src/tests/bridging/mod.rs +++ b/xcm/xcm-builder/src/tests/bridging/mod.rs @@ -69,9 +69,10 @@ impl SendXcm for TestRemoteIncomingRouter { let pair = (dest.take().unwrap(), msg.take().unwrap()); Ok((pair, MultiAssets::new())) } - fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { + fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result { + let hash = fake_message_hash(&pair.1); REMOTE_INCOMING_XCM.with(|q| q.borrow_mut().push(pair)); - Ok(()) + Ok(hash) } } @@ -99,9 +100,8 @@ fn deliver( c: u32, d: InteriorMultiLocation, m: Xcm<()>, -) -> Result<(), SendError> { - export_xcm::(n, c, d, m)?; - Ok(()) +) -> Result { + export_xcm::(n, c, d, m).map(|(hash, _)| hash) } impl, Remote: Get, RemoteExporter: ExportXcm> SendXcm @@ -121,7 +121,7 @@ impl, Remote: Get, RemoteExporter: ExportXcm> S Ok((message, MultiAssets::new())) } - fn deliver(message: Xcm<()>) -> Result<(), SendError> { + fn deliver(message: Xcm<()>) -> Result { // We now pretend that the message was delivered from `Local` to `Remote`, and execute // so we need to ensure that the `TestConfig` is set up properly for executing as // though it is `Remote`. @@ -130,10 +130,11 @@ impl, Remote: Get, RemoteExporter: ExportXcm> S AllowUnpaidFrom::set(vec![origin.clone()]); set_exporter_override(price::, deliver::); // The we execute it: + let hash = fake_message_hash(&message); let outcome = - XcmExecutor::::execute_xcm(origin, message.into(), 2_000_000_000_000); + XcmExecutor::::execute_xcm(origin, message.into(), hash, 2_000_000_000_000); match outcome { - Outcome::Complete(..) => Ok(()), + Outcome::Complete(..) => Ok(hash), Outcome::Incomplete(..) => Err(Transport("Error executing")), Outcome::Error(..) => Err(Transport("Unable to execute")), } @@ -161,7 +162,7 @@ impl, Remote: Get, RemoteExporter: ExportXcm> S Ok((message, MultiAssets::new())) } - fn deliver(message: Xcm<()>) -> Result<(), SendError> { + fn deliver(message: Xcm<()>) -> Result { // We now pretend that the message was delivered from `Local` to `Remote`, and execute // so we need to ensure that the `TestConfig` is set up properly for executing as // though it is `Remote`. @@ -170,10 +171,11 @@ impl, Remote: Get, RemoteExporter: ExportXcm> S AllowPaidFrom::set(vec![origin.clone()]); set_exporter_override(price::, deliver::); // The we execute it: + let hash = fake_message_hash(&message); let outcome = - XcmExecutor::::execute_xcm(origin, message.into(), 2_000_000_000_000); + XcmExecutor::::execute_xcm(origin, message.into(), hash, 2_000_000_000_000); match outcome { - Outcome::Complete(..) => Ok(()), + Outcome::Complete(..) => Ok(hash), Outcome::Incomplete(..) => Err(Transport("Error executing")), Outcome::Error(..) => Err(Transport("Unable to execute")), } diff --git a/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs index f3b31582116c..86cea75e7300 100644 --- a/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs +++ b/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs @@ -66,7 +66,7 @@ fn sending_to_bridged_chain_works() { add_asset(Parachain(100), (Here, 1000u128)); let msg = Xcm(vec![Trap(1)]); - assert_eq!(send_xcm::(dest, msg), Ok((Parent, 150u128).into())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, (Parent, 150u128).into()); assert_eq!(TheBridge::service(), 1); assert_eq!( take_received_remote_messages(), @@ -106,7 +106,8 @@ fn sending_to_parachain_of_bridged_chain_works() { // Initialize the local relay so that our parachain has funds to pay for export. add_asset(Parachain(100), (Here, 1000u128)); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok((Parent, 150u128).into())); + let msg = Xcm(vec![Trap(1)]); + assert_eq!(send_xcm::(dest, msg).unwrap().1, (Parent, 150u128).into()); assert_eq!(TheBridge::service(), 1); let expected = vec![( Parachain(100).into(), diff --git a/xcm/xcm-builder/src/tests/bridging/remote_para_para.rs b/xcm/xcm-builder/src/tests/bridging/remote_para_para.rs index a79c1efa23ba..648807763b2a 100644 --- a/xcm/xcm-builder/src/tests/bridging/remote_para_para.rs +++ b/xcm/xcm-builder/src/tests/bridging/remote_para_para.rs @@ -50,8 +50,10 @@ type LocalRouter = (LocalInnerRouter, LocalBridgingRouter); fn sending_to_bridged_chain_works() { let msg = Xcm(vec![Trap(1)]); assert_eq!( - send_xcm::((Parent, Parent, Remote::get(), Parachain(1)).into(), msg), - Ok(MultiAssets::new()) + send_xcm::((Parent, Parent, Remote::get(), Parachain(1)).into(), msg) + .unwrap() + .1, + MultiAssets::new() ); assert_eq!(TheBridge::service(), 1); assert_eq!( @@ -79,8 +81,9 @@ fn sending_to_bridged_chain_works() { /// ``` #[test] fn sending_to_sibling_of_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Parent, Remote::get(), Parachain(1000)).into(); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, MultiAssets::new()); assert_eq!(TheBridge::service(), 1); let expected = vec![( (Parent, Parachain(1000)).into(), @@ -105,8 +108,9 @@ fn sending_to_sibling_of_bridged_chain_works() { /// ``` #[test] fn sending_to_relay_of_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Parent, Remote::get()).into(); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, MultiAssets::new()); assert_eq!(TheBridge::service(), 1); let expected = vec![( Parent.into(), diff --git a/xcm/xcm-builder/src/tests/bridging/remote_para_para_via_relay.rs b/xcm/xcm-builder/src/tests/bridging/remote_para_para_via_relay.rs index 3746e5c7766c..0a6e0bfb73dd 100644 --- a/xcm/xcm-builder/src/tests/bridging/remote_para_para_via_relay.rs +++ b/xcm/xcm-builder/src/tests/bridging/remote_para_para_via_relay.rs @@ -50,8 +50,10 @@ type LocalRouter = (LocalInnerRouter, LocalBridgingRouter); fn sending_to_bridged_chain_works() { let msg = Xcm(vec![Trap(1)]); assert_eq!( - send_xcm::((Parent, Remote::get(), Parachain(1)).into(), msg), - Ok(MultiAssets::new()) + send_xcm::((Parent, Remote::get(), Parachain(1)).into(), msg) + .unwrap() + .1, + MultiAssets::new() ); assert_eq!(TheBridge::service(), 1); assert_eq!( @@ -72,8 +74,9 @@ fn sending_to_bridged_chain_works() { /// ``` #[test] fn sending_to_sibling_of_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Remote::get(), Parachain(1000)).into(); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, MultiAssets::new()); assert_eq!(TheBridge::service(), 1); let expected = vec![( (Parent, Parachain(1000)).into(), @@ -94,8 +97,9 @@ fn sending_to_sibling_of_bridged_chain_works() { /// ``` #[test] fn sending_to_relay_of_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Remote::get()).into(); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, MultiAssets::new()); assert_eq!(TheBridge::service(), 1); let expected = vec![(Parent.into(), Xcm(vec![UniversalOrigin(Local::get().into()), Trap(1)]))]; assert_eq!(take_received_remote_messages(), expected); diff --git a/xcm/xcm-builder/src/tests/bridging/remote_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/remote_relay_relay.rs index 0fed565a53f0..83cc0ac78096 100644 --- a/xcm/xcm-builder/src/tests/bridging/remote_relay_relay.rs +++ b/xcm/xcm-builder/src/tests/bridging/remote_relay_relay.rs @@ -50,8 +50,8 @@ type LocalRouter = (LocalInnerRouter, LocalBridgeRouter); fn sending_to_bridged_chain_works() { let msg = Xcm(vec![Trap(1)]); assert_eq!( - send_xcm::((Parent, Parent, Remote::get()).into(), msg), - Ok(MultiAssets::new()) + send_xcm::((Parent, Parent, Remote::get()).into(), msg).unwrap().1, + MultiAssets::new() ); assert_eq!(TheBridge::service(), 1); assert_eq!( @@ -79,8 +79,9 @@ fn sending_to_bridged_chain_works() { /// ``` #[test] fn sending_to_parachain_of_bridged_chain_works() { + let msg = Xcm(vec![Trap(1)]); let dest = (Parent, Parent, Remote::get(), Parachain(1000)).into(); - assert_eq!(send_xcm::(dest, Xcm(vec![Trap(1)])), Ok(MultiAssets::new())); + assert_eq!(send_xcm::(dest, msg).unwrap().1, MultiAssets::new()); assert_eq!(TheBridge::service(), 1); let expected = vec![( Parachain(1000).into(), diff --git a/xcm/xcm-builder/src/tests/expecting.rs b/xcm/xcm-builder/src/tests/expecting.rs index d54eef86c358..33830a721e05 100644 --- a/xcm/xcm-builder/src/tests/expecting.rs +++ b/xcm/xcm-builder/src/tests/expecting.rs @@ -21,137 +21,117 @@ fn expect_pallet_should_work() { AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 // and let them know to hand it to account #3. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 41, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 41, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); } #[test] fn expect_pallet_should_fail_correctly() { AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 60, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 60, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"System".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 1, + name: b"System".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_system".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_system".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 0, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 0, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 2, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 42, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 2, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 42, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::PalletNotFound)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 2, - min_crate_minor: 42, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 2, + min_crate_minor: 42, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 0, - min_crate_minor: 42, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 0, + min_crate_minor: 42, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExpectPallet { - index: 1, - name: b"Balances".as_ref().into(), - module_name: b"pallet_balances".as_ref().into(), - crate_major: 1, - min_crate_minor: 43, - }]), - 50, - ); + let message = Xcm(vec![ExpectPallet { + index: 1, + name: b"Balances".as_ref().into(), + module_name: b"pallet_balances".as_ref().into(), + crate_major: 1, + min_crate_minor: 43, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); } diff --git a/xcm/xcm-builder/src/tests/locking.rs b/xcm/xcm-builder/src/tests/locking.rs index d6afe08e4970..9f58936faa39 100644 --- a/xcm/xcm-builder/src/tests/locking.rs +++ b/xcm/xcm-builder/src/tests/locking.rs @@ -27,31 +27,24 @@ fn lock_roundtrip_should_work() { set_send_price((Parent, 10u128)); // They want to lock 100 of the native parent tokens to be unlocked only by Parachain #1. - let r = XcmExecutor::::execute_xcm( - (3u64,), - Xcm(vec![ - WithdrawAsset((Parent, 100u128).into()), - SetAppendix( - vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: (3u64,).into() }] - .into(), - ), - LockAsset { asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into() }, - ]), - 50, - ); + let message = Xcm(vec![ + WithdrawAsset((Parent, 100u128).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: (3u64,).into() }].into(), + ), + LockAsset { asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); assert_eq!(r, Outcome::Complete(40)); assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); - assert_eq!( - sent_xcm(), - vec![( - (Parent, Parachain(1)).into(), - Xcm::<()>(vec![NoteUnlockable { - owner: (Parent, Parachain(42), 3u64).into(), - asset: (Parent, 100u128).into() - },]), - )] - ); + let expected_msg = Xcm::<()>(vec![NoteUnlockable { + owner: (Parent, Parachain(42), 3u64).into(), + asset: (Parent, 100u128).into(), + }]); + let expected_hash = fake_message_hash(&expected_msg); + assert_eq!(sent_xcm(), vec![((Parent, Parachain(1)).into(), expected_msg, expected_hash)]); assert_eq!( take_lock_trace(), vec![Lock { @@ -62,11 +55,10 @@ fn lock_roundtrip_should_work() { ); // Now we'll unlock it. - let r = XcmExecutor::::execute_xcm( - (Parent, Parachain(1)), - Xcm(vec![UnlockAsset { asset: (Parent, 100u128).into(), target: (3u64,).into() }]), - 50, - ); + let message = + Xcm(vec![UnlockAsset { asset: (Parent, 100u128).into(), target: (3u64,).into() }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((Parent, Parachain(1)), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); } @@ -80,14 +72,12 @@ fn auto_fee_paying_should_work() { set_send_price((Parent, 10u128)); // They want to lock 100 of the native parent tokens to be unlocked only by Parachain #1. - let r = XcmExecutor::::execute_xcm( - (3u64,), - Xcm(vec![ - SetFeesMode { jit_withdraw: true }, - LockAsset { asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into() }, - ]), - 50, - ); + let message = Xcm(vec![ + SetFeesMode { jit_withdraw: true }, + LockAsset { asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); assert_eq!(r, Outcome::Complete(20)); assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); } @@ -99,14 +89,12 @@ fn lock_should_fail_correctly() { // #3 wants to lock 100 of the native parent tokens to be unlocked only by parachain ../#1, // but they don't have any. - let r = XcmExecutor::::execute_xcm( - (3u64,), - Xcm(vec![LockAsset { - asset: (Parent, 100u128).into(), - unlocker: (Parent, Parachain(1)).into(), - }]), - 50, - ); + let message = Xcm(vec![LockAsset { + asset: (Parent, 100u128).into(), + unlocker: (Parent, Parachain(1)).into(), + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::LockError)); assert_eq!(sent_xcm(), vec![]); assert_eq!(take_lock_trace(), vec![]); @@ -118,14 +106,12 @@ fn lock_should_fail_correctly() { // #3 wants to lock 100 of the native parent tokens to be unlocked only by parachain ../#1, // but there's nothing to pay the fees for sending the notification message. - let r = XcmExecutor::::execute_xcm( - (3u64,), - Xcm(vec![LockAsset { - asset: (Parent, 100u128).into(), - unlocker: (Parent, Parachain(1)).into(), - }]), - 50, - ); + let message = Xcm(vec![LockAsset { + asset: (Parent, 100u128).into(), + unlocker: (Parent, Parachain(1)).into(), + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::NotHoldingFees)); assert_eq!(sent_xcm(), vec![]); assert_eq!(take_lock_trace(), vec![]); @@ -141,11 +127,10 @@ fn remote_unlock_roundtrip_should_work() { set_send_price((Parent, 10u128)); // We have been told by Parachain #1 that Account #3 has locked funds which we can unlock. - let r = XcmExecutor::::execute_xcm( - (Parent, Parachain(1)), - Xcm(vec![NoteUnlockable { asset: (Parent, 100u128).into(), owner: (3u64,).into() }]), - 50, - ); + let message = + Xcm(vec![NoteUnlockable { asset: (Parent, 100u128).into(), owner: (3u64,).into() }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((Parent, Parachain(1)), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); assert_eq!( take_lock_trace(), @@ -157,34 +142,22 @@ fn remote_unlock_roundtrip_should_work() { ); // Let's request those funds be unlocked. - let r = XcmExecutor::::execute_xcm( - (3u64,), - Xcm(vec![ - WithdrawAsset((Parent, 100u128).into()), - SetAppendix( - vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: (3u64,).into() }] - .into(), - ), - RequestUnlock { - asset: (Parent, 100u128).into(), - locker: (Parent, Parachain(1)).into(), - }, - ]), - 50, - ); + let message = Xcm(vec![ + WithdrawAsset((Parent, 100u128).into()), + SetAppendix( + vec![DepositAsset { assets: AllCounted(2).into(), beneficiary: (3u64,).into() }].into(), + ), + RequestUnlock { asset: (Parent, 100u128).into(), locker: (Parent, Parachain(1)).into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); assert_eq!(r, Outcome::Complete(40)); assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); - assert_eq!( - sent_xcm(), - vec![( - (Parent, Parachain(1)).into(), - Xcm::<()>(vec![UnlockAsset { - target: (3u64,).into(), - asset: (Parent, 100u128).into() - },]), - )] - ); + let expected_msg = + Xcm::<()>(vec![UnlockAsset { target: (3u64,).into(), asset: (Parent, 100u128).into() }]); + let expected_hash = fake_message_hash(&expected_msg); + assert_eq!(sent_xcm(), vec![((Parent, Parachain(1)).into(), expected_msg, expected_hash)]); assert_eq!( take_lock_trace(), vec![Reduce { @@ -205,38 +178,33 @@ fn remote_unlock_should_fail_correctly() { // We want to unlock 100 of the native parent tokens which were locked for us on parachain. // This won't work as we don't have any record of them being locked for us. // No message will be sent and no lock records changed. - let r = XcmExecutor::::execute_xcm( - (3u64,), - Xcm(vec![RequestUnlock { - asset: (Parent, 100u128).into(), - locker: (Parent, Parachain(1)).into(), - }]), - 50, - ); + let message = Xcm(vec![RequestUnlock { + asset: (Parent, 100u128).into(), + locker: (Parent, Parachain(1)).into(), + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::LockError)); assert_eq!(sent_xcm(), vec![]); assert_eq!(take_lock_trace(), vec![]); // We have been told by Parachain #1 that Account #3 has locked funds which we can unlock. - let r = XcmExecutor::::execute_xcm( - (Parent, Parachain(1)), - Xcm(vec![NoteUnlockable { asset: (Parent, 100u128).into(), owner: (3u64,).into() }]), - 50, - ); + let message = + Xcm(vec![NoteUnlockable { asset: (Parent, 100u128).into(), owner: (3u64,).into() }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((Parent, Parachain(1)), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); let _discard = take_lock_trace(); // We want to unlock 100 of the native parent tokens which were locked for us on parachain. // This won't work now as we don't have the funds to send the onward message. // No message will be sent and no lock records changed. - let r = XcmExecutor::::execute_xcm( - (3u64,), - Xcm(vec![RequestUnlock { - asset: (Parent, 100u128).into(), - locker: (Parent, Parachain(1)).into(), - }]), - 50, - ); + let message = Xcm(vec![RequestUnlock { + asset: (Parent, 100u128).into(), + locker: (Parent, Parachain(1)).into(), + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::NotHoldingFees)); assert_eq!(sent_xcm(), vec![]); diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index 3972170ab15c..e1f2fbcbaa87 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -30,13 +30,14 @@ pub use frame_support::{ weights::{GetDispatchInfo, PostDispatchInfo}, }; pub use parity_scale_codec::{Decode, Encode}; +pub use sp_io::hashing::blake2_256; pub use sp_std::{ cell::RefCell, collections::{btree_map::BTreeMap, btree_set::BTreeSet}, fmt::Debug, marker::PhantomData, }; -pub use xcm::latest::prelude::*; +pub use xcm::prelude::*; pub use xcm_executor::{ traits::{ AssetExchange, AssetLock, ConvertOrigin, Enact, ExportXcm, FeeManager, FeeReason, @@ -105,26 +106,26 @@ impl GetDispatchInfo for TestCall { } thread_local! { - pub static SENT_XCM: RefCell)>> = RefCell::new(Vec::new()); - pub static EXPORTED_XCM: RefCell)>> = RefCell::new(Vec::new()); + pub static SENT_XCM: RefCell, XcmHash)>> = RefCell::new(Vec::new()); + pub static EXPORTED_XCM: RefCell, XcmHash)>> = RefCell::new(Vec::new()); pub static EXPORTER_OVERRIDE: RefCell) -> Result, - fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result<(), SendError>, + fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result, )>> = RefCell::new(None); pub static SEND_PRICE: RefCell = RefCell::new(MultiAssets::new()); } -pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm)> { +pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm, XcmHash)> { SENT_XCM.with(|q| (*q.borrow()).clone()) } pub fn set_send_price(p: impl Into) { SEND_PRICE.with(|l| l.replace(p.into().into())); } -pub fn exported_xcm() -> Vec<(NetworkId, u32, InteriorMultiLocation, opaque::Xcm)> { +pub fn exported_xcm() -> Vec<(NetworkId, u32, InteriorMultiLocation, opaque::Xcm, XcmHash)> { EXPORTED_XCM.with(|q| (*q.borrow()).clone()) } pub fn set_exporter_override( price: fn(NetworkId, u32, &InteriorMultiLocation, &Xcm<()>) -> Result, - deliver: fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result<(), SendError>, + deliver: fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result, ) { EXPORTER_OVERRIDE.with(|x| x.replace(Some((price, deliver)))); } @@ -134,28 +135,31 @@ pub fn clear_exporter_override() { } pub struct TestMessageSender; impl SendXcm for TestMessageSender { - type Ticket = (MultiLocation, Xcm<()>); + type Ticket = (MultiLocation, Xcm<()>, XcmHash); fn validate( dest: &mut Option, msg: &mut Option>, - ) -> SendResult<(MultiLocation, Xcm<()>)> { - let pair = (dest.take().unwrap(), msg.take().unwrap()); - Ok((pair, SEND_PRICE.with(|l| l.borrow().clone()))) + ) -> SendResult<(MultiLocation, Xcm<()>, XcmHash)> { + let msg = msg.take().unwrap(); + let hash = fake_message_hash(&msg); + let triplet = (dest.take().unwrap(), msg, hash); + Ok((triplet, SEND_PRICE.with(|l| l.borrow().clone()))) } - fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { - SENT_XCM.with(|q| q.borrow_mut().push(pair)); - Ok(()) + fn deliver(triplet: (MultiLocation, Xcm<()>, XcmHash)) -> Result { + let hash = triplet.2; + SENT_XCM.with(|q| q.borrow_mut().push(triplet)); + Ok(hash) } } pub struct TestMessageExporter; impl ExportXcm for TestMessageExporter { - type Ticket = (NetworkId, u32, InteriorMultiLocation, Xcm<()>); + type Ticket = (NetworkId, u32, InteriorMultiLocation, Xcm<()>, XcmHash); fn validate( network: NetworkId, channel: u32, dest: &mut Option, msg: &mut Option>, - ) -> SendResult<(NetworkId, u32, InteriorMultiLocation, Xcm<()>)> { + ) -> SendResult<(NetworkId, u32, InteriorMultiLocation, Xcm<()>, XcmHash)> { let (d, m) = (dest.take().unwrap(), msg.take().unwrap()); let r: Result = EXPORTER_OVERRIDE.with(|e| { if let Some((ref f, _)) = &*e.borrow() { @@ -164,8 +168,9 @@ impl ExportXcm for TestMessageExporter { Ok(MultiAssets::new()) } }); + let h = fake_message_hash(&m); match r { - Ok(price) => Ok(((network, channel, d, m), price)), + Ok(price) => Ok(((network, channel, d, m, h), price)), Err(e) => { *dest = Some(d); *msg = Some(m); @@ -173,14 +178,17 @@ impl ExportXcm for TestMessageExporter { }, } } - fn deliver(tuple: (NetworkId, u32, InteriorMultiLocation, Xcm<()>)) -> Result<(), SendError> { + fn deliver( + tuple: (NetworkId, u32, InteriorMultiLocation, Xcm<()>, XcmHash), + ) -> Result { EXPORTER_OVERRIDE.with(|e| { if let Some((_, ref f)) = &*e.borrow() { - let (network, channel, dest, msg) = tuple; + let (network, channel, dest, msg, _hash) = tuple; f(network, channel, dest, msg) } else { + let hash = tuple.4; EXPORTED_XCM.with(|q| q.borrow_mut().push(tuple)); - Ok(()) + Ok(hash) } }) } @@ -201,12 +209,20 @@ pub fn add_asset(who: impl Into, what: impl Into) { pub struct TestAssetTransactor; impl TransactAsset for TestAssetTransactor { - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> Result<(), XcmError> { + fn deposit_asset( + what: &MultiAsset, + who: &MultiLocation, + _context: &XcmContext, + ) -> Result<(), XcmError> { add_asset(who.clone(), what.clone()); Ok(()) } - fn withdraw_asset(what: &MultiAsset, who: &MultiLocation) -> Result { + fn withdraw_asset( + what: &MultiAsset, + who: &MultiLocation, + _maybe_context: Option<&XcmContext>, + ) -> Result { ASSETS.with(|a| { a.borrow_mut() .get_mut(who) @@ -330,6 +346,7 @@ impl OnResponse for TestResponseHandler { _querier: Option<&MultiLocation>, response: xcm::latest::Response, _max_weight: Weight, + _context: &XcmContext, ) -> Weight { QUERIES.with(|q| { q.borrow_mut().entry(query_id).and_modify(|v| { @@ -596,3 +613,7 @@ impl Config for TestConfig { pub fn fungible_multi_asset(location: MultiLocation, amount: u128) -> MultiAsset { (AssetId::from(location), Fungibility::Fungible(amount)).into() } + +pub fn fake_message_hash(message: &Xcm) -> XcmHash { + message.using_encoded(sp_io::hashing::blake2_256) +} diff --git a/xcm/xcm-builder/src/tests/origins.rs b/xcm/xcm-builder/src/tests/origins.rs index 93569d9d0fb1..9b75c4f98650 100644 --- a/xcm/xcm-builder/src/tests/origins.rs +++ b/xcm/xcm-builder/src/tests/origins.rs @@ -25,35 +25,29 @@ fn universal_origin_should_work() { // Parachain 2 may represent Polkadot to us add_universal_alias(Parachain(2), Polkadot); - let r = XcmExecutor::::execute_xcm( - Parachain(2), - Xcm(vec![ - UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, - ]), - 50, - ); + let message = Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(2), message, hash, 50); assert_eq!(r, Outcome::Incomplete(10, XcmError::InvalidLocation)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, - ]), - 50, - ); + let message = Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); - add_asset((Ancestor(2), GlobalConsensus(Kusama)), (Parent, 100u128)); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ - UniversalOrigin(GlobalConsensus(Kusama)), - TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, - ]), - 50, - ); + add_asset((Ancestor(2), GlobalConsensus(Kusama)), (Parent, 100)); + let message = Xcm(vec![ + UniversalOrigin(GlobalConsensus(Kusama)), + TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(20)); assert_eq!(asset_list((Ancestor(2), GlobalConsensus(Kusama))), vec![]); } @@ -64,15 +58,18 @@ fn export_message_should_work() { AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); // Local parachain #1 issues a transfer asset on Polkadot Relay-chain, transfering 100 Planck to // Polkadot parachain #2. - let message = Xcm(vec![TransferAsset { + let expected_message = Xcm(vec![TransferAsset { assets: (Here, 100u128).into(), beneficiary: Parachain(2).into(), }]); - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![ExportMessage { network: Polkadot, destination: Here, xcm: message.clone() }]), - 50, - ); + let expected_hash = fake_message_hash(&expected_message); + let message = Xcm(vec![ExportMessage { + network: Polkadot, + destination: Here, + xcm: expected_message.clone(), + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); - assert_eq!(exported_xcm(), vec![(Polkadot, 403611790, Here, message)]); + assert_eq!(exported_xcm(), vec![(Polkadot, 403611790, Here, expected_message, expected_hash)]); } diff --git a/xcm/xcm-builder/src/tests/querying.rs b/xcm/xcm-builder/src/tests/querying.rs index feb3259208ed..43b3235cbaca 100644 --- a/xcm/xcm-builder/src/tests/querying.rs +++ b/xcm/xcm-builder/src/tests/querying.rs @@ -21,32 +21,26 @@ fn pallet_query_should_work() { AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 // and let them know to hand it to account #3. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![QueryPallet { - module_name: "Error".into(), - response_info: QueryResponseInfo { - destination: Parachain(1).into(), - query_id: 1, - max_weight: 50, - }, - }]), - 50, - ); + let message = Xcm(vec![QueryPallet { + module_name: "Error".into(), + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: 1, + max_weight: 50, + }, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); - assert_eq!( - sent_xcm(), - vec![( - Parachain(1).into(), - Xcm::<()>(vec![QueryResponse { - query_id: 1, - max_weight: 50, - response: Response::PalletsInfo(vec![].try_into().unwrap()), - querier: Some(Here.into()), - }]), - )] - ); + let expected_msg = Xcm::<()>(vec![QueryResponse { + query_id: 1, + max_weight: 50, + response: Response::PalletsInfo(vec![].try_into().unwrap()), + querier: Some(Here.into()), + }]); + let expected_hash = fake_message_hash(&expected_msg); + assert_eq!(sent_xcm(), vec![(Parachain(1).into(), expected_msg, expected_hash)]); } #[test] @@ -54,44 +48,38 @@ fn pallet_query_with_results_should_work() { AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); // They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2 // and let them know to hand it to account #3. - let r = XcmExecutor::::execute_xcm( - Parachain(1), - Xcm(vec![QueryPallet { - module_name: "pallet_balances".into(), - response_info: QueryResponseInfo { - destination: Parachain(1).into(), - query_id: 1, - max_weight: 50, - }, - }]), - 50, - ); + let message = Xcm(vec![QueryPallet { + module_name: "pallet_balances".into(), + response_info: QueryResponseInfo { + destination: Parachain(1).into(), + query_id: 1, + max_weight: 50, + }, + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); - assert_eq!( - sent_xcm(), - vec![( - Parachain(1).into(), - Xcm::<()>(vec![QueryResponse { - query_id: 1, - max_weight: 50, - response: Response::PalletsInfo( - vec![PalletInfo::new( - 1, - b"Balances".as_ref().into(), - b"pallet_balances".as_ref().into(), - 1, - 42, - 69, - ) - .unwrap(),] - .try_into() - .unwrap() - ), - querier: Some(Here.into()), - }]), - )] - ); + let expected_msg = Xcm::<()>(vec![QueryResponse { + query_id: 1, + max_weight: 50, + response: Response::PalletsInfo( + vec![PalletInfo::new( + 1, + b"Balances".as_ref().into(), + b"pallet_balances".as_ref().into(), + 1, + 42, + 69, + ) + .unwrap()] + .try_into() + .unwrap(), + ), + querier: Some(Here.into()), + }]); + let expected_hash = fake_message_hash(&expected_msg); + assert_eq!(sent_xcm(), vec![(Parachain(1).into(), expected_msg, expected_hash)]); } #[test] @@ -107,14 +95,15 @@ fn prepaid_result_of_query_should_get_free_execution() { max_weight: 10, querier: Some(Here.into()), }]); + let hash = fake_message_hash(&message); let weight_limit = 10; // First time the response gets through since we're expecting it... - let r = XcmExecutor::::execute_xcm(Parent, message.clone(), weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message.clone(), hash, weight_limit); assert_eq!(r, Outcome::Complete(10)); assert_eq!(response(query_id).unwrap(), the_response); // Second time it doesn't, since we're not. - let r = XcmExecutor::::execute_xcm(Parent, message.clone(), weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message.clone(), hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); } diff --git a/xcm/xcm-builder/src/tests/transacting.rs b/xcm/xcm-builder/src/tests/transacting.rs index 009ba5ad96d1..4528cef2202b 100644 --- a/xcm/xcm-builder/src/tests/transacting.rs +++ b/xcm/xcm-builder/src/tests/transacting.rs @@ -25,8 +25,9 @@ fn transacting_should_work() { require_weight_at_most: 50, call: TestCall::Any(50, None).encode().into(), }]); + let hash = fake_message_hash(&message); let weight_limit = 60; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(60)); } @@ -39,8 +40,9 @@ fn transacting_should_respect_max_weight_requirement() { require_weight_at_most: 40, call: TestCall::Any(50, None).encode().into(), }]); + let hash = fake_message_hash(&message); let weight_limit = 60; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Incomplete(50, XcmError::MaxWeightInvalid)); } @@ -53,8 +55,9 @@ fn transacting_should_refund_weight() { require_weight_at_most: 50, call: TestCall::Any(50, Some(30)).encode().into(), }]); + let hash = fake_message_hash(&message); let weight_limit = 60; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(40)); } @@ -79,8 +82,9 @@ fn paid_transacting_should_refund_payment_for_unused_weight() { RefundSurplus, DepositAsset { assets: AllCounted(1).into(), beneficiary: one.clone() }, ]); + let hash = fake_message_hash(&message); let weight_limit = 100; - let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); + let r = XcmExecutor::::execute_xcm(origin, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(60)); assert_eq!( asset_list(AccountIndex64 { index: 1, network: None }), @@ -104,21 +108,18 @@ fn report_successful_transact_status_should_work() { max_weight: 5000, }), ]); + let hash = fake_message_hash(&message); let weight_limit = 70; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(70)); - assert_eq!( - sent_xcm(), - vec![( - Parent.into(), - Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Success), - query_id: 42, - max_weight: 5000, - querier: Some(Here.into()), - }]) - )] - ); + let expected_msg = Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Success), + query_id: 42, + max_weight: 5000, + querier: Some(Here.into()), + }]); + let expected_hash = fake_message_hash(&expected_msg); + assert_eq!(sent_xcm(), vec![(Parent.into(), expected_msg, expected_hash)]); } #[test] @@ -137,21 +138,18 @@ fn report_failed_transact_status_should_work() { max_weight: 5000, }), ]); + let hash = fake_message_hash(&message); let weight_limit = 70; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(70)); - assert_eq!( - sent_xcm(), - vec![( - Parent.into(), - Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), - query_id: 42, - max_weight: 5000, - querier: Some(Here.into()), - }]) - )] - ); + let expected_msg = Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), + query_id: 42, + max_weight: 5000, + querier: Some(Here.into()), + }]); + let expected_hash = fake_message_hash(&expected_msg); + assert_eq!(sent_xcm(), vec![(Parent.into(), expected_msg, expected_hash)]); } #[test] @@ -171,19 +169,16 @@ fn clear_transact_status_should_work() { max_weight: 5000, }), ]); + let hash = fake_message_hash(&message); let weight_limit = 80; - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(80)); - assert_eq!( - sent_xcm(), - vec![( - Parent.into(), - Xcm(vec![QueryResponse { - response: Response::DispatchResult(MaybeErrorCode::Success), - query_id: 42, - max_weight: 5000, - querier: Some(Here.into()), - }]) - )] - ); + let expected_msg = Xcm(vec![QueryResponse { + response: Response::DispatchResult(MaybeErrorCode::Success), + query_id: 42, + max_weight: 5000, + querier: Some(Here.into()), + }]); + let expected_hash = fake_message_hash(&expected_msg); + assert_eq!(sent_xcm(), vec![(Parent.into(), expected_msg, expected_hash)]); } diff --git a/xcm/xcm-builder/src/tests/version_subscriptions.rs b/xcm/xcm-builder/src/tests/version_subscriptions.rs index 2ecd12a05b4f..e7125e6e75a5 100644 --- a/xcm/xcm-builder/src/tests/version_subscriptions.rs +++ b/xcm/xcm-builder/src/tests/version_subscriptions.rs @@ -25,18 +25,20 @@ fn simple_version_subscriptions_should_work() { SetAppendix(Xcm(vec![])), SubscribeVersion { query_id: 42, max_response_weight: 5000 }, ]); + let hash = fake_message_hash(&message); let weight_limit = 20; - let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); + let r = XcmExecutor::::execute_xcm(origin, message, hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); let origin = Parachain(1000); let message = Xcm::(vec![SubscribeVersion { query_id: 42, max_response_weight: 5000 }]); + let hash = fake_message_hash(&message); let weight_limit = 10; - let r = XcmExecutor::::execute_xcm(origin, message.clone(), weight_limit); + let r = XcmExecutor::::execute_xcm(origin, message.clone(), hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(10)); assert_eq!(SubscriptionRequests::get(), vec![(Parent.into(), Some((42, 5000)))]); @@ -49,10 +51,12 @@ fn version_subscription_instruction_should_work() { DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), SubscribeVersion { query_id: 42, max_response_weight: 5000 }, ]); + let hash = fake_message_hash(&message); let weight_limit = 20; let r = XcmExecutor::::execute_xcm_in_credit( origin.clone(), - message.clone(), + message, + hash, weight_limit, weight_limit, ); @@ -62,9 +66,11 @@ fn version_subscription_instruction_should_work() { SetAppendix(Xcm(vec![])), SubscribeVersion { query_id: 42, max_response_weight: 5000 }, ]); + let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm_in_credit( origin, - message.clone(), + message, + hash, weight_limit, weight_limit, ); @@ -79,17 +85,19 @@ fn simple_version_unsubscriptions_should_work() { let origin = Parachain(1000); let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); + let hash = fake_message_hash(&message); let weight_limit = 20; - let r = XcmExecutor::::execute_xcm(origin, message, weight_limit); + let r = XcmExecutor::::execute_xcm(origin, message, hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); let origin = Parachain(1000); let message = Xcm::(vec![UnsubscribeVersion]); + let hash = fake_message_hash(&message); let weight_limit = 10; - let r = XcmExecutor::::execute_xcm(origin, message.clone(), weight_limit); + let r = XcmExecutor::::execute_xcm(origin, message.clone(), hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); - let r = XcmExecutor::::execute_xcm(Parent, message, weight_limit); + let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(10)); assert_eq!(SubscriptionRequests::get(), vec![(Parent.into(), None)]); @@ -105,10 +113,12 @@ fn version_unsubscription_instruction_should_work() { DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), UnsubscribeVersion, ]); + let hash = fake_message_hash(&message); let weight_limit = 20; let r = XcmExecutor::::execute_xcm_in_credit( origin.clone(), - message.clone(), + message, + hash, weight_limit, weight_limit, ); @@ -116,9 +126,11 @@ fn version_unsubscription_instruction_should_work() { // Fine to do it when origin is untouched. let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); + let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm_in_credit( origin, - message.clone(), + message, + hash, weight_limit, weight_limit, ); diff --git a/xcm/xcm-builder/src/tests/weight.rs b/xcm/xcm-builder/src/tests/weight.rs index f0a3aaf57a1b..c09c2420cda0 100644 --- a/xcm/xcm-builder/src/tests/weight.rs +++ b/xcm/xcm-builder/src/tests/weight.rs @@ -43,25 +43,27 @@ fn errors_should_return_unused_weight() { let limit = ::Weigher::weight(&mut message).unwrap(); assert_eq!(limit, 30); - let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); + let hash = fake_message_hash(&message); + + let r = XcmExecutor::::execute_xcm(Here, message.clone(), hash, limit); assert_eq!(r, Outcome::Complete(30)); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 7u128).into()]); assert_eq!(asset_list(Here), vec![(Here, 4u128).into()]); assert_eq!(sent_xcm(), vec![]); - let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); + let r = XcmExecutor::::execute_xcm(Here, message.clone(), hash, limit); assert_eq!(r, Outcome::Incomplete(30, XcmError::NotWithdrawable)); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 10u128).into()]); assert_eq!(asset_list(Here), vec![(Here, 1u128).into()]); assert_eq!(sent_xcm(), vec![]); - let r = XcmExecutor::::execute_xcm(Here, message.clone(), limit); + let r = XcmExecutor::::execute_xcm(Here, message.clone(), hash, limit); assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11u128).into()]); assert_eq!(asset_list(Here), vec![]); assert_eq!(sent_xcm(), vec![]); - let r = XcmExecutor::::execute_xcm(Here, message, limit); + let r = XcmExecutor::::execute_xcm(Here, message, hash, limit); assert_eq!(r, Outcome::Incomplete(10, XcmError::NotWithdrawable)); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11u128).into()]); assert_eq!(asset_list(Here), vec![]); diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index d88329a4128c..1e0869801812 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -84,7 +84,7 @@ impl> SendXcm validate_export::(network, 0, destination, message) } - fn deliver(ticket: Exporter::Ticket) -> Result<(), SendError> { + fn deliver(ticket: Exporter::Ticket) -> Result { Exporter::deliver(ticket) } } @@ -190,7 +190,7 @@ impl Ok((v, cost)) } - fn deliver(validation: Router::Ticket) -> Result<(), SendError> { + fn deliver(validation: Router::Ticket) -> Result { Router::deliver(validation) } } @@ -264,7 +264,7 @@ impl Ok((v, cost)) } - fn deliver(ticket: Router::Ticket) -> Result<(), SendError> { + fn deliver(ticket: Router::Ticket) -> Result { Router::deliver(ticket) } } @@ -331,14 +331,14 @@ pub struct HaulBlobExporter( impl, Price: Get> ExportXcm for HaulBlobExporter { - type Ticket = Vec; + type Ticket = (Vec, XcmHash); fn validate( network: NetworkId, _channel: u32, destination: &mut Option, message: &mut Option>, - ) -> Result<(Vec, MultiAssets), SendError> { + ) -> Result<((Vec, XcmHash), MultiAssets), SendError> { let bridged_network = BridgedNetwork::get(); ensure!(&network == &bridged_network, SendError::NotApplicable); // We don't/can't use the `channel` for this adapter. @@ -351,13 +351,14 @@ impl, Price: Get> }, }; let message = VersionedXcm::from(message.take().ok_or(SendError::MissingArgument)?); + let hash = message.using_encoded(sp_io::hashing::blake2_256); let blob = BridgeMessage { universal_dest, message }.encode(); - Ok((blob, Price::get())) + Ok(((blob, hash), Price::get())) } - fn deliver(blob: Vec) -> Result<(), SendError> { + fn deliver((blob, hash): (Vec, XcmHash)) -> Result { Bridge::haul_blob(blob); - Ok(()) + Ok(hash) } } diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index bc56e7dad0d3..3b782d99de66 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -19,6 +19,7 @@ use frame_support::{ traits::{Everything, Nothing}, weights::Weight, }; +use parity_scale_codec::Encode; use sp_core::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; use sp_std::cell::RefCell; @@ -40,24 +41,27 @@ pub type AccountId = AccountId32; pub type Balance = u128; thread_local! { - pub static SENT_XCM: RefCell> = RefCell::new(Vec::new()); + pub static SENT_XCM: RefCell> = RefCell::new(Vec::new()); } -pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm)> { +pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm, XcmHash)> { SENT_XCM.with(|q| (*q.borrow()).clone()) } pub struct TestSendXcm; impl SendXcm for TestSendXcm { - type Ticket = (MultiLocation, Xcm<()>); + type Ticket = (MultiLocation, Xcm<()>, XcmHash); fn validate( dest: &mut Option, msg: &mut Option>, - ) -> SendResult<(MultiLocation, Xcm<()>)> { - let pair = (dest.take().unwrap(), msg.take().unwrap()); - Ok((pair, MultiAssets::new())) + ) -> SendResult<(MultiLocation, Xcm<()>, XcmHash)> { + let msg = msg.take().unwrap(); + let hash = fake_message_hash(&msg); + let triplet = (dest.take().unwrap(), msg, hash); + Ok((triplet, MultiAssets::new())) } - fn deliver(pair: (MultiLocation, Xcm<()>)) -> Result<(), SendError> { - SENT_XCM.with(|q| q.borrow_mut().push(pair)); - Ok(()) + fn deliver(triplet: (MultiLocation, Xcm<()>, XcmHash)) -> Result { + let hash = triplet.2; + SENT_XCM.with(|q| q.borrow_mut().push(triplet)); + Ok(hash) } } @@ -245,3 +249,7 @@ pub fn kusama_like_with_balances(balances: Vec<(AccountId, Balance)>) -> sp_io:: ext.execute_with(|| System::set_block_number(1)); ext } + +pub fn fake_message_hash(message: &Xcm) -> XcmHash { + message.using_encoded(sp_io::hashing::blake2_256) +} diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index 6932c006546a..f2c708ab849b 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -17,7 +17,8 @@ mod mock; use mock::{ - kusama_like_with_balances, AccountId, Balance, Balances, BaseXcmWeight, XcmConfig, CENTS, + fake_message_hash, kusama_like_with_balances, AccountId, Balance, Balances, BaseXcmWeight, + XcmConfig, CENTS, }; use polkadot_parachain::primitives::Id as ParaId; use sp_runtime::traits::AccountIdConversion; @@ -46,18 +47,16 @@ fn withdraw_and_deposit_works() { let other_para_id = 3000; let amount = REGISTER_AMOUNT; let weight = 3 * BaseXcmWeight::get(); - let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID), - Xcm(vec![ - WithdrawAsset((Here, amount).into()), - buy_execution(), - DepositAsset { - assets: AllCounted(1).into(), - beneficiary: Parachain(other_para_id).into(), - }, - ]), - weight, - ); + let message = Xcm(vec![ + WithdrawAsset((Here, amount).into()), + buy_execution(), + DepositAsset { + assets: AllCounted(1).into(), + beneficiary: Parachain(other_para_id).into(), + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); let other_para_acc: AccountId = ParaId::from(other_para_id).into_account(); assert_eq!(Balances::free_balance(para_acc), INITIAL_BALANCE - amount); @@ -87,20 +86,18 @@ fn report_holding_works() { query_id: 1234, max_weight: 1_000_000_000, }; - let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID), - Xcm(vec![ - WithdrawAsset((Here, amount).into()), - buy_execution(), - DepositAsset { - assets: AllCounted(1).into(), - beneficiary: OnlyChild.into(), // invalid destination - }, - // is not triggered becasue the deposit fails - ReportHolding { response_info: response_info.clone(), assets: All.into() }, - ]), - weight, - ); + let message = Xcm(vec![ + WithdrawAsset((Here, amount).into()), + buy_execution(), + DepositAsset { + assets: AllCounted(1).into(), + beneficiary: OnlyChild.into(), // invalid destination + }, + // is not triggered becasue the deposit fails + ReportHolding { response_info: response_info.clone(), assets: All.into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, weight); assert_eq!( r, Outcome::Incomplete( @@ -113,38 +110,32 @@ fn report_holding_works() { assert_eq!(Balances::free_balance(para_acc.clone()), INITIAL_BALANCE - amount); // now do a successful transfer - let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID), - Xcm(vec![ - WithdrawAsset((Here, amount).into()), - buy_execution(), - DepositAsset { - assets: AllCounted(1).into(), - beneficiary: Parachain(other_para_id).into(), - }, - // used to get a notification in case of success - ReportHolding { - response_info: response_info.clone(), - assets: AllCounted(1).into(), - }, - ]), - weight, - ); + let message = Xcm(vec![ + WithdrawAsset((Here, amount).into()), + buy_execution(), + DepositAsset { + assets: AllCounted(1).into(), + beneficiary: Parachain(other_para_id).into(), + }, + // used to get a notification in case of success + ReportHolding { response_info: response_info.clone(), assets: AllCounted(1).into() }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); let other_para_acc: AccountId = ParaId::from(other_para_id).into_account(); assert_eq!(Balances::free_balance(other_para_acc), amount); assert_eq!(Balances::free_balance(para_acc), INITIAL_BALANCE - 2 * amount); + let expected_msg = Xcm(vec![QueryResponse { + query_id: response_info.query_id, + response: Response::Assets(vec![].into()), + max_weight: response_info.max_weight, + querier: Some(Here.into()), + }]); + let expected_hash = fake_message_hash(&expected_msg); assert_eq!( mock::sent_xcm(), - vec![( - Parachain(PARA_ID).into(), - Xcm(vec![QueryResponse { - query_id: response_info.query_id, - response: Response::Assets(vec![].into()), - max_weight: response_info.max_weight, - querier: Some(Here.into()), - }]), - )] + vec![(Parachain(PARA_ID).into(), expected_msg, expected_hash,)] ); }); } @@ -176,65 +167,53 @@ fn teleport_to_statemine_works() { let weight = 3 * BaseXcmWeight::get(); // teleports are allowed to community chains, even in the absence of trust from their side. - let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID), - Xcm(vec![ - WithdrawAsset((Here, amount).into()), - buy_execution(), - InitiateTeleport { - assets: All.into(), - dest: Parachain(other_para_id).into(), - xcm: Xcm(teleport_effects.clone()), - }, - ]), - weight, - ); + let message = Xcm(vec![ + WithdrawAsset((Here, amount).into()), + buy_execution(), + InitiateTeleport { + assets: All.into(), + dest: Parachain(other_para_id).into(), + xcm: Xcm(teleport_effects.clone()), + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); + let expected_msg = Xcm(vec![ReceiveTeleportedAsset((Parent, amount).into()), ClearOrigin] + .into_iter() + .chain(teleport_effects.clone().into_iter()) + .collect()); + let expected_hash = fake_message_hash(&expected_msg); assert_eq!( mock::sent_xcm(), - vec![( - Parachain(other_para_id).into(), - Xcm(vec![ReceiveTeleportedAsset((Parent, amount).into()), ClearOrigin,] - .into_iter() - .chain(teleport_effects.clone().into_iter()) - .collect()) - )] + vec![(Parachain(other_para_id).into(), expected_msg, expected_hash,)] ); // teleports are allowed from statemine to kusama. - let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID), - Xcm(vec![ - WithdrawAsset((Here, amount).into()), - buy_execution(), - InitiateTeleport { - assets: All.into(), - dest: Parachain(statemine_id).into(), - xcm: Xcm(teleport_effects.clone()), - }, - ]), - weight, - ); + let message = Xcm(vec![ + WithdrawAsset((Here, amount).into()), + buy_execution(), + InitiateTeleport { + assets: All.into(), + dest: Parachain(statemine_id).into(), + xcm: Xcm(teleport_effects.clone()), + }, + ]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); // 2 * amount because of the other teleport above assert_eq!(Balances::free_balance(para_acc), INITIAL_BALANCE - 2 * amount); + let expected_msg = Xcm(vec![ReceiveTeleportedAsset((Parent, amount).into()), ClearOrigin] + .into_iter() + .chain(teleport_effects.clone().into_iter()) + .collect()); + let expected_hash = fake_message_hash(&expected_msg); assert_eq!( mock::sent_xcm(), vec![ - ( - Parachain(other_para_id).into(), - Xcm(vec![ReceiveTeleportedAsset((Parent, amount).into()), ClearOrigin,] - .into_iter() - .chain(teleport_effects.clone().into_iter()) - .collect()), - ), - ( - Parachain(statemine_id).into(), - Xcm(vec![ReceiveTeleportedAsset((Parent, amount).into()), ClearOrigin,] - .into_iter() - .chain(teleport_effects.clone().into_iter()) - .collect()), - ) + (Parachain(other_para_id).into(), expected_msg.clone(), expected_hash,), + (Parachain(statemine_id).into(), expected_msg, expected_hash,) ] ); }); @@ -261,31 +240,28 @@ fn reserve_based_transfer_works() { beneficiary: (Parent, Parachain(PARA_ID)).into(), }, ]; + let message = Xcm(vec![ + WithdrawAsset((Here, amount).into()), + buy_execution(), + DepositReserveAsset { + assets: AllCounted(1).into(), + dest: Parachain(other_para_id).into(), + xcm: Xcm(transfer_effects.clone()), + }, + ]); + let hash = fake_message_hash(&message); let weight = 3 * BaseXcmWeight::get(); - let r = XcmExecutor::::execute_xcm( - Parachain(PARA_ID), - Xcm(vec![ - WithdrawAsset((Here, amount).into()), - buy_execution(), - DepositReserveAsset { - assets: AllCounted(1).into(), - dest: Parachain(other_para_id).into(), - xcm: Xcm(transfer_effects.clone()), - }, - ]), - weight, - ); + let r = XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); assert_eq!(Balances::free_balance(para_acc), INITIAL_BALANCE - amount); + let expected_msg = Xcm(vec![ReserveAssetDeposited((Parent, amount).into()), ClearOrigin] + .into_iter() + .chain(transfer_effects.into_iter()) + .collect()); + let expected_hash = fake_message_hash(&expected_msg); assert_eq!( mock::sent_xcm(), - vec![( - Parachain(other_para_id).into(), - Xcm(vec![ReserveAssetDeposited((Parent, amount).into()), ClearOrigin,] - .into_iter() - .chain(transfer_effects.into_iter()) - .collect()) - )] + vec![(Parachain(other_para_id).into(), expected_msg, expected_hash,)] ); }); } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index ec7f583128e9..9b765041e251 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -49,7 +49,7 @@ pub struct FeesMode { pub struct XcmExecutor { holding: Assets, holding_limit: usize, - origin: Option, + context: XcmContext, original_origin: MultiLocation, trader: Config::Trader, /// The most recent error result and instruction index into the fragment in which it occurred, @@ -67,6 +67,7 @@ pub struct XcmExecutor { appendix_weight: u64, transact_status: MaybeErrorCode, fees_mode: FeesMode, + topic: Option<[u8; 32]>, _config: PhantomData, } @@ -85,10 +86,10 @@ impl XcmExecutor { self.holding_limit = v } pub fn origin(&self) -> &Option { - &self.origin + &self.context.origin } pub fn set_origin(&mut self, v: Option) { - self.origin = v + self.context.origin = v } pub fn original_origin(&self) -> &MultiLocation { &self.original_origin @@ -156,6 +157,12 @@ impl XcmExecutor { pub fn set_fees_mode(&mut self, v: FeesMode) { self.fees_mode = v } + pub fn topic(&self) -> &Option<[u8; 32]> { + &self.topic + } + pub fn set_topic(&mut self, v: Option<[u8; 32]>) { + self.topic = v; + } } pub struct WeighedMessage(Weight, Xcm); @@ -176,6 +183,7 @@ impl ExecuteXcm for XcmExecutor { fn execute( origin: impl Into, WeighedMessage(xcm_weight, mut message): WeighedMessage, + message_hash: XcmHash, mut weight_credit: Weight, ) -> Outcome { let origin = origin.into(); @@ -203,10 +211,10 @@ impl ExecuteXcm for XcmExecutor { return Outcome::Error(XcmError::Barrier) } - let mut vm = Self::new(origin); + let mut vm = Self::new(origin, message_hash); while !message.0.is_empty() { - let result = vm.execute(message); + let result = vm.process(message); log::trace!(target: "xcm::execute_xcm_in_credit", "result: {:?}", result); message = if let Err(error) = result { vm.total_surplus.saturating_accrue(error.weight); @@ -218,14 +226,14 @@ impl ExecuteXcm for XcmExecutor { } } - vm.post_execute(xcm_weight) + vm.post_process(xcm_weight) } fn charge_fees(origin: impl Into, fees: MultiAssets) -> XcmResult { let origin = origin.into(); if !Config::FeeManager::is_waived(Some(&origin), FeeReason::ChargeFees) { for asset in fees.inner() { - Config::AssetTransactor::withdraw_asset(&asset, &origin)?; + Config::AssetTransactor::withdraw_asset(&asset, &origin, None)?; } Config::FeeManager::handle_fee(fees); } @@ -254,12 +262,12 @@ impl From for frame_benchmarking::BenchmarkError { } impl XcmExecutor { - pub fn new(origin: impl Into) -> Self { + pub fn new(origin: impl Into, message_hash: XcmHash) -> Self { let origin = origin.into(); Self { holding: Assets::new(), holding_limit: Config::MaxAssetsIntoHolding::get() as usize, - origin: Some(origin.clone()), + context: XcmContext { origin: Some(origin.clone()), message_hash, topic: None }, original_origin: origin, trader: Config::Trader::new(), error: None, @@ -271,17 +279,21 @@ impl XcmExecutor { appendix_weight: 0, transact_status: Default::default(), fees_mode: FeesMode { jit_withdraw: false }, + topic: None, _config: PhantomData, } } - /// Execute the XCM program fragment and report back the error and which instruction caused it, - /// or `Ok` if there was no error. - pub fn execute(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { + #[cfg(feature = "runtime-benchmarks")] + pub fn bench_process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { + self.process(xcm) + } + + fn process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { log::trace!( - target: "xcm::execute", + target: "xcm::process", "origin: {:?}, total_surplus/refunded: {:?}/{:?}, error_handler_weight: {:?}", - self.origin, + self.origin_ref(), self.total_surplus, self.total_refunded, self.error_handler_weight, @@ -305,7 +317,7 @@ impl XcmExecutor { /// Execute any final operations after having executed the XCM message. /// This includes refunding surplus weight, trapping extra holding funds, and returning any errors during execution. - pub fn post_execute(mut self, xcm_weight: Weight) -> Outcome { + pub fn post_process(mut self, xcm_weight: Weight) -> Outcome { // We silently drop any error from our attempt to refund the surplus as it's a charitable // thing so best-effort is all we will do. let _ = self.refund_surplus(); @@ -314,8 +326,13 @@ impl XcmExecutor { let mut weight_used = xcm_weight.saturating_sub(self.total_surplus); if !self.holding.is_empty() { - log::trace!(target: "xcm::execute_xcm_in_credit", "Trapping assets in holding register: {:?} (original_origin: {:?})", self.holding, self.original_origin); - let trap_weight = Config::AssetTrap::drop_assets(&self.original_origin, self.holding); + log::trace!( + target: "xcm::execute_xcm_in_credit", + "Trapping assets in holding register: {:?}, context: {:?} (original_origin: {:?})", + self.holding, self.context, self.original_origin, + ); + let trap_weight = + Config::AssetTrap::drop_assets(&self.original_origin, self.holding, &self.context); weight_used.saturating_accrue(trap_weight); }; @@ -330,20 +347,27 @@ impl XcmExecutor { } } + fn origin_ref(&self) -> Option<&MultiLocation> { + self.context.origin.as_ref() + } + + fn cloned_origin(&self) -> Option { + self.context.origin.clone() + } + /// Send an XCM, charging fees from Holding as needed. fn send( &mut self, dest: MultiLocation, msg: Xcm<()>, reason: FeeReason, - ) -> Result<(), XcmError> { + ) -> Result { let (ticket, fee) = validate_send::(dest, msg)?; - if !Config::FeeManager::is_waived(self.origin.as_ref(), reason) { + if !Config::FeeManager::is_waived(self.origin_ref(), reason) { let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; Config::FeeManager::handle_fee(paid.into()); } - Config::XcmSender::deliver(ticket)?; - Ok(()) + Config::XcmSender::deliver(ticket).map_err(Into::into) } /// Remove the registered error handler and return it. Do not refund its weight. @@ -409,16 +433,16 @@ impl XcmExecutor { match instr { WithdrawAsset(assets) => { // Take `assets` from the origin account (on-chain) and place in holding. - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); for asset in assets.into_inner().into_iter() { - Config::AssetTransactor::withdraw_asset(&asset, &origin)?; + Config::AssetTransactor::withdraw_asset(&asset, &origin, Some(&self.context))?; self.subsume_asset(asset)?; } Ok(()) }, ReserveAssetDeposited(assets) => { // check whether we trust origin to be our reserve location for this asset. - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); for asset in assets.into_inner().into_iter() { // Must ensure that we recognise the asset as being managed by the origin. ensure!( @@ -431,27 +455,34 @@ impl XcmExecutor { }, TransferAsset { assets, beneficiary } => { // Take `assets` from the origin account (on-chain) and place into dest account. - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; for asset in assets.inner() { - Config::AssetTransactor::beam_asset(&asset, origin, &beneficiary)?; + Config::AssetTransactor::beam_asset( + &asset, + origin, + &beneficiary, + &self.context, + )?; } Ok(()) }, TransferReserveAsset { mut assets, dest, xcm } => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; // Take `assets` from the origin account (on-chain) and place into dest account. for asset in assets.inner() { - Config::AssetTransactor::beam_asset(asset, origin, &dest)?; + Config::AssetTransactor::beam_asset(asset, origin, &dest, &self.context)?; } - let context = Config::LocationInverter::universal_location().into(); - assets.reanchor(&dest, &context).map_err(|()| XcmError::MultiLocationFull)?; + let reanchor_context = Config::LocationInverter::universal_location().into(); + assets + .reanchor(&dest, &reanchor_context) + .map_err(|()| XcmError::MultiLocationFull)?; let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); self.send(dest, Xcm(message), FeeReason::TransferReserveAsset)?; Ok(()) }, ReceiveTeleportedAsset(assets) => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); // check whether we trust origin to teleport this asset to us via config trait. for asset in assets.inner() { // We only trust the origin to send us assets that they identify as their @@ -463,17 +494,17 @@ impl XcmExecutor { // We should check that the asset can actually be teleported in (for this to be in error, there // would need to be an accounting violation by one of the trusted chains, so it's unlikely, but we // don't want to punish a possibly innocent chain/user). - Config::AssetTransactor::can_check_in(&origin, asset)?; + Config::AssetTransactor::can_check_in(&origin, asset, &self.context)?; } for asset in assets.into_inner().into_iter() { - Config::AssetTransactor::check_in(&origin, &asset); + Config::AssetTransactor::check_in(&origin, &asset, &self.context); self.subsume_asset(asset)?; } Ok(()) }, Transact { origin_kind, require_weight_at_most, mut call } => { // We assume that the Relay-chain is allowed to use transact on this parachain. - let origin = self.origin.clone().ok_or(XcmError::BadOrigin)?; + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); // TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain let message_call = call.take_decoded().map_err(|_| XcmError::FailedToDecode)?; @@ -505,47 +536,50 @@ impl XcmExecutor { Ok(()) }, QueryResponse { query_id, response, max_weight, querier } => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; Config::ResponseHandler::on_response( origin, query_id, querier.as_ref(), response, max_weight, + &self.context, ); Ok(()) }, DescendOrigin(who) => self + .context .origin .as_mut() .ok_or(XcmError::BadOrigin)? .append_with(who) .map_err(|_| XcmError::MultiLocationFull), ClearOrigin => { - self.origin = None; + self.context.origin = None; Ok(()) }, ReportError(response_info) => { // Report the given result by sending a QueryResponse XCM to a previously given outcome // destination if one was registered. self.respond( - self.origin.clone(), + self.cloned_origin(), Response::ExecutionResult(self.error), response_info, FeeReason::Report, - ) + )?; + Ok(()) }, DepositAsset { assets, beneficiary } => { let deposited = self.holding.saturating_take(assets); for asset in deposited.into_assets_iter() { - Config::AssetTransactor::deposit_asset(&asset, &beneficiary)?; + Config::AssetTransactor::deposit_asset(&asset, &beneficiary, &self.context)?; } Ok(()) }, DepositReserveAsset { assets, dest, xcm } => { let deposited = self.holding.saturating_take(assets); for asset in deposited.assets_iter() { - Config::AssetTransactor::deposit_asset(&asset, &dest)?; + Config::AssetTransactor::deposit_asset(&asset, &dest, &self.context)?; } // Note that we pass `None` as `maybe_failed_bin` and drop any assets which cannot // be reanchored because we have already called `deposit_asset` on all assets. @@ -572,7 +606,7 @@ impl XcmExecutor { // We must do this first in order to resolve wildcards. let assets = self.holding.saturating_take(assets); for asset in assets.assets_iter() { - Config::AssetTransactor::check_out(&dest, &asset); + Config::AssetTransactor::check_out(&dest, &asset, &self.context); } // Note that we pass `None` as `maybe_failed_bin` and drop any assets which cannot // be reanchored because we have already checked all assets out. @@ -588,11 +622,12 @@ impl XcmExecutor { let assets = Self::reanchored(self.holding.min(&assets), &response_info.destination, None); self.respond( - self.origin.clone(), + self.cloned_origin(), Response::Assets(assets), response_info, FeeReason::Report, - ) + )?; + Ok(()) }, BuyExecution { fees, weight_limit } => { // There is no need to buy any weight is `weight_limit` is `Unlimited` since it @@ -630,8 +665,8 @@ impl XcmExecutor { Ok(()) }, ClaimAsset { assets, ticket } => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; - let ok = Config::AssetClaims::claim_assets(origin, &ticket, &assets); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + let ok = Config::AssetClaims::claim_assets(origin, &ticket, &assets, &self.context); ensure!(ok, XcmError::UnknownClaim); for asset in assets.into_inner().into_iter() { self.subsume_asset(asset)?; @@ -640,16 +675,21 @@ impl XcmExecutor { }, Trap(code) => Err(XcmError::Trap(code)), SubscribeVersion { query_id, max_response_weight } => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; // We don't allow derivative origins to subscribe since it would otherwise pose a // DoS risk. - ensure!(self.original_origin == origin, XcmError::BadOrigin); - Config::SubscriptionService::start(&origin, query_id, max_response_weight) + ensure!(&self.original_origin == origin, XcmError::BadOrigin); + Config::SubscriptionService::start( + origin, + query_id, + max_response_weight, + &self.context, + ) }, UnsubscribeVersion => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; ensure!(&self.original_origin == origin, XcmError::BadOrigin); - Config::SubscriptionService::stop(origin) + Config::SubscriptionService::stop(origin, &self.context) }, BurnAsset(assets) => { self.holding.saturating_take(assets.into()); @@ -658,7 +698,7 @@ impl XcmExecutor { ExpectAsset(assets) => self.holding.ensure_contains(&assets).map_err(|_| XcmError::ExpectationFalse), ExpectOrigin(origin) => { - ensure!(self.origin == origin, XcmError::ExpectationFalse); + ensure!(self.context.origin == origin, XcmError::ExpectationFalse); Ok(()) }, ExpectError(error) => { @@ -682,7 +722,7 @@ impl XcmExecutor { .collect::, XcmError>>()?; let QueryResponseInfo { destination, query_id, max_weight } = response_info; let response = Response::PalletsInfo(pallets.try_into()?); - let querier = Self::to_querier(self.origin.clone(), &destination)?; + let querier = Self::to_querier(self.cloned_origin(), &destination)?; let instruction = QueryResponse { query_id, response, max_weight, querier }; let message = Xcm(vec![instruction]); self.send(destination, message, FeeReason::QueryPallet)?; @@ -701,12 +741,15 @@ impl XcmExecutor { ensure!(minor >= min_crate_minor, XcmError::VersionIncompatible); Ok(()) }, - ReportTransactStatus(response_info) => self.respond( - self.origin.clone(), - Response::DispatchResult(self.transact_status.clone()), - response_info, - FeeReason::Report, - ), + ReportTransactStatus(response_info) => { + self.respond( + self.cloned_origin(), + Response::DispatchResult(self.transact_status.clone()), + response_info, + FeeReason::Report, + )?; + Ok(()) + }, ClearTransactStatus => { self.transact_status = Default::default(); Ok(()) @@ -714,17 +757,17 @@ impl XcmExecutor { UniversalOrigin(new_global) => { let universal_location = Config::LocationInverter::universal_location(); ensure!(universal_location.first() != Some(&new_global), XcmError::InvalidLocation); - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); let origin_xform = (origin, new_global); let ok = Config::UniversalAliases::contains(&origin_xform); ensure!(ok, XcmError::InvalidLocation); let (_, new_global) = origin_xform; let new_origin = X1(new_global).relative_to(&universal_location); - self.origin = Some(new_origin); + self.context.origin = Some(new_origin); Ok(()) }, ExportMessage { network, destination, xcm } => { - let hash = (&self.origin, &destination).using_encoded(blake2_128); + let hash = (self.origin_ref(), &destination).using_encoded(blake2_128); let channel = u32::decode(&mut hash.as_ref()).unwrap_or(0); // Hash identifies the lane on the exporter which we use. We use the pairwise // combination of the origin and destination to ensure origin/destination pairs will @@ -736,7 +779,7 @@ impl XcmExecutor { Ok(()) }, LockAsset { asset, unlocker } => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); let (remote_asset, context) = Self::try_reanchor(asset.clone(), &unlocker)?; let lock_ticket = Config::AssetLocker::prepare_lock(unlocker.clone(), asset, origin.clone())?; @@ -750,17 +793,17 @@ impl XcmExecutor { Ok(()) }, UnlockAsset { asset, target } => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); Config::AssetLocker::prepare_unlock(origin.clone(), asset, target)?.enact()?; Ok(()) }, NoteUnlockable { asset, owner } => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); Config::AssetLocker::note_unlockable(origin, asset, owner)?; Ok(()) }, RequestUnlock { asset, locker } => { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); let remote_asset = Self::try_reanchor(asset.clone(), &locker)?.0; let reduce_ticket = Config::AssetLocker::prepare_reduce_unlockable( locker.clone(), @@ -776,9 +819,9 @@ impl XcmExecutor { Ok(()) }, ExchangeAsset { give, want, maximal } => { - let origin = self.origin.as_ref(); let give = self.holding.saturating_take(give); - let r = Config::AssetExchanger::exchange_asset(origin, give, &want, maximal); + let r = + Config::AssetExchanger::exchange_asset(self.origin_ref(), give, &want, maximal); let completed = r.is_ok(); let received = r.unwrap_or_else(|a| a); for asset in received.into_assets_iter() { @@ -794,6 +837,14 @@ impl XcmExecutor { self.fees_mode = FeesMode { jit_withdraw }; Ok(()) }, + SetTopic(topic) => { + self.topic = Some(topic); + Ok(()) + }, + ClearTopic => { + self.topic = None; + Ok(()) + }, HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), HrmpChannelClosing { .. } => Err(XcmError::Unimplemented), @@ -801,13 +852,13 @@ impl XcmExecutor { } fn take_fee(&mut self, fee: MultiAssets, reason: FeeReason) -> XcmResult { - if Config::FeeManager::is_waived(self.origin.as_ref(), reason) { + if Config::FeeManager::is_waived(self.origin_ref(), reason) { return Ok(()) } let paid = if self.fees_mode.jit_withdraw { - let origin = self.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; for asset in fee.inner() { - Config::AssetTransactor::withdraw_asset(&asset, origin)?; + Config::AssetTransactor::withdraw_asset(&asset, origin, Some(&self.context))?; } fee } else { @@ -840,29 +891,28 @@ impl XcmExecutor { response: Response, info: QueryResponseInfo, fee_reason: FeeReason, - ) -> Result<(), XcmError> { + ) -> Result { let querier = Self::to_querier(local_querier, &info.destination)?; let QueryResponseInfo { destination, query_id, max_weight } = info; let instruction = QueryResponse { query_id, response, max_weight, querier }; let message = Xcm(vec![instruction]); let (ticket, fee) = validate_send::(destination, message)?; - if !Config::FeeManager::is_waived(self.origin.as_ref(), fee_reason) { + if !Config::FeeManager::is_waived(self.origin_ref(), fee_reason) { let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; Config::FeeManager::handle_fee(paid.into()); } - Config::XcmSender::deliver(ticket)?; - Ok(()) + Config::XcmSender::deliver(ticket).map_err(Into::into) } fn try_reanchor( asset: MultiAsset, destination: &MultiLocation, ) -> Result<(MultiAsset, MultiLocation), XcmError> { - let context = Config::LocationInverter::universal_location().into(); + let reanchor_context = Config::LocationInverter::universal_location().into(); let asset = asset - .reanchored(&destination, &context) + .reanchored(&destination, &reanchor_context) .map_err(|()| XcmError::ReanchorFailed)?; - Ok((asset, context)) + Ok((asset, reanchor_context)) } /// NOTE: Any assets which were unable to be reanchored are introduced into `failed_bin`. @@ -871,8 +921,8 @@ impl XcmExecutor { dest: &MultiLocation, maybe_failed_bin: Option<&mut Assets>, ) -> MultiAssets { - let context = Config::LocationInverter::universal_location().into(); - assets.reanchor(dest, &context, maybe_failed_bin); + let reanchor_context = Config::LocationInverter::universal_location().into(); + assets.reanchor(dest, &reanchor_context, maybe_failed_bin); assets.into_assets_iter().collect::>().into() } } diff --git a/xcm/xcm-executor/src/traits/drop_assets.rs b/xcm/xcm-executor/src/traits/drop_assets.rs index 5f82c5feb74b..45eefc9fba4e 100644 --- a/xcm/xcm-executor/src/traits/drop_assets.rs +++ b/xcm/xcm-executor/src/traits/drop_assets.rs @@ -17,15 +17,15 @@ use crate::Assets; use core::marker::PhantomData; use frame_support::{traits::Contains, weights::Weight}; -use xcm::latest::{MultiAssets, MultiLocation}; +use xcm::latest::{MultiAssets, MultiLocation, XcmContext}; /// Define a handler for when some non-empty `Assets` value should be dropped. pub trait DropAssets { /// Handler for receiving dropped assets. Returns the weight consumed by this operation. - fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight; + fn drop_assets(origin: &MultiLocation, assets: Assets, context: &XcmContext) -> Weight; } impl DropAssets for () { - fn drop_assets(_origin: &MultiLocation, _assets: Assets) -> Weight { + fn drop_assets(_origin: &MultiLocation, _assets: Assets, _context: &XcmContext) -> Weight { 0 } } @@ -35,9 +35,9 @@ impl DropAssets for () { pub struct FilterAssets(PhantomData<(D, A)>); impl> DropAssets for FilterAssets { - fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight { + fn drop_assets(origin: &MultiLocation, assets: Assets, context: &XcmContext) -> Weight { if A::contains(&assets) { - D::drop_assets(origin, assets) + D::drop_assets(origin, assets, context) } else { 0 } @@ -50,9 +50,9 @@ impl> DropAssets for FilterAssets { pub struct FilterOrigin(PhantomData<(D, O)>); impl> DropAssets for FilterOrigin { - fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight { + fn drop_assets(origin: &MultiLocation, assets: Assets, context: &XcmContext) -> Weight { if O::contains(origin) { - D::drop_assets(origin, assets) + D::drop_assets(origin, assets, context) } else { 0 } @@ -63,14 +63,24 @@ impl> DropAssets for FilterOrigin bool; + fn claim_assets( + origin: &MultiLocation, + ticket: &MultiLocation, + what: &MultiAssets, + context: &XcmContext, + ) -> bool; } #[impl_trait_for_tuples::impl_for_tuples(30)] impl ClaimAssets for Tuple { - fn claim_assets(origin: &MultiLocation, ticket: &MultiLocation, what: &MultiAssets) -> bool { + fn claim_assets( + origin: &MultiLocation, + ticket: &MultiLocation, + what: &MultiAssets, + context: &XcmContext, + ) -> bool { for_tuples!( #( - if Tuple::claim_assets(origin, ticket, what) { + if Tuple::claim_assets(origin, ticket, what, context) { return true; } )* ); diff --git a/xcm/xcm-executor/src/traits/export.rs b/xcm/xcm-executor/src/traits/export.rs index 65823b8b3c14..4b4169ddc16d 100644 --- a/xcm/xcm-executor/src/traits/export.rs +++ b/xcm/xcm-executor/src/traits/export.rs @@ -41,7 +41,7 @@ pub trait ExportXcm { /// The implementation should do everything possible to ensure that this function is infallible /// if called immediately after `validate`. Returning an error here would result in a price /// paid without the service being delivered. - fn deliver(ticket: Self::Ticket) -> Result<(), SendError>; + fn deliver(ticket: Self::Ticket) -> Result; } #[impl_trait_for_tuples::impl_for_tuples(30)] @@ -76,7 +76,7 @@ impl ExportXcm for Tuple { } } - fn deliver(one_ticket: Self::Ticket) -> Result<(), SendError> { + fn deliver(one_ticket: Self::Ticket) -> Result { for_tuples!( #( if let Some(validated) = one_ticket.Tuple.take() { return Tuple::deliver(validated); @@ -110,8 +110,8 @@ pub fn export_xcm( channel: u32, dest: InteriorMultiLocation, msg: Xcm<()>, -) -> Result { - let (ticket, price) = T::validate(network, channel, &mut Some(dest), &mut Some(msg))?; - T::deliver(ticket)?; - Ok(price) +) -> Result<(XcmHash, MultiAssets), SendError> { + let (ticket, price) = T::validate(network, channel, &mut Some(dest), &mut Some(msg.clone()))?; + let hash = T::deliver(ticket)?; + Ok((hash, price)) } diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index 016976453511..2720dfd6ce5a 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -15,7 +15,9 @@ // along with Polkadot. If not, see . use frame_support::weights::Weight; -use xcm::latest::{Error as XcmError, MultiLocation, QueryId, Response, Result as XcmResult}; +use xcm::latest::{ + Error as XcmError, MultiLocation, QueryId, Response, Result as XcmResult, XcmContext, +}; /// Define what needs to be done upon receiving a query response. pub trait OnResponse { @@ -34,6 +36,7 @@ pub trait OnResponse { querier: Option<&MultiLocation>, response: Response, max_weight: Weight, + context: &XcmContext, ) -> Weight; } impl OnResponse for () { @@ -50,6 +53,7 @@ impl OnResponse for () { _querier: Option<&MultiLocation>, _response: Response, _max_weight: Weight, + _context: &XcmContext, ) -> Weight { 0 } @@ -65,21 +69,26 @@ pub trait VersionChangeNotifier { /// /// If the `location` has an ongoing notification and when this function is called, then an /// error should be returned. - fn start(location: &MultiLocation, query_id: QueryId, max_weight: u64) -> XcmResult; + fn start( + location: &MultiLocation, + query_id: QueryId, + max_weight: u64, + context: &XcmContext, + ) -> XcmResult; /// Stop notifying `location` should the XCM change. Returns an error if there is no existing /// notification set up. - fn stop(location: &MultiLocation) -> XcmResult; + fn stop(location: &MultiLocation, context: &XcmContext) -> XcmResult; /// Return true if a location is subscribed to XCM version changes. fn is_subscribed(location: &MultiLocation) -> bool; } impl VersionChangeNotifier for () { - fn start(_: &MultiLocation, _: QueryId, _: u64) -> XcmResult { + fn start(_: &MultiLocation, _: QueryId, _: u64, _: &XcmContext) -> XcmResult { Err(XcmError::Unimplemented) } - fn stop(_: &MultiLocation) -> XcmResult { + fn stop(_: &MultiLocation, _: &XcmContext) -> XcmResult { Err(XcmError::Unimplemented) } fn is_subscribed(_: &MultiLocation) -> bool { diff --git a/xcm/xcm-executor/src/traits/transact_asset.rs b/xcm/xcm-executor/src/traits/transact_asset.rs index 7a933275a45a..49cf2f43fff8 100644 --- a/xcm/xcm-executor/src/traits/transact_asset.rs +++ b/xcm/xcm-executor/src/traits/transact_asset.rs @@ -16,7 +16,7 @@ use crate::Assets; use sp_std::result::Result; -use xcm::latest::{Error as XcmError, MultiAsset, MultiLocation, Result as XcmResult}; +use xcm::latest::{Error as XcmError, MultiAsset, MultiLocation, Result as XcmResult, XcmContext}; /// Facility for asset transacting. /// @@ -29,7 +29,11 @@ pub trait TransactAsset { /// Ensure that `check_in` will result in `Ok`. /// /// When composed as a tuple, all type-items are called and at least one must result in `Ok`. - fn can_check_in(_origin: &MultiLocation, _what: &MultiAsset) -> XcmResult { + fn can_check_in( + _origin: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { Err(XcmError::Unimplemented) } @@ -46,7 +50,7 @@ pub trait TransactAsset { /// /// When composed as a tuple, all type-items are called. It is up to the implementer that there exists no /// value for `_what` which can cause side-effects for more than one of the type-items. - fn check_in(_origin: &MultiLocation, _what: &MultiAsset) {} + fn check_in(_origin: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {} /// An asset has been teleported out to the given destination. This should do whatever housekeeping is needed. /// @@ -58,20 +62,28 @@ pub trait TransactAsset { /// /// When composed as a tuple, all type-items are called. It is up to the implementer that there exists no /// value for `_what` which can cause side-effects for more than one of the type-items. - fn check_out(_dest: &MultiLocation, _what: &MultiAsset) {} + fn check_out(_dest: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {} /// Deposit the `what` asset into the account of `who`. /// /// Implementations should return `XcmError::FailedToTransactAsset` if deposit failed. - fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation) -> XcmResult { + fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation, _context: &XcmContext) -> XcmResult { Err(XcmError::Unimplemented) } /// Withdraw the given asset from the consensus system. Return the actual asset(s) withdrawn, /// which should always be equal to `_what`. /// + /// The XCM `_maybe_context` parameter may be `None` when the caller of `withdraw_asset` is + /// outside of the context of a currently-executing XCM. An example will be the `charge_fees` + /// method in the XCM executor. + /// /// Implementations should return `XcmError::FailedToTransactAsset` if withdraw failed. - fn withdraw_asset(_what: &MultiAsset, _who: &MultiLocation) -> Result { + fn withdraw_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _maybe_context: Option<&XcmContext>, + ) -> Result { Err(XcmError::Unimplemented) } @@ -82,6 +94,7 @@ pub trait TransactAsset { _asset: &MultiAsset, _from: &MultiLocation, _to: &MultiLocation, + _context: &XcmContext, ) -> Result { Err(XcmError::Unimplemented) } @@ -93,12 +106,13 @@ pub trait TransactAsset { asset: &MultiAsset, from: &MultiLocation, to: &MultiLocation, + context: &XcmContext, ) -> Result { - match Self::transfer_asset(asset, from, to) { + match Self::transfer_asset(asset, from, to, context) { Err(XcmError::AssetNotFound | XcmError::Unimplemented) => { - let assets = Self::withdraw_asset(asset, from)?; + let assets = Self::withdraw_asset(asset, from, Some(context))?; // Not a very forgiving attitude; once we implement roll-backs then it'll be nicer. - Self::deposit_asset(asset, to)?; + Self::deposit_asset(asset, to, context)?; Ok(assets) }, result => result, @@ -108,62 +122,69 @@ pub trait TransactAsset { #[impl_trait_for_tuples::impl_for_tuples(30)] impl TransactAsset for Tuple { - fn can_check_in(origin: &MultiLocation, what: &MultiAsset) -> XcmResult { + fn can_check_in(origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult { for_tuples!( #( - match Tuple::can_check_in(origin, what) { + match Tuple::can_check_in(origin, what, context) { Err(XcmError::AssetNotFound) | Err(XcmError::Unimplemented) => (), r => return r, } )* ); log::trace!( target: "xcm::TransactAsset::can_check_in", - "asset not found: what: {:?}, origin: {:?}", + "asset not found: what: {:?}, origin: {:?}, context: {:?}", what, origin, + context, ); Err(XcmError::AssetNotFound) } - fn check_in(origin: &MultiLocation, what: &MultiAsset) { + fn check_in(origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) { for_tuples!( #( - Tuple::check_in(origin, what); + Tuple::check_in(origin, what, context); )* ); } - fn check_out(dest: &MultiLocation, what: &MultiAsset) { + fn check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) { for_tuples!( #( - Tuple::check_out(dest, what); + Tuple::check_out(dest, what, context); )* ); } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult { + fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { for_tuples!( #( - match Tuple::deposit_asset(what, who) { + match Tuple::deposit_asset(what, who, context) { Err(XcmError::AssetNotFound) | Err(XcmError::Unimplemented) => (), r => return r, } )* ); log::trace!( target: "xcm::TransactAsset::deposit_asset", - "did not deposit asset: what: {:?}, who: {:?}", + "did not deposit asset: what: {:?}, who: {:?}, context: {:?}", what, who, + context, ); Err(XcmError::AssetNotFound) } - fn withdraw_asset(what: &MultiAsset, who: &MultiLocation) -> Result { + fn withdraw_asset( + what: &MultiAsset, + who: &MultiLocation, + maybe_context: Option<&XcmContext>, + ) -> Result { for_tuples!( #( - match Tuple::withdraw_asset(what, who) { + match Tuple::withdraw_asset(what, who, maybe_context) { Err(XcmError::AssetNotFound) | Err(XcmError::Unimplemented) => (), r => return r, } )* ); log::trace!( target: "xcm::TransactAsset::withdraw_asset", - "did not withdraw asset: what: {:?}, who: {:?}", + "did not withdraw asset: what: {:?}, who: {:?}, maybe_context: {:?}", what, who, + maybe_context, ); Err(XcmError::AssetNotFound) } @@ -172,19 +193,21 @@ impl TransactAsset for Tuple { what: &MultiAsset, from: &MultiLocation, to: &MultiLocation, + context: &XcmContext, ) -> Result { for_tuples!( #( - match Tuple::transfer_asset(what, from, to) { + match Tuple::transfer_asset(what, from, to, context) { Err(XcmError::AssetNotFound) | Err(XcmError::Unimplemented) => (), r => return r, } )* ); log::trace!( target: "xcm::TransactAsset::transfer_asset", - "did not transfer asset: what: {:?}, from: {:?}, to: {:?}", + "did not transfer asset: what: {:?}, from: {:?}, to: {:?}, context: {:?}", what, from, to, + context, ); Err(XcmError::AssetNotFound) } @@ -200,15 +223,27 @@ mod tests { pub struct NotFoundTransactor; impl TransactAsset for NotFoundTransactor { - fn can_check_in(_origin: &MultiLocation, _what: &MultiAsset) -> XcmResult { + fn can_check_in( + _origin: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { Err(XcmError::AssetNotFound) } - fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation) -> XcmResult { + fn deposit_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: &XcmContext, + ) -> XcmResult { Err(XcmError::AssetNotFound) } - fn withdraw_asset(_what: &MultiAsset, _who: &MultiLocation) -> Result { + fn withdraw_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: Option<&XcmContext>, + ) -> Result { Err(XcmError::AssetNotFound) } @@ -216,6 +251,7 @@ mod tests { _what: &MultiAsset, _from: &MultiLocation, _to: &MultiLocation, + _context: &XcmContext, ) -> Result { Err(XcmError::AssetNotFound) } @@ -223,15 +259,27 @@ mod tests { pub struct OverflowTransactor; impl TransactAsset for OverflowTransactor { - fn can_check_in(_origin: &MultiLocation, _what: &MultiAsset) -> XcmResult { + fn can_check_in( + _origin: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { Err(XcmError::Overflow) } - fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation) -> XcmResult { + fn deposit_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: &XcmContext, + ) -> XcmResult { Err(XcmError::Overflow) } - fn withdraw_asset(_what: &MultiAsset, _who: &MultiLocation) -> Result { + fn withdraw_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: Option<&XcmContext>, + ) -> Result { Err(XcmError::Overflow) } @@ -239,6 +287,7 @@ mod tests { _what: &MultiAsset, _from: &MultiLocation, _to: &MultiLocation, + _context: &XcmContext, ) -> Result { Err(XcmError::Overflow) } @@ -246,15 +295,27 @@ mod tests { pub struct SuccessfulTransactor; impl TransactAsset for SuccessfulTransactor { - fn can_check_in(_origin: &MultiLocation, _what: &MultiAsset) -> XcmResult { + fn can_check_in( + _origin: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { Ok(()) } - fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation) -> XcmResult { + fn deposit_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: &XcmContext, + ) -> XcmResult { Ok(()) } - fn withdraw_asset(_what: &MultiAsset, _who: &MultiLocation) -> Result { + fn withdraw_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: Option<&XcmContext>, + ) -> Result { Ok(Assets::default()) } @@ -262,6 +323,7 @@ mod tests { _what: &MultiAsset, _from: &MultiLocation, _to: &MultiLocation, + _context: &XcmContext, ) -> Result { Ok(Assets::default()) } @@ -273,7 +335,11 @@ mod tests { (UnimplementedTransactor, NotFoundTransactor, UnimplementedTransactor); assert_eq!( - MultiTransactor::deposit_asset(&(Here, 1u128).into(), &Here.into()), + MultiTransactor::deposit_asset( + &(Here, 1u128).into(), + &Here.into(), + &XcmContext::with_message_hash([0; 32]), + ), Err(XcmError::AssetNotFound) ); } @@ -282,7 +348,14 @@ mod tests { fn unimplemented_and_not_found_continue_iteration() { type MultiTransactor = (UnimplementedTransactor, NotFoundTransactor, SuccessfulTransactor); - assert_eq!(MultiTransactor::deposit_asset(&(Here, 1u128).into(), &Here.into()), Ok(()),); + assert_eq!( + MultiTransactor::deposit_asset( + &(Here, 1u128).into(), + &Here.into(), + &XcmContext::with_message_hash([0; 32]), + ), + Ok(()) + ); } #[test] @@ -290,7 +363,11 @@ mod tests { type MultiTransactor = (OverflowTransactor, SuccessfulTransactor); assert_eq!( - MultiTransactor::deposit_asset(&(Here, 1u128).into(), &Here.into()), + MultiTransactor::deposit_asset( + &(Here, 1u128).into(), + &Here.into(), + &XcmContext::with_message_hash([0; 32]), + ), Err(XcmError::Overflow) ); } @@ -299,6 +376,13 @@ mod tests { fn success_stops_iteration() { type MultiTransactor = (SuccessfulTransactor, OverflowTransactor); - assert_eq!(MultiTransactor::deposit_asset(&(Here, 1u128).into(), &Here.into()), Ok(()),); + assert_eq!( + MultiTransactor::deposit_asset( + &(Here, 1u128).into(), + &Here.into(), + &XcmContext::with_message_hash([0; 32]), + ), + Ok(()), + ); } } diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index ac322dddb499..8c5474a31e84 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -309,10 +309,11 @@ pub mod mock_msg_queue { max_weight: Weight, ) -> Result { let hash = Encode::using_encoded(&xcm, T::Hashing::hash); + let message_hash = Encode::using_encoded(&xcm, sp_io::hashing::blake2_256); let (result, event) = match Xcm::::try_from(xcm) { Ok(xcm) => { let location = (Parent, Parachain(sender.into())); - match T::XcmExecutor::execute_xcm(location, xcm, max_weight) { + match T::XcmExecutor::execute_xcm(location, xcm, message_hash, max_weight) { Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), // As far as the caller is concerned, this was dispatched without error, so @@ -357,19 +358,18 @@ pub mod mock_msg_queue { ) -> Weight { for (_i, (_sent_at, data)) in iter.enumerate() { let id = sp_io::hashing::blake2_256(&data[..]); - let maybe_msg = - VersionedXcm::::decode(&mut &data[..]).map(Xcm::::try_from); - match maybe_msg { + let maybe_versioned = VersionedXcm::::decode(&mut &data[..]); + match maybe_versioned { Err(_) => { Self::deposit_event(Event::InvalidFormat(id)); }, - Ok(Err(())) => { - Self::deposit_event(Event::UnsupportedVersion(id)); - }, - Ok(Ok(x)) => { - let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), limit); - >::append(x); - Self::deposit_event(Event::ExecutedDownward(id, outcome)); + Ok(versioned) => match Xcm::try_from(versioned) { + Err(()) => Self::deposit_event(Event::UnsupportedVersion(id)), + Ok(x) => { + let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit); + >::append(x); + Self::deposit_event(Event::ExecutedDownward(id, outcome)); + }, }, } } diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index ef9958ecd522..ebecc61d40c7 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -227,10 +227,11 @@ pub mod mock_msg_queue { max_weight: Weight, ) -> Result { let hash = Encode::using_encoded(&xcm, T::Hashing::hash); + let message_hash = xcm.using_encoded(sp_io::hashing::blake2_256); let (result, event) = match Xcm::::try_from(xcm) { Ok(xcm) => { let location = MultiLocation::new(1, X1(Parachain(sender.into()))); - match T::XcmExecutor::execute_xcm(location, xcm, max_weight) { + match T::XcmExecutor::execute_xcm(location, xcm, message_hash, max_weight) { Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), // As far as the caller is concerned, this was dispatched without error, so @@ -285,7 +286,7 @@ pub mod mock_msg_queue { Self::deposit_event(Event::UnsupportedVersion(id)); }, Ok(Ok(x)) => { - let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), limit); + let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit); >::append(x); Self::deposit_event(Event::ExecutedDownward(id, outcome)); }, diff --git a/xcm/xcm-simulator/src/lib.rs b/xcm/xcm-simulator/src/lib.rs index 05effd284ec3..6a60eecb71d4 100644 --- a/xcm/xcm-simulator/src/lib.rs +++ b/xcm/xcm-simulator/src/lib.rs @@ -20,7 +20,7 @@ pub use codec::Encode; pub use paste; pub use frame_support::{traits::Get, weights::Weight}; -pub use sp_io::TestExternalities; +pub use sp_io::{hashing::blake2_256, TestExternalities}; pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, marker::PhantomData}; pub use polkadot_core_primitives::BlockNumber as RelayBlockNumber; @@ -76,6 +76,10 @@ pub fn encode_xcm(message: Xcm<()>, message_kind: MessageKind) -> Vec { } } +pub fn fake_message_hash(message: &Xcm) -> XcmHash { + message.using_encoded(blake2_256) +} + #[macro_export] #[rustfmt::skip] macro_rules! decl_test_relay_chain { @@ -210,6 +214,7 @@ macro_rules! decl_test_network { parachains = vec![ $( ($para_id:expr, $parachain:ty), )* ], } ) => { + use $crate::Encode; pub struct $name; impl $name { @@ -319,9 +324,10 @@ macro_rules! decl_test_network { } fn deliver( triple: ($crate::ParaId, $crate::MultiLocation, $crate::Xcm<()>), - ) -> Result<(), $crate::SendError> { + ) -> Result<$crate::XcmHash, $crate::SendError> { + let hash = $crate::fake_message_hash(&triple.2); $crate::PARA_MESSAGE_BUS.with(|b| b.borrow_mut().push_back(triple)); - Ok(()) + Ok(hash) } } @@ -350,9 +356,10 @@ macro_rules! decl_test_network { } fn deliver( pair: ($crate::MultiLocation, $crate::Xcm<()>), - ) -> Result<(), $crate::SendError> { + ) -> Result<$crate::XcmHash, $crate::SendError> { + let hash = $crate::fake_message_hash(&pair.1); $crate::RELAY_MESSAGE_BUS.with(|b| b.borrow_mut().push_back(pair)); - Ok(()) + Ok(hash) } } }; From 3026e8984d1330483f2f0a1afa7fe989a3364386 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 9 Mar 2022 01:42:33 -0800 Subject: [PATCH 068/231] Fixes --- xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 13da0e50f47d..91a7195746cc 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -141,13 +141,13 @@ benchmarks_instance_pallet! { let instruction = Instruction::ReserveAssetDeposited(assets.clone()); let xcm = Xcm(vec![instruction]); }: { - executor.execute(xcm).map_err(|_| { + executor.bench_process(xcm).map_err(|_| { BenchmarkError::Override( BenchmarkResult::from_weight(T::BlockWeights::get().max_block) ) })?; } verify { - assert!(executor.holding.ensure_contains(&assets).is_ok()); + assert!(executor.holding().ensure_contains(&assets).is_ok()); } receive_teleported_asset { From 4c8ed73250334061c813e9d7f48753be580c8478 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 9 Mar 2022 01:54:08 -0800 Subject: [PATCH 069/231] Fixes --- xcm/pallet-xcm-benchmarks/src/fungible/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index e59f4951b08e..8db8440ca730 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -184,7 +184,7 @@ parameter_types! { )); pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( ChildTeleporter::get(), - MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) }, + MultiAsset { id: Concrete(Here.into_location()), fun: Fungible(100) }, )); pub const TeleConcreteFung: (MultiAssetFilter, MultiLocation) = (Wild(AllOf { fun: WildFungible, id: Concrete(Here.into_location()) }), ChildTeleporter::get()); From 16b9de822b83906995746a3c6a228193954f085a Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 9 Mar 2022 02:45:04 -0800 Subject: [PATCH 070/231] Fixes --- runtime/westend/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index f8813c08c356..e880e18eef34 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1558,7 +1558,7 @@ sp_api::impl_runtime_apis! { )); pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( Westmint::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); } From 38fb089f00ed69047d61633640c1a9a2e656e8f8 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 10 Mar 2022 21:01:12 -0800 Subject: [PATCH 071/231] Fixes --- runtime/common/src/xcm_sender.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index 1502c5ec72a3..82fa6a203cd1 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -17,7 +17,7 @@ //! XCM sender for relay chain. use parity_scale_codec::Encode; -use primitives::v1::Id as ParaId; +use primitives::v2::Id as ParaId; use runtime_parachains::{ configuration::{self, HostConfiguration}, dmp, From ac9662c693b08fa7f0c29341c32c52bc7cb9be68 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 11 Mar 2022 17:53:55 +0100 Subject: [PATCH 072/231] Formatting --- .../bin/rialto-parachain/runtime/src/lib.rs | 6 ++-- runtime/rococo/src/xcm_config.rs | 6 ++-- runtime/westend/src/xcm_config.rs | 6 ++-- xcm/pallet-xcm-benchmarks/src/mock.rs | 2 +- xcm/pallet-xcm/src/mock.rs | 6 ++-- xcm/xcm-builder/src/location_conversion.rs | 28 ++++++++++--------- xcm/xcm-builder/tests/mock/mod.rs | 6 ++-- xcm/xcm-simulator/example/src/parachain.rs | 6 ++-- xcm/xcm-simulator/example/src/relay_chain.rs | 6 ++-- xcm/xcm-simulator/fuzzer/src/parachain.rs | 6 ++-- 10 files changed, 40 insertions(+), 38 deletions(-) diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index cd22389f6738..d124d9dd5d6e 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -287,7 +287,7 @@ parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Polkadot; pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); - pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -372,7 +372,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = NativeAsset; type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of UNIT - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = UsingComponents, RelayLocation, AccountId, Balances, ()>; @@ -406,7 +406,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index f0c3d81d99ff..89b79bd8c1b7 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -39,7 +39,7 @@ use xcm_executor::XcmExecutor; parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub const ThisNetwork: NetworkId = NetworkId::Rococo; - pub Ancestry: InteriorMultiLocation = ThisNetwork::get().into(); + pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); pub CheckAccount: AccountId = XcmPallet::check_account(); } @@ -128,7 +128,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = @@ -172,7 +172,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 4fe04bd8c056..3ed06e9c6d11 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -39,7 +39,7 @@ use xcm_executor::XcmExecutor; parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub const ThisNetwork: NetworkId = Westend; - pub Ancestry: InteriorMultiLocation = ThisNetwork::get().into(); + pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); pub CheckAccount: AccountId = XcmPallet::check_account(); } @@ -107,7 +107,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = WeightInfoBounds, Call, MaxInstructions>; type Trader = @@ -144,7 +144,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = WeightInfoBounds, Call, MaxInstructions>; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/pallet-xcm-benchmarks/src/mock.rs b/xcm/pallet-xcm-benchmarks/src/mock.rs index 84fc9fb9e7b4..718f232f0779 100644 --- a/xcm/pallet-xcm-benchmarks/src/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/mock.rs @@ -61,7 +61,7 @@ impl xcm_executor::traits::Convert for AccountIdConverter { } parameter_types! { - pub Ancestry: InteriorMultiLocation = Junction::Parachain(101).into(); + pub UniversalLocation: InteriorMultiLocation = Junction::Parachain(101).into(); pub UnitWeightCost: Weight = 10; pub WeightPrice: (AssetId, u128) = (Concrete(Here.into()), 1_000_000); } diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 0e86483d6792..2b72a87f92e4 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -245,7 +245,7 @@ impl pallet_balances::Config for Test { parameter_types! { pub const RelayLocation: MultiLocation = Here.into_location(); pub const AnyNetwork: Option = None; - pub Ancestry: InteriorMultiLocation = Here; + pub UniversalLocation: InteriorMultiLocation = Here; pub UnitWeightCost: Weight = 1_000; } @@ -285,7 +285,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = Case; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -318,7 +318,7 @@ impl pallet_xcm::Config for Test { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index a40dff5c93af..0e7116ec5ddd 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -165,24 +165,26 @@ impl>, AccountId: From<[u8; 20]> + Into<[u8; 20]> /// # use xcm_executor::traits::UniversalLocation; /// # fn main() { /// parameter_types!{ -/// pub Ancestry: InteriorMultiLocation = X2( +/// pub UniversalLocation: InteriorMultiLocation = X2( /// Parachain(1), /// AccountKey20 { network: None, key: Default::default() }, /// ); /// } /// /// let input = MultiLocation::new(2, X2(Parachain(2), AccountId32 { network: None, id: Default::default() })); -/// let inverted = LocationInverter::::invert_location(&input); +/// let inverted = LocationInverter::::invert_location(&input); /// assert_eq!(inverted, Ok(MultiLocation::new( /// 2, /// X2(Parachain(1), AccountKey20 { network: None, key: Default::default() }), /// ))); /// # } /// ``` -pub struct LocationInverter(PhantomData); -impl> UniversalLocation for LocationInverter { +pub struct LocationInverter(PhantomData); +impl> UniversalLocation + for LocationInverter +{ fn universal_location() -> InteriorMultiLocation { - Ancestry::get() + UniversalLocation::get() } } @@ -216,11 +218,11 @@ mod tests { #[test] fn inverter_works_in_tree() { parameter_types! { - pub Ancestry: InteriorMultiLocation = X3(Parachain(1), account20(), account20()); + pub UniversalLocation: InteriorMultiLocation = X3(Parachain(1), account20(), account20()); } let input = MultiLocation::new(3, X2(Parachain(2), account32())); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = LocationInverter::::invert_location(&input).unwrap(); assert_eq!(inverted, MultiLocation::new(2, X3(Parachain(1), account20(), account20()))); } @@ -231,11 +233,11 @@ mod tests { #[test] fn inverter_uses_context_as_inverted_location() { parameter_types! { - pub Ancestry: InteriorMultiLocation = X2(account20(), account20()); + pub UniversalLocation: InteriorMultiLocation = X2(account20(), account20()); } let input = MultiLocation::grandparent(); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = LocationInverter::::invert_location(&input).unwrap(); assert_eq!(inverted, X2(account20(), account20()).into()); } @@ -246,22 +248,22 @@ mod tests { #[test] fn inverter_uses_only_child_on_missing_context() { parameter_types! { - pub Ancestry: InteriorMultiLocation = X1(PalletInstance(5)); + pub UniversalLocation: InteriorMultiLocation = X1(PalletInstance(5)); } let input = MultiLocation::grandparent(); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = LocationInverter::::invert_location(&input).unwrap(); assert_eq!(inverted, X2(PalletInstance(5), OnlyChild).into()); } #[test] fn inverter_errors_when_location_is_too_large() { parameter_types! { - pub Ancestry: InteriorMultiLocation = Here; + pub UniversalLocation: InteriorMultiLocation = Here; } let input = MultiLocation { parents: 99, interior: X1(Parachain(88)) }; - let inverted = LocationInverter::::invert_location(&input); + let inverted = LocationInverter::::invert_location(&input); assert_eq!(inverted, Err(())); } } diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 3b782d99de66..424a0e28017c 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -128,7 +128,7 @@ impl configuration::Config for Runtime { parameter_types! { pub const KsmLocation: MultiLocation = MultiLocation::here(); pub const KusamaNetwork: NetworkId = NetworkId::Kusama; - pub Ancestry: InteriorMultiLocation = Here; + pub UniversalLocation: InteriorMultiLocation = Here; pub CheckAccount: AccountId = XcmPallet::check_account(); } @@ -178,7 +178,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -199,7 +199,7 @@ pub type LocalOriginToLocation = SignedToAccountId32; + type LocationInverter = LocationInverter; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = TestSendXcm; // Anyone can execute XCM messages locally... diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 8c5474a31e84..36c63ec014e0 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -166,7 +166,7 @@ parameter_types! { parameter_types! { pub const KsmLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub Ancestry: InteriorMultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); } pub type LocationToAccountId = ( @@ -222,7 +222,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = (NativeAsset, TrustedReserves); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -395,7 +395,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 256780e0c692..53b06a32648e 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -118,7 +118,7 @@ parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub RelayNetwork: NetworkId = ByGenesis([0; 32]); pub const AnyNetwork: Option = None; - pub Ancestry: InteriorMultiLocation = Here; + pub UniversalLocation: InteriorMultiLocation = Here; pub UnitWeightCost: Weight = 1_000; } @@ -165,7 +165,7 @@ impl Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -195,7 +195,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index ebecc61d40c7..620563067469 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -104,7 +104,7 @@ parameter_types! { parameter_types! { pub const KsmLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub Ancestry: InteriorMultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = Parachain(MsgQueue::parachain_id().into()).into(); } pub type LocationToAccountId = ( @@ -140,7 +140,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = NativeAsset; type IsTeleporter = (); - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -314,7 +314,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; From 0f3c3ed89a902de85f723c6689484db316a5d394 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 11 Mar 2022 18:03:57 +0100 Subject: [PATCH 073/231] Fixes --- xcm/pallet-xcm-benchmarks/src/fungible/mock.rs | 2 +- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 2 +- xcm/xcm-builder/src/location_conversion.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 8db8440ca730..aa3498fa492a 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -138,7 +138,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = (); type IsReserve = TrustedReserves; type IsTeleporter = TrustedTeleporters; - type LocationInverter = xcm_builder::LocationInverter; + type LocationInverter = xcm_builder::LocationInverter; type Barrier = AllowUnpaidExecutionFrom; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 52f6e4528c58..5f45cb56df00 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -110,7 +110,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = AlwaysSignedByDefault; type IsReserve = AllAssetLocationsPass; type IsTeleporter = (); - type LocationInverter = xcm_builder::LocationInverter; + type LocationInverter = xcm_builder::LocationInverter; type Barrier = AllowUnpaidExecutionFrom; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index 0e7116ec5ddd..b239fa978ca3 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -180,11 +180,11 @@ impl>, AccountId: From<[u8; 20]> + Into<[u8; 20]> /// # } /// ``` pub struct LocationInverter(PhantomData); -impl> UniversalLocation - for LocationInverter +impl> UniversalLocation + for LocationInverter { fn universal_location() -> InteriorMultiLocation { - UniversalLocation::get() + Location::get() } } From 59d3e17f8a00081b8e957130ff8c95562f6e92e7 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 11 Mar 2022 18:04:05 +0100 Subject: [PATCH 074/231] Formatting --- xcm/xcm-builder/src/location_conversion.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index b239fa978ca3..1afc855df2a2 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -180,9 +180,7 @@ impl>, AccountId: From<[u8; 20]> + Into<[u8; 20]> /// # } /// ``` pub struct LocationInverter(PhantomData); -impl> UniversalLocation - for LocationInverter -{ +impl> UniversalLocation for LocationInverter { fn universal_location() -> InteriorMultiLocation { Location::get() } From 7a1bc07110d2c7cc1ac19345f4ade36fbabd6bc2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 11 Mar 2022 19:10:46 +0100 Subject: [PATCH 075/231] Fixes --- runtime/common/src/xcm_sender.rs | 34 ++++++++++++++++++++++++++++-- runtime/kusama/src/xcm_config.rs | 2 +- runtime/polkadot/src/xcm_config.rs | 2 +- runtime/rococo/src/xcm_config.rs | 2 +- runtime/westend/src/xcm_config.rs | 2 +- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index 82fa6a203cd1..205850e2f324 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -16,6 +16,7 @@ //! XCM sender for relay chain. +use frame_support::traits::Get; use parity_scale_codec::Encode; use primitives::v2::Id as ParaId; use runtime_parachains::{ @@ -26,10 +27,38 @@ use sp_std::{marker::PhantomData, prelude::*}; use xcm::prelude::*; use SendError::*; +pub trait PriceForParachainDelivery { + fn price_for_parachain_delivery(para: ParaId, message: &Xcm<()>) -> MultiAssets; +} + +impl PriceForParachainDelivery for () { + fn price_for_parachain_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets { + MultiAssets::new() + } +} + +pub struct ConstantPrice(sp_std::marker::PhantomData); + +impl PriceForParachainDelivery for () { + fn price_for_parachain_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets { + MultiAssets::new() + } +} + +impl> PriceForParachainDelivery for ConstantPrice { + fn price_for_parachain_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets { + T::get() + } +} + /// XCM sender for relay chain. It only sends downward message. pub struct ChildParachainRouter(PhantomData<(T, W)>); -impl SendXcm +impl< + T: configuration::Config + dmp::Config, + W: xcm::WrapVersion, + P: PriceForParachainDelivery, +> SendXcm for ChildParachainRouter { type Ticket = (HostConfiguration, ParaId, Vec); @@ -50,11 +79,12 @@ impl SendXcm let xcm = msg.take().ok_or(MissingArgument)?; let config = >::config(); let para = id.into(); + let price = P::price_for_parachain_delivery(para, &xcm); let blob = W::wrap_version(&d, xcm).map_err(|()| DestinationUnsupported)?.encode(); >::can_queue_downward_message(&config, ¶, &blob) .map_err(Into::::into)?; - Ok(((config, para, blob), MultiAssets::new())) + Ok(((config, para, blob), price)) } fn deliver( diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 8adb87b804a6..0d1f9960156f 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -102,7 +102,7 @@ parameter_types! { /// individual routers. pub type XcmRouter = ( // Only one router so far - use DMP to communicate with child parachains. - xcm_sender::ChildParachainRouter, + xcm_sender::ChildParachainRouter, ); parameter_types! { diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index d88596847983..501e5e5620e5 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -97,7 +97,7 @@ parameter_types! { /// individual routers. pub type XcmRouter = ( // Only one router so far - use DMP to communicate with child parachains. - xcm_sender::ChildParachainRouter, + xcm_sender::ChildParachainRouter, ); parameter_types! { diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 89b79bd8c1b7..00e3b643ff59 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -74,7 +74,7 @@ parameter_types! { /// individual routers. pub type XcmRouter = ( // Only one router so far - use DMP to communicate with child parachains. - xcm_sender::ChildParachainRouter, + xcm_sender::ChildParachainRouter, ); parameter_types! { diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 3ed06e9c6d11..4952c2d007d9 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -70,7 +70,7 @@ type LocalOriginConverter = ( /// individual routers. pub type XcmRouter = ( // Only one router so far - use DMP to communicate with child parachains. - xcm_sender::ChildParachainRouter, + xcm_sender::ChildParachainRouter, ); parameter_types! { From df62f3cbb604b1926f6716e34f2541ca52c78ad8 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 11 Mar 2022 19:11:09 +0100 Subject: [PATCH 076/231] Fixes --- runtime/common/src/xcm_sender.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index 205850e2f324..db8343647e31 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -52,14 +52,14 @@ impl> PriceForParachainDelivery for ConstantPrice { } /// XCM sender for relay chain. It only sends downward message. -pub struct ChildParachainRouter(PhantomData<(T, W)>); +pub struct ChildParachainRouter(PhantomData<(T, W, P)>); impl< T: configuration::Config + dmp::Config, W: xcm::WrapVersion, P: PriceForParachainDelivery, > SendXcm - for ChildParachainRouter + for ChildParachainRouter { type Ticket = (HostConfiguration, ParaId, Vec); From 5a916ca6fcc2fa9e2dcbf0bcb0a77d331a9c68ed Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 11 Mar 2022 19:11:15 +0100 Subject: [PATCH 077/231] Formatting --- runtime/common/src/xcm_sender.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index db8343647e31..1c3bb8df5afe 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -54,12 +54,8 @@ impl> PriceForParachainDelivery for ConstantPrice { /// XCM sender for relay chain. It only sends downward message. pub struct ChildParachainRouter(PhantomData<(T, W, P)>); -impl< - T: configuration::Config + dmp::Config, - W: xcm::WrapVersion, - P: PriceForParachainDelivery, -> SendXcm - for ChildParachainRouter +impl + SendXcm for ChildParachainRouter { type Ticket = (HostConfiguration, ParaId, Vec); From 9cf0ff56826466aa317ca4dc7a2cc5837084ccd3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 11 Mar 2022 19:12:02 +0100 Subject: [PATCH 078/231] Formatting --- runtime/common/src/xcm_sender.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index 1c3bb8df5afe..bc806d67f2e0 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -30,7 +30,6 @@ use SendError::*; pub trait PriceForParachainDelivery { fn price_for_parachain_delivery(para: ParaId, message: &Xcm<()>) -> MultiAssets; } - impl PriceForParachainDelivery for () { fn price_for_parachain_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets { MultiAssets::new() @@ -38,13 +37,6 @@ impl PriceForParachainDelivery for () { } pub struct ConstantPrice(sp_std::marker::PhantomData); - -impl PriceForParachainDelivery for () { - fn price_for_parachain_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets { - MultiAssets::new() - } -} - impl> PriceForParachainDelivery for ConstantPrice { fn price_for_parachain_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets { T::get() From d236b2f9645f7a481cff0112280ef1186caa4e67 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 11 Mar 2022 10:51:22 -0800 Subject: [PATCH 079/231] Remove horrible names --- xcm/pallet-xcm-benchmarks/src/fungible/mock.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index aa3498fa492a..bf962f65668c 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -172,8 +172,8 @@ impl crate::Config for Test { } } -pub type TrustedTeleporters = (xcm_builder::Case,); -pub type TrustedReserves = (xcm_builder::Case,); +pub type TrustedTeleporters = (xcm_builder::Case,); +pub type TrustedReserves = (xcm_builder::Case,); parameter_types! { pub const CheckedAccount: Option = Some(100); @@ -186,9 +186,9 @@ parameter_types! { ChildTeleporter::get(), MultiAsset { id: Concrete(Here.into_location()), fun: Fungible(100) }, )); - pub const TeleConcreteFung: (MultiAssetFilter, MultiLocation) = + pub const TeleportConcreteFungible: (MultiAssetFilter, MultiLocation) = (Wild(AllOf { fun: WildFungible, id: Concrete(Here.into_location()) }), ChildTeleporter::get()); - pub const RsrvConcreteFung: (MultiAssetFilter, MultiLocation) = + pub const ReserveConcreteFungible: (MultiAssetFilter, MultiLocation) = (Wild(AllOf { fun: WildFungible, id: Concrete(Here.into_location()) }), ChildTeleporter::get()); } From edd992e5d589ff744ecbae4955c017257bc80346 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 11 Mar 2022 23:26:32 +0100 Subject: [PATCH 080/231] Bump --- Cargo.lock | 326 ++++++++++++++++++++++++++--------------------------- 1 file changed, 163 insertions(+), 163 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1dea584e8cdf..92d6a3a0a04f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -450,7 +450,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "beefy-primitives", "fnv", @@ -480,7 +480,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -503,12 +503,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "scale-info", @@ -2050,7 +2050,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", ] @@ -2068,7 +2068,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -2090,7 +2090,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "Inflector", "chrono", @@ -2131,7 +2131,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -2146,7 +2146,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -2174,7 +2174,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "bitflags", "frame-metadata", @@ -2203,7 +2203,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2215,7 +2215,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.3", @@ -2227,7 +2227,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "proc-macro2", "quote", @@ -2237,7 +2237,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2260,7 +2260,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -2271,7 +2271,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "log", @@ -2288,7 +2288,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "sp-api", @@ -2312,7 +2312,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "sp-api", @@ -2508,7 +2508,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "chrono", "frame-election-provider-support", @@ -4954,7 +4954,7 @@ checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -4968,7 +4968,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -4984,7 +4984,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -4999,7 +4999,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5023,7 +5023,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5043,7 +5043,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-election-provider-support", "frame-support", @@ -5063,7 +5063,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5078,7 +5078,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "beefy-primitives", "frame-support", @@ -5094,7 +5094,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -5119,7 +5119,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5203,7 +5203,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5220,7 +5220,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5236,7 +5236,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5259,7 +5259,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5277,7 +5277,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5292,7 +5292,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5315,7 +5315,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5331,7 +5331,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5351,7 +5351,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5368,7 +5368,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5385,7 +5385,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5403,7 +5403,7 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -5419,7 +5419,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5436,7 +5436,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5451,7 +5451,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -5465,7 +5465,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -5482,7 +5482,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5505,7 +5505,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5521,7 +5521,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5536,7 +5536,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -5550,7 +5550,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5566,7 +5566,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -5587,7 +5587,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5603,7 +5603,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -5617,7 +5617,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5640,7 +5640,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -5651,7 +5651,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "log", "sp-arithmetic", @@ -5660,7 +5660,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -5674,7 +5674,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5692,7 +5692,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5711,7 +5711,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-support", "frame-system", @@ -5728,7 +5728,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5745,7 +5745,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5756,7 +5756,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5773,7 +5773,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5788,7 +5788,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -5804,7 +5804,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-benchmarking", "frame-support", @@ -8265,7 +8265,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "env_logger", "jsonrpsee 0.8.0", @@ -8612,7 +8612,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "log", "sp-core", @@ -8623,7 +8623,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "futures 0.3.21", @@ -8650,7 +8650,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "futures-timer", @@ -8673,7 +8673,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8689,7 +8689,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.3", @@ -8706,7 +8706,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -8717,7 +8717,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "chrono", "clap", @@ -8755,7 +8755,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "fnv", "futures 0.3.21", @@ -8783,7 +8783,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "hash-db", "kvdb", @@ -8808,7 +8808,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "futures 0.3.21", @@ -8832,7 +8832,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "fork-tree", @@ -8875,7 +8875,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -8899,7 +8899,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8912,7 +8912,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "futures 0.3.21", @@ -8937,7 +8937,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "sc-client-api", "sp-authorship", @@ -8948,7 +8948,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "lazy_static", "lru 0.6.6", @@ -8975,7 +8975,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "environmental", "parity-scale-codec", @@ -8992,7 +8992,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "log", "parity-scale-codec", @@ -9008,7 +9008,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "cfg-if 1.0.0", "libc", @@ -9026,7 +9026,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "ahash", "async-trait", @@ -9066,7 +9066,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "finality-grandpa", "futures 0.3.21", @@ -9090,7 +9090,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "ansi_term", "futures 0.3.21", @@ -9107,7 +9107,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "hex", @@ -9122,7 +9122,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "asynchronous-codec 0.5.0", @@ -9171,7 +9171,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "ahash", "futures 0.3.21", @@ -9188,7 +9188,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "bytes 1.1.0", "fnv", @@ -9216,7 +9216,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "libp2p", @@ -9229,7 +9229,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9238,7 +9238,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "hash-db", @@ -9269,7 +9269,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9294,7 +9294,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9311,7 +9311,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "directories", @@ -9375,7 +9375,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "log", "parity-scale-codec", @@ -9389,7 +9389,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -9410,7 +9410,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "chrono", "futures 0.3.21", @@ -9428,7 +9428,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "ansi_term", "atty", @@ -9459,7 +9459,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -9470,7 +9470,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "futures-timer", @@ -9497,7 +9497,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "log", @@ -9510,7 +9510,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "futures-timer", @@ -10014,7 +10014,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "hash-db", "log", @@ -10031,7 +10031,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "blake2 0.10.4", "proc-macro-crate 1.1.3", @@ -10043,7 +10043,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "scale-info", @@ -10056,7 +10056,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "integer-sqrt", "num-traits", @@ -10071,7 +10071,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "scale-info", @@ -10084,7 +10084,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "parity-scale-codec", @@ -10096,7 +10096,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "sp-api", @@ -10108,7 +10108,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "log", @@ -10126,7 +10126,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "futures 0.3.21", @@ -10145,7 +10145,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "merlin", @@ -10168,7 +10168,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "scale-info", @@ -10182,7 +10182,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -10194,7 +10194,7 @@ dependencies = [ [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "base58", "bitflags", @@ -10240,7 +10240,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "blake2 0.10.4", "byteorder", @@ -10254,7 +10254,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "proc-macro2", "quote", @@ -10265,7 +10265,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "kvdb", "parking_lot 0.12.0", @@ -10274,7 +10274,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "proc-macro2", "quote", @@ -10284,7 +10284,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "environmental", "parity-scale-codec", @@ -10295,7 +10295,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "finality-grandpa", "log", @@ -10313,7 +10313,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10327,7 +10327,7 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "hash-db", @@ -10352,7 +10352,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "lazy_static", "sp-core", @@ -10363,7 +10363,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "futures 0.3.21", @@ -10380,7 +10380,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "thiserror", "zstd", @@ -10389,7 +10389,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "scale-info", @@ -10404,7 +10404,7 @@ dependencies = [ [[package]] name = "sp-npos-elections-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -10415,7 +10415,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "sp-api", "sp-core", @@ -10425,7 +10425,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "backtrace", "lazy_static", @@ -10435,7 +10435,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "rustc-hash", "serde", @@ -10445,7 +10445,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "either", "hash256-std-hasher", @@ -10467,7 +10467,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10484,7 +10484,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "Inflector", "proc-macro-crate 1.1.3", @@ -10496,7 +10496,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "serde", "serde_json", @@ -10505,7 +10505,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "scale-info", @@ -10519,7 +10519,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "scale-info", @@ -10530,7 +10530,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "hash-db", "log", @@ -10553,12 +10553,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10571,7 +10571,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "log", "sp-core", @@ -10584,7 +10584,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "futures-timer", @@ -10600,7 +10600,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "sp-std", @@ -10612,7 +10612,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "sp-api", "sp-runtime", @@ -10621,7 +10621,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "log", @@ -10637,7 +10637,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "hash-db", "memory-db", @@ -10653,7 +10653,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10670,7 +10670,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10681,7 +10681,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "impl-trait-for-tuples", "log", @@ -10882,7 +10882,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "platforms", ] @@ -10890,7 +10890,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.21", @@ -10912,7 +10912,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures-util", "hyper", @@ -10925,7 +10925,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "async-trait", "futures 0.3.21", @@ -10951,7 +10951,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "futures 0.3.21", "substrate-test-utils-derive", @@ -10961,7 +10961,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -10972,7 +10972,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "ansi_term", "build-helper", @@ -11631,7 +11631,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#f5f286db0da99761792b69bf4a997535dcc8f260" +source = "git+https://github.com/paritytech/substrate?branch=master#5cc2ef8e4c03b64691db367036fedd8f4d7f0326" dependencies = [ "clap", "jsonrpsee 0.4.1", From 4421714e9b4412bebc015cd26f03a1536c1cc2bd Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sat, 12 Mar 2022 12:28:57 +0100 Subject: [PATCH 081/231] Remove InvertLocation trait (#5092) * Remove InvertLocation trait * Remove unneeded functions * Formatting --- .../bin/rialto-parachain/runtime/src/lib.rs | 6 +-- runtime/kusama/src/xcm_config.rs | 8 +-- runtime/polkadot/src/xcm_config.rs | 8 +-- runtime/rococo/src/xcm_config.rs | 6 +-- runtime/test-runtime/src/lib.rs | 3 +- runtime/test-runtime/src/xcm_config.rs | 16 ++---- runtime/westend/src/xcm_config.rs | 6 +-- .../src/fungible/mock.rs | 2 +- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 2 +- xcm/pallet-xcm/src/lib.rs | 23 ++++----- xcm/pallet-xcm/src/mock.rs | 8 +-- xcm/src/v3/junctions.rs | 29 +++++++++++ xcm/src/v3/multiasset.rs | 36 +++++++++++--- xcm/src/v3/multilocation.rs | 41 +++------------- xcm/xcm-builder/src/lib.rs | 2 +- xcm/xcm-builder/src/location_conversion.rs | 49 ++----------------- xcm/xcm-builder/src/test_utils.rs | 2 +- xcm/xcm-builder/src/tests/mock.rs | 6 +-- xcm/xcm-builder/src/universal_exports.rs | 34 +++++++------ xcm/xcm-builder/tests/mock/mod.rs | 8 +-- xcm/xcm-executor/src/assets.rs | 4 +- xcm/xcm-executor/src/config.rs | 7 ++- xcm/xcm-executor/src/lib.rs | 22 ++++----- xcm/xcm-executor/src/traits/conversion.rs | 23 --------- xcm/xcm-executor/src/traits/mod.rs | 8 ++- xcm/xcm-simulator/example/src/parachain.rs | 9 ++-- xcm/xcm-simulator/example/src/relay_chain.rs | 8 +-- xcm/xcm-simulator/fuzzer/src/parachain.rs | 10 ++-- xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 8 +-- 29 files changed, 173 insertions(+), 221 deletions(-) diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index d124d9dd5d6e..b406ec306b19 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -69,7 +69,7 @@ use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, - EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, + EnsureXcmOrigin, FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, @@ -372,7 +372,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = NativeAsset; type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of UNIT - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = UsingComponents, RelayLocation, AccountId, Balances, ()>; @@ -406,7 +406,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 0d1f9960156f..1ea3717051bd 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -32,8 +32,8 @@ use xcm_builder::{ AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, - LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, - TakeWeightCredit, UsingComponents, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, }; use xcm_executor::XcmExecutor; @@ -142,7 +142,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; // The weight trader piggybacks on the existing transaction-fee conversion logic. @@ -192,7 +192,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 501e5e5620e5..02066df1fb32 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -31,8 +31,8 @@ use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, - IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + TakeWeightCredit, UsingComponents, }; use xcm_executor::XcmExecutor; @@ -134,7 +134,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; // The weight trader piggybacks on the existing transaction-fee conversion logic. @@ -184,7 +184,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 00e3b643ff59..8e71ca8daffe 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -31,7 +31,7 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter, + CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents, }; use xcm_executor::XcmExecutor; @@ -128,7 +128,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = @@ -172,7 +172,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 07508efc2ff0..1353b0507d1b 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -521,6 +521,7 @@ parameter_types! { pub const BaseXcmWeight: frame_support::weights::Weight = 1_000; pub const AnyNetwork: Option = None; pub const MaxInstructions: u32 = 100; + pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; } pub type LocalOriginToLocation = xcm_builder::SignedToAccountId32; @@ -530,7 +531,7 @@ impl pallet_xcm::Config for Runtime { // is `XcmExecutor`, which will be used in unit tests located in xcm-executor. type Event = Event; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; - type LocationInverter = xcm_config::InvertNothing; + type UniversalLocation = UniversalLocation; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type Weigher = xcm_builder::FixedWeightBounds; type XcmRouter = xcm_config::DoNothingRouter; diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index cd0ac5137bd0..284a1d3dc21b 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -22,7 +22,7 @@ use frame_support::{ use xcm::latest::prelude::*; use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32}; use xcm_executor::{ - traits::{TransactAsset, UniversalLocation, WeightTrader}, + traits::{TransactAsset, WeightTrader}, Assets, }; @@ -30,6 +30,7 @@ parameter_types! { pub const OurNetwork: NetworkId = NetworkId::Polkadot; pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 16; + pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location @@ -79,17 +80,6 @@ impl WeightTrader for DummyWeightTrader { } } -pub struct InvertNothing; -impl UniversalLocation for InvertNothing { - fn invert_location(_: &MultiLocation) -> sp_std::result::Result { - Ok(Here.into()) - } - - fn universal_location() -> InteriorMultiLocation { - Here - } -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type Call = super::Call; @@ -98,7 +88,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = pallet_xcm::XcmPassthrough; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = InvertNothing; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = DummyWeightTrader; diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 4952c2d007d9..ecf1a8be21bb 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -30,7 +30,7 @@ use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, LocationInverter, + CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; @@ -107,7 +107,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds, Call, MaxInstructions>; type Trader = @@ -144,7 +144,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = WeightInfoBounds, Call, MaxInstructions>; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index bf962f65668c..f20fe23146a8 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -138,7 +138,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = (); type IsReserve = TrustedReserves; type IsTeleporter = TrustedTeleporters; - type LocationInverter = xcm_builder::LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = AllowUnpaidExecutionFrom; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 5f45cb56df00..ec34975e3a0d 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -110,7 +110,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = AlwaysSignedByDefault; type IsReserve = AllAssetLocationsPass; type IsTeleporter = (); - type LocationInverter = xcm_builder::LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = AllowUnpaidExecutionFrom; type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 5a388982c788..30254ff4e769 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -54,8 +54,7 @@ pub use pallet::*; use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash}; use xcm_executor::{ traits::{ - ClaimAssets, DropAssets, MatchesFungible, OnResponse, UniversalLocation, - VersionChangeNotifier, WeightBounds, + ClaimAssets, DropAssets, MatchesFungible, OnResponse, VersionChangeNotifier, WeightBounds, }, Assets, }; @@ -69,7 +68,7 @@ pub mod pallet { }; use frame_system::Config as SysConfig; use sp_core::H256; - use xcm_executor::traits::{MatchesFungible, UniversalLocation, WeightBounds}; + use xcm_executor::traits::{MatchesFungible, WeightBounds}; parameter_types! { /// An implementation of `Get` which just returns the latest XCM version which we can @@ -125,8 +124,8 @@ pub mod pallet { /// Means of measuring the weight consumed by an XCM message locally. type Weigher: WeightBounds<::Call>; - /// Means of inverting a location. - type LocationInverter: UniversalLocation; + /// This chain's Universal Location. + type UniversalLocation: Get; /// The outer `Origin` type. type Origin: From + From<::Origin>; @@ -983,12 +982,12 @@ impl Pallet { let value = (origin_location, assets.into_inner()); ensure!(T::XcmReserveTransferFilter::contains(&value), Error::::Filtered); let (origin_location, assets) = value; - let ancestry = T::LocationInverter::universal_location().into(); + let context = T::UniversalLocation::get(); let fees = assets .get(fee_asset_item as usize) .ok_or(Error::::Empty)? .clone() - .reanchored(&dest, &ancestry) + .reanchored(&dest, context) .map_err(|_| Error::::CannotReanchor)?; let max_assets = assets.len() as u32; let assets: MultiAssets = assets.into(); @@ -1041,12 +1040,12 @@ impl Pallet { let value = (origin_location, assets.into_inner()); ensure!(T::XcmTeleportFilter::contains(&value), Error::::Filtered); let (origin_location, assets) = value; - let ancestry = T::LocationInverter::universal_location().into(); + let context = T::UniversalLocation::get(); let fees = assets .get(fee_asset_item as usize) .ok_or(Error::::Empty)? .clone() - .reanchored(&dest, &ancestry) + .reanchored(&dest, context) .map_err(|_| Error::::CannotReanchor)?; let max_assets = assets.len() as u32; let assets: MultiAssets = assets.into(); @@ -1333,7 +1332,8 @@ impl Pallet { timeout: T::BlockNumber, ) -> Result { let responder = responder.into(); - let destination = T::LocationInverter::invert_location(&responder) + let destination = T::UniversalLocation::get() + .invert_target(&responder) .map_err(|()| XcmError::MultiLocationNotInvertible)?; let query_id = Self::new_query(responder, timeout, Here); let response_info = QueryResponseInfo { destination, query_id, max_weight: 0 }; @@ -1371,7 +1371,8 @@ impl Pallet { timeout: T::BlockNumber, ) -> Result<(), XcmError> { let responder = responder.into(); - let destination = T::LocationInverter::invert_location(&responder) + let destination = T::UniversalLocation::get() + .invert_target(&responder) .map_err(|()| XcmError::MultiLocationNotInvertible)?; let notify: ::Call = notify.into(); let max_weight = notify.get_dispatch_info().weight; diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 2b72a87f92e4..2a6018ac35f1 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -30,8 +30,8 @@ use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, Case, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, - FixedWeightBounds, IsConcrete, LocationInverter, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, }; use xcm_executor::XcmExecutor; @@ -285,7 +285,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = Case; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -318,7 +318,7 @@ impl pallet_xcm::Config for Test { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs index d958478ac50d..5deb952d1506 100644 --- a/xcm/src/v3/junctions.rs +++ b/xcm/src/v3/junctions.rs @@ -135,6 +135,19 @@ impl Junctions { self.for_each_mut(Junction::remove_network_id); } + /// Treating `self` as the universal context, return the location of the local consensus system + /// from the point of view of the given `location`. + pub fn invert_target(mut self, location: &MultiLocation) -> Result { + let mut junctions = Self::Here; + for _ in 0..location.parent_count() { + junctions = junctions + .pushed_with(self.take_first().unwrap_or(Junction::OnlyChild)) + .map_err(|_| ())?; + } + let parents = location.interior().len() as u8; + Ok(MultiLocation::new(parents, junctions)) + } + /// Execute a function `f` on every junction. We use this since we cannot implement a mutable /// `Iterator` without unsafe code. pub fn for_each_mut(&mut self, mut x: impl FnMut(&mut Junction)) { @@ -570,6 +583,22 @@ xcm_procedural::impl_conversion_functions_for_junctions_v3!(); mod tests { use super::{super::prelude::*, *}; + #[test] + fn inverting_works() { + let context: InteriorMultiLocation = (Parachain(1000), PalletInstance(42)).into(); + let target = (Parent, PalletInstance(69)).into(); + let expected = (Parent, PalletInstance(42)).into(); + let inverted = context.invert_target(&target).unwrap(); + assert_eq!(inverted, expected); + + let context: InteriorMultiLocation = + (Parachain(1000), PalletInstance(42), GeneralIndex(1)).into(); + let target = (Parent, Parent, PalletInstance(69), GeneralIndex(2)).into(); + let expected = (Parent, Parent, PalletInstance(42), GeneralIndex(1)).into(); + let inverted = context.invert_target(&target).unwrap(); + assert_eq!(inverted, expected); + } + #[test] fn relative_to_works() { use Junctions::*; diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index c93ac0902789..d5064faab8d3 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -23,7 +23,7 @@ //! - `MultiAssetFilter`: A combination of `Wild` and `MultiAssets` designed for efficiently filtering an XCM holding //! account. -use super::MultiLocation; +use super::{InteriorMultiLocation, MultiLocation}; use crate::v2::{ AssetId as OldAssetId, AssetInstance as OldAssetInstance, Fungibility as OldFungibility, MultiAsset as OldMultiAsset, MultiAssetFilter as OldMultiAssetFilter, @@ -347,7 +347,11 @@ impl AssetId { /// Mutate the asset to represent the same value from the perspective of a new `target` /// location. The local chain's location is provided in `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { if let AssetId::Concrete(ref mut l) = self { l.reanchor(target, context)?; } @@ -412,7 +416,11 @@ impl MultiAsset { /// Mutate the location of the asset identifier if concrete, giving it the same location /// relative to a `target` context. The local context is provided as `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { self.id.reanchor(target, context) } @@ -421,7 +429,7 @@ impl MultiAsset { pub fn reanchored( mut self, target: &MultiLocation, - context: &MultiLocation, + context: InteriorMultiLocation, ) -> Result { self.id.reanchor(target, context)?; Ok(self) @@ -620,8 +628,12 @@ impl MultiAssets { /// Mutate the location of the asset identifier if concrete, giving it the same location /// relative to a `target` context. The local context is provided as `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { - self.0.iter_mut().try_for_each(|i| i.reanchor(target, context)) + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { + self.0.iter_mut().try_for_each(|i| i.reanchor(target, context.clone())) } /// Return a reference to an item at a specific index or `None` if it doesn't exist. @@ -700,7 +712,11 @@ impl WildMultiAsset { /// Mutate the asset to represent the same value from the perspective of a new `target` /// location. The local chain's location is provided in `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { use WildMultiAsset::*; match self { AllOf { ref mut id, .. } | AllOfCounted { ref mut id, .. } => @@ -785,7 +801,11 @@ impl MultiAssetFilter { /// Mutate the location of the asset identifier if concrete, giving it the same location /// relative to a `target` context. The local context is provided as `context`. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { match self { MultiAssetFilter::Definite(ref mut assets) => assets.reanchor(target, context), MultiAssetFilter::Wild(ref mut wild) => wild.reanchor(target, context), diff --git a/xcm/src/v3/multilocation.rs b/xcm/src/v3/multilocation.rs index f5d9256aacc3..28e2cf84cca6 100644 --- a/xcm/src/v3/multilocation.rs +++ b/xcm/src/v3/multilocation.rs @@ -388,11 +388,15 @@ impl MultiLocation { /// The context of `self` is provided as `context`. /// /// Does not modify `self` in case of overflow. - pub fn reanchor(&mut self, target: &MultiLocation, context: &MultiLocation) -> Result<(), ()> { + pub fn reanchor( + &mut self, + target: &MultiLocation, + context: InteriorMultiLocation, + ) -> Result<(), ()> { // TODO: https://github.com/paritytech/polkadot/issues/4489 Optimize this. // 1. Use our `context` to figure out how the `target` would address us. - let inverted_target = context.inverted(target)?; + let inverted_target = context.invert_target(target)?; // 2. Prepend `inverted_target` to `self` to get self's location from the perspective of // `target`. @@ -412,7 +416,7 @@ impl MultiLocation { pub fn reanchored( mut self, target: &MultiLocation, - context: &MultiLocation, + context: InteriorMultiLocation, ) -> Result { match self.reanchor(target, context) { Ok(()) => Ok(self), @@ -420,20 +424,6 @@ impl MultiLocation { } } - /// Treating `self` as a context, determine how it would be referenced by a `target` location. - pub fn inverted(&self, target: &MultiLocation) -> Result { - use Junction::OnlyChild; - let mut context = self.clone(); - let mut junctions = Junctions::Here; - for _ in 0..target.parent_count() { - junctions = junctions - .pushed_front_with(context.interior.take_last().unwrap_or(OnlyChild)) - .map_err(|_| ())?; - } - let parents = target.interior().len() as u8; - Ok(MultiLocation::new(parents, junctions)) - } - /// Remove any unneeded parents/junctions in `self` based on the given context it will be /// interpreted in. pub fn simplify(&mut self, context: &Junctions) { @@ -520,21 +510,6 @@ mod tests { assert_eq!(x, MultiLocation { parents: 0, interior: OnlyChild.into() }); } - #[test] - fn inverted_works() { - let context: MultiLocation = (Parachain(1000), PalletInstance(42)).into(); - let target = (Parent, PalletInstance(69)).into(); - let expected = (Parent, PalletInstance(42)).into(); - let inverted = context.inverted(&target).unwrap(); - assert_eq!(inverted, expected); - - let context: MultiLocation = (Parachain(1000), PalletInstance(42), GeneralIndex(1)).into(); - let target = (Parent, Parent, PalletInstance(69), GeneralIndex(2)).into(); - let expected = (Parent, Parent, PalletInstance(42), GeneralIndex(1)).into(); - let inverted = context.inverted(&target).unwrap(); - assert_eq!(inverted, expected); - } - #[test] fn simplify_basic_works() { let mut location: MultiLocation = @@ -589,7 +564,7 @@ mod tests { let context = Parachain(2000).into(); let target = (Parent, Parachain(1000)).into(); let expected = GeneralIndex(42).into(); - id.reanchor(&target, &context).unwrap(); + id.reanchor(&target, context).unwrap(); assert_eq!(id, expected); } diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index e69dfbfbc6af..eb160fa12ecd 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -29,7 +29,7 @@ pub mod test_utils; mod location_conversion; pub use location_conversion::{ Account32Hash, AccountId32Aliases, AccountKey20Aliases, ChildParachainConvertsVia, - LocationInverter, ParentIsPreset, SiblingParachainConvertsVia, + ParentIsPreset, SiblingParachainConvertsVia, }; mod origin_conversion; diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index 1afc855df2a2..9384bdf2732a 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -20,7 +20,7 @@ use sp_io::hashing::blake2_256; use sp_runtime::traits::{AccountIdConversion, TrailingZeroInput}; use sp_std::{borrow::Borrow, marker::PhantomData}; use xcm::latest::prelude::*; -use xcm_executor::traits::{Convert, UniversalLocation}; +use xcm_executor::traits::Convert; pub struct Account32Hash(PhantomData<(Network, AccountId)>); impl>, AccountId: From<[u8; 32]> + Into<[u8; 32]> + Clone> @@ -147,45 +147,6 @@ impl>, AccountId: From<[u8; 20]> + Into<[u8; 20]> } } -/// Simple location inverter; give it this location's context and it'll figure out the inverted -/// location. -/// -/// # Example -/// ## Network Topology -/// ```txt -/// v Source -/// Relay -> Para 1 -> Account20 -/// -> Para 2 -> Account32 -/// ^ Target -/// ``` -/// ```rust -/// # use frame_support::parameter_types; -/// # use xcm::latest::prelude::*; -/// # use xcm_builder::LocationInverter; -/// # use xcm_executor::traits::UniversalLocation; -/// # fn main() { -/// parameter_types!{ -/// pub UniversalLocation: InteriorMultiLocation = X2( -/// Parachain(1), -/// AccountKey20 { network: None, key: Default::default() }, -/// ); -/// } -/// -/// let input = MultiLocation::new(2, X2(Parachain(2), AccountId32 { network: None, id: Default::default() })); -/// let inverted = LocationInverter::::invert_location(&input); -/// assert_eq!(inverted, Ok(MultiLocation::new( -/// 2, -/// X2(Parachain(1), AccountKey20 { network: None, key: Default::default() }), -/// ))); -/// # } -/// ``` -pub struct LocationInverter(PhantomData); -impl> UniversalLocation for LocationInverter { - fn universal_location() -> InteriorMultiLocation { - Location::get() - } -} - #[cfg(test)] mod tests { use super::*; @@ -220,7 +181,7 @@ mod tests { } let input = MultiLocation::new(3, X2(Parachain(2), account32())); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = UniversalLocation::get().invert_target(&input).unwrap(); assert_eq!(inverted, MultiLocation::new(2, X3(Parachain(1), account20(), account20()))); } @@ -235,7 +196,7 @@ mod tests { } let input = MultiLocation::grandparent(); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = UniversalLocation::get().invert_target(&input).unwrap(); assert_eq!(inverted, X2(account20(), account20()).into()); } @@ -250,7 +211,7 @@ mod tests { } let input = MultiLocation::grandparent(); - let inverted = LocationInverter::::invert_location(&input).unwrap(); + let inverted = UniversalLocation::get().invert_target(&input).unwrap(); assert_eq!(inverted, X2(PalletInstance(5), OnlyChild).into()); } @@ -261,7 +222,7 @@ mod tests { } let input = MultiLocation { parents: 99, interior: X1(Parachain(88)) }; - let inverted = LocationInverter::::invert_location(&input); + let inverted = UniversalLocation::get().invert_target(&input); assert_eq!(inverted, Err(())); } } diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index f75edc47661c..b56e39f4266a 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -25,7 +25,7 @@ use sp_std::vec::Vec; pub use xcm::latest::prelude::*; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ - traits::{ConvertOrigin, OnResponse, TransactAsset, UniversalLocation}, + traits::{ConvertOrigin, OnResponse, TransactAsset}, Assets, Config, }; diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index e1f2fbcbaa87..dc5b427e9674 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -17,7 +17,7 @@ use crate::{barriers::AllowSubscriptionsFrom, test_utils::*}; pub use crate::{ AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, - FixedRateOfFungible, FixedWeightBounds, LocationInverter, TakeWeightCredit, + FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit, }; use frame_support::traits::ContainsPair; pub use frame_support::{ @@ -41,7 +41,7 @@ pub use xcm::prelude::*; pub use xcm_executor::{ traits::{ AssetExchange, AssetLock, ConvertOrigin, Enact, ExportXcm, FeeManager, FeeReason, - LockError, OnResponse, TransactAsset, UniversalLocation, + LockError, OnResponse, TransactAsset, }, Assets, Config, }; @@ -593,7 +593,7 @@ impl Config for TestConfig { type OriginConverter = TestOriginConverter; type IsReserve = TestIsReserve; type IsTeleporter = TestIsTeleporter; - type LocationInverter = LocationInverter; + type UniversalLocation = ExecutorUniversalLocation; type Barrier = TestBarrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index 1e0869801812..5db871135db8 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -55,9 +55,11 @@ fn ensure_is_remote( /// that the message sending cannot be abused in any way. /// /// This is only useful when the local chain has bridging capabilities. -pub struct LocalUnpaidExporter(PhantomData<(Exporter, Ancestry)>); -impl> SendXcm - for LocalUnpaidExporter +pub struct LocalUnpaidExporter( + PhantomData<(Exporter, UniversalLocation)>, +); +impl> SendXcm + for LocalUnpaidExporter { type Ticket = Exporter::Ticket; @@ -66,7 +68,7 @@ impl> SendXcm xcm: &mut Option>, ) -> SendResult { let d = dest.take().ok_or(MissingArgument)?; - let devolved = match ensure_is_remote(Ancestry::get(), d) { + let devolved = match ensure_is_remote(UniversalLocation::get(), d) { Ok(x) => x, Err(d) => { *dest = Some(d); @@ -144,11 +146,11 @@ impl)>>> ExporterFor /// /// This is only useful if we have special dispensation by the remote bridges to have the /// `ExportMessage` instruction executed without payment. -pub struct UnpaidRemoteExporter( - PhantomData<(Bridges, Router, Ancestry)>, +pub struct UnpaidRemoteExporter( + PhantomData<(Bridges, Router, UniversalLocation)>, ); -impl> SendXcm - for UnpaidRemoteExporter +impl> SendXcm + for UnpaidRemoteExporter { type Ticket = Router::Ticket; @@ -157,7 +159,7 @@ impl xcm: &mut Option>, ) -> SendResult { let d = dest.as_ref().ok_or(MissingArgument)?.clone(); - let devolved = ensure_is_remote(Ancestry::get(), d).map_err(|_| NotApplicable)?; + let devolved = ensure_is_remote(UniversalLocation::get(), d).map_err(|_| NotApplicable)?; let (remote_network, remote_location, local_network, local_location) = devolved; // Prepend the desired message with instructions which effectively rewrite the origin. @@ -203,11 +205,11 @@ impl /// /// The `ExportMessage` instruction on the bridge is paid for from the local chain's sovereign /// account on the bridge. The amount paid is determined through the `ExporterFor` trait. -pub struct SovereignPaidRemoteExporter( - PhantomData<(Bridges, Router, Ancestry)>, +pub struct SovereignPaidRemoteExporter( + PhantomData<(Bridges, Router, UniversalLocation)>, ); -impl> SendXcm - for SovereignPaidRemoteExporter +impl> SendXcm + for SovereignPaidRemoteExporter { type Ticket = Router::Ticket; @@ -216,7 +218,7 @@ impl xcm: &mut Option>, ) -> SendResult { let d = dest.as_ref().ok_or(MissingArgument)?.clone(); - let devolved = ensure_is_remote(Ancestry::get(), d).map_err(|_| NotApplicable)?; + let devolved = ensure_is_remote(UniversalLocation::get(), d).map_err(|_| NotApplicable)?; let (remote_network, remote_location, local_network, local_location) = devolved; // Prepend the desired message with instructions which effectively rewrite the origin. @@ -234,14 +236,14 @@ impl .ok_or(NotApplicable)?; let local_from_bridge = - MultiLocation::from(Ancestry::get()).inverted(&bridge).map_err(|_| Unroutable)?; + UniversalLocation::get().invert_target(&bridge).map_err(|_| Unroutable)?; let export_instruction = ExportMessage { network: remote_network, destination: remote_location, xcm: exported }; let message = Xcm(if let Some(ref payment) = maybe_payment { let fees = payment .clone() - .reanchored(&bridge, &Ancestry::get().into()) + .reanchored(&bridge, UniversalLocation::get()) .map_err(|_| Unroutable)?; vec![ WithdrawAsset(fees.clone().into()), diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 424a0e28017c..4104e91b8776 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -33,8 +33,8 @@ use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, - IsChildSystemParachain, IsConcrete, LocationInverter, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + IsChildSystemParachain, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, }; pub type AccountId = AccountId32; @@ -178,7 +178,7 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -199,7 +199,7 @@ pub type LocalOriginToLocation = SignedToAccountId32; + type UniversalLocation = UniversalLocation; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = TestSendXcm; // Anyone can execute XCM messages locally... diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index ac8b41233bf4..0f09fde03806 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -23,7 +23,7 @@ use sp_std::{ use xcm::latest::{ AssetId, AssetInstance, Fungibility::{Fungible, NonFungible}, - MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, + InteriorMultiLocation, MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, WildFungibility::{Fungible as WildFungible, NonFungible as WildNonFungible}, WildMultiAsset::{All, AllCounted, AllOf, AllOfCounted}, }; @@ -216,7 +216,7 @@ impl Assets { pub fn reanchor( &mut self, target: &MultiLocation, - context: &MultiLocation, + context: InteriorMultiLocation, mut maybe_failed_bin: Option<&mut Self>, ) { let mut fungible = Default::default(); diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 23cc7e885764..1184f77c6712 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -16,8 +16,7 @@ use crate::traits::{ AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, - OnResponse, ShouldExecute, TransactAsset, UniversalLocation, VersionChangeNotifier, - WeightBounds, WeightTrader, + OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; use frame_support::{ dispatch::{Dispatchable, Parameter}, @@ -46,8 +45,8 @@ pub trait Config { /// Combinations of (Asset, Location) pairs which we trust as teleporters. type IsTeleporter: ContainsPair; - /// Means of inverting a location. - type LocationInverter: UniversalLocation; + /// This chain's Universal Location. + type UniversalLocation: Get; /// Whether we should execute the given XCM at all. type Barrier: ShouldExecute; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 9b765041e251..61fa76be551f 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -31,7 +31,7 @@ use xcm::latest::prelude::*; pub mod traits; use traits::{ validate_export, AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, Enact, - ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, + ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; @@ -472,9 +472,9 @@ impl XcmExecutor { for asset in assets.inner() { Config::AssetTransactor::beam_asset(asset, origin, &dest, &self.context)?; } - let reanchor_context = Config::LocationInverter::universal_location().into(); + let reanchor_context = Config::UniversalLocation::get(); assets - .reanchor(&dest, &reanchor_context) + .reanchor(&dest, reanchor_context) .map_err(|()| XcmError::MultiLocationFull)?; let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); @@ -755,7 +755,7 @@ impl XcmExecutor { Ok(()) }, UniversalOrigin(new_global) => { - let universal_location = Config::LocationInverter::universal_location(); + let universal_location = Config::UniversalLocation::get(); ensure!(universal_location.first() != Some(&new_global), XcmError::InvalidLocation); let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); let origin_xform = (origin, new_global); @@ -784,7 +784,7 @@ impl XcmExecutor { let lock_ticket = Config::AssetLocker::prepare_lock(unlocker.clone(), asset, origin.clone())?; let owner = - origin.reanchored(&unlocker, &context).map_err(|_| XcmError::ReanchorFailed)?; + origin.reanchored(&unlocker, context).map_err(|_| XcmError::ReanchorFailed)?; let msg = Xcm::<()>(vec![NoteUnlockable { asset: remote_asset, owner }]); let (ticket, price) = validate_send::(unlocker, msg)?; self.take_fee(price, FeeReason::LockAsset)?; @@ -876,7 +876,7 @@ impl XcmExecutor { Ok(match local_querier { None => None, Some(q) => Some( - q.reanchored(&destination, &Config::LocationInverter::universal_location().into()) + q.reanchored(&destination, Config::UniversalLocation::get()) .map_err(|_| XcmError::ReanchorFailed)?, ), }) @@ -907,10 +907,10 @@ impl XcmExecutor { fn try_reanchor( asset: MultiAsset, destination: &MultiLocation, - ) -> Result<(MultiAsset, MultiLocation), XcmError> { - let reanchor_context = Config::LocationInverter::universal_location().into(); + ) -> Result<(MultiAsset, InteriorMultiLocation), XcmError> { + let reanchor_context = Config::UniversalLocation::get(); let asset = asset - .reanchored(&destination, &reanchor_context) + .reanchored(&destination, reanchor_context.clone()) .map_err(|()| XcmError::ReanchorFailed)?; Ok((asset, reanchor_context)) } @@ -921,8 +921,8 @@ impl XcmExecutor { dest: &MultiLocation, maybe_failed_bin: Option<&mut Assets>, ) -> MultiAssets { - let reanchor_context = Config::LocationInverter::universal_location().into(); - assets.reanchor(dest, &reanchor_context, maybe_failed_bin); + let reanchor_context = Config::UniversalLocation::get(); + assets.reanchor(dest, reanchor_context, maybe_failed_bin); assets.into_assets_iter().collect::>().into() } } diff --git a/xcm/xcm-executor/src/traits/conversion.rs b/xcm/xcm-executor/src/traits/conversion.rs index b14aedc37b64..acb91c1b9ef9 100644 --- a/xcm/xcm-executor/src/traits/conversion.rs +++ b/xcm/xcm-executor/src/traits/conversion.rs @@ -203,26 +203,3 @@ impl ConvertOrigin for Tuple { Err(origin) } } - -/// Means of wotking with a relative location. -pub trait UniversalLocation { - /// Return the location of the local consensus system from the point of view of the location - /// `l`. - /// - /// Given a target `location`, the result provides the location which represents the local - /// consensus system from the targets perspective. - fn invert_location(location: &MultiLocation) -> Result { - let mut context = Self::universal_location(); - let mut junctions = Here; - for _ in 0..location.parent_count() { - junctions = junctions - .pushed_with(context.take_first().unwrap_or(OnlyChild)) - .map_err(|_| ())?; - } - let parents = location.interior().len() as u8; - Ok(MultiLocation::new(parents, junctions)) - } - - /// Return the location of the local consensus system within the known Universe. - fn universal_location() -> InteriorMultiLocation; -} diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index 4ad216effde6..ead19f79eea5 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -17,9 +17,7 @@ //! Various traits used in configuring the executor. mod conversion; -pub use conversion::{ - Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry, UniversalLocation, -}; +pub use conversion::{Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry}; mod drop_assets; pub use drop_assets::{ClaimAssets, DropAssets}; mod asset_lock; @@ -51,7 +49,7 @@ pub mod prelude { export_xcm, validate_export, AssetExchange, AssetLock, ClaimAssets, Convert, ConvertOrigin, Decoded, DropAssets, Enact, Encoded, Error, ExportXcm, FeeManager, FeeReason, Identity, JustTry, LockError, MatchesFungible, MatchesFungibles, MatchesNonFungible, - MatchesNonFungibles, OnResponse, ShouldExecute, TransactAsset, UniversalLocation, - VersionChangeNotifier, WeightBounds, WeightTrader, + MatchesNonFungibles, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, + WeightBounds, WeightTrader, }; } diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 36c63ec014e0..4147ac3a408a 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -39,9 +39,8 @@ use xcm::{latest::prelude::*, VersionedXcm}; use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, - IsConcrete, LocationInverter, NativeAsset, NonFungiblesAdapter, ParentIsPreset, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, + IsConcrete, NativeAsset, NonFungiblesAdapter, ParentIsPreset, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; use xcm_executor::{ traits::{Convert, JustTry}, @@ -222,7 +221,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = (NativeAsset, TrustedReserves); type IsTeleporter = TrustedTeleporters; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -395,7 +394,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 53b06a32648e..b7a7a13f0bf6 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -31,8 +31,8 @@ use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, - FixedWeightBounds, IsConcrete, LocationInverter, NonFungiblesAdapter, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + FixedWeightBounds, IsConcrete, NonFungiblesAdapter, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -165,7 +165,7 @@ impl Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -195,7 +195,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 620563067469..58ad7a95136c 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -38,9 +38,9 @@ use polkadot_parachain::primitives::{ use xcm::{latest::prelude::*, VersionedXcm}; use xcm_builder::{ AccountId32Aliases, AllowUnpaidExecutionFrom, CurrencyAdapter as XcmCurrencyAdapter, - EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, LocationInverter, - NativeAsset, ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, + EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, IsConcrete, NativeAsset, + ParentIsPreset, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, }; use xcm_executor::{Config, XcmExecutor}; @@ -140,7 +140,7 @@ impl Config for XcmConfig { type OriginConverter = XcmOriginToCallOrigin; type IsReserve = NativeAsset; type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -314,7 +314,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 1e77d3ec9f69..4a0267214a8a 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -31,7 +31,7 @@ use xcm_builder::{ AccountId32Aliases, AllowUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete, - LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; use xcm_executor::{Config, XcmExecutor}; @@ -97,7 +97,7 @@ parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub const ThisNetwork: NetworkId = NetworkId::ByGenesis([0; 32]); pub const AnyNetwork: Option = None; - pub const Ancestry: InteriorMultiLocation = Here; + pub const UniversalLocation: InteriorMultiLocation = Here; pub const UnitWeightCost: Weight = 1_000; } @@ -132,7 +132,7 @@ impl Config for XcmConfig { type OriginConverter = LocalOriginConverter; type IsReserve = (); type IsTeleporter = (); - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; @@ -162,7 +162,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; - type LocationInverter = LocationInverter; + type UniversalLocation = UniversalLocation; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; From cb1246788518630ddbac00516c951f34b7c98478 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 12 Mar 2022 18:10:43 +0100 Subject: [PATCH 082/231] Fixes --- xcm/src/v3/junctions.rs | 10 +++++----- xcm/xcm-builder/src/location_conversion.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs index 5deb952d1506..27580eb61643 100644 --- a/xcm/src/v3/junctions.rs +++ b/xcm/src/v3/junctions.rs @@ -136,15 +136,15 @@ impl Junctions { } /// Treating `self` as the universal context, return the location of the local consensus system - /// from the point of view of the given `location`. - pub fn invert_target(mut self, location: &MultiLocation) -> Result { + /// from the point of view of the given `target`. + pub fn invert_target(mut self, target: &MultiLocation) -> Result { let mut junctions = Self::Here; - for _ in 0..location.parent_count() { + for _ in 0..target.parent_count() { junctions = junctions - .pushed_with(self.take_first().unwrap_or(Junction::OnlyChild)) + .pushed_front_with(self.take_last().unwrap_or(Junction::OnlyChild)) .map_err(|_| ())?; } - let parents = location.interior().len() as u8; + let parents = target.interior().len() as u8; Ok(MultiLocation::new(parents, junctions)) } diff --git a/xcm/xcm-builder/src/location_conversion.rs b/xcm/xcm-builder/src/location_conversion.rs index 9384bdf2732a..cc5770b3cca9 100644 --- a/xcm/xcm-builder/src/location_conversion.rs +++ b/xcm/xcm-builder/src/location_conversion.rs @@ -207,12 +207,12 @@ mod tests { #[test] fn inverter_uses_only_child_on_missing_context() { parameter_types! { - pub UniversalLocation: InteriorMultiLocation = X1(PalletInstance(5)); + pub UniversalLocation: InteriorMultiLocation = PalletInstance(5).into(); } let input = MultiLocation::grandparent(); let inverted = UniversalLocation::get().invert_target(&input).unwrap(); - assert_eq!(inverted, X2(PalletInstance(5), OnlyChild).into()); + assert_eq!(inverted, (OnlyChild, PalletInstance(5)).into()); } #[test] From 41e7c476ed8ac925ed63c0d11c2512b4b0ff5e1f Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sun, 13 Mar 2022 11:25:54 +0100 Subject: [PATCH 083/231] Remove XCMv1 (#5094) * Remove XCMv1 * Remove XCMv1 * Formatting * Fixes * Fixes * Formatting --- xcm/pallet-xcm/src/tests.rs | 102 +++-- xcm/procedural/src/lib.rs | 6 +- xcm/procedural/src/v1.rs | 17 - xcm/procedural/src/v1/multilocation.rs | 179 -------- xcm/procedural/src/v2.rs | 183 ++++++++ xcm/procedural/src/v3.rs | 14 +- xcm/src/lib.rs | 93 +--- xcm/src/v1/mod.rs | 595 ------------------------- xcm/src/v1/order.rs | 240 ---------- xcm/src/v1/traits.rs | 277 ------------ xcm/src/{v1 => v2}/junction.rs | 0 xcm/src/v2/mod.rs | 348 +++++++-------- xcm/src/{v1 => v2}/multiasset.rs | 0 xcm/src/{v1 => v2}/multilocation.rs | 16 +- xcm/src/v3/junction.rs | 6 +- xcm/src/v3/multilocation.rs | 8 +- 16 files changed, 440 insertions(+), 1644 deletions(-) delete mode 100644 xcm/procedural/src/v1.rs delete mode 100644 xcm/procedural/src/v1/multilocation.rs create mode 100644 xcm/procedural/src/v2.rs delete mode 100644 xcm/src/v1/mod.rs delete mode 100644 xcm/src/v1/order.rs delete mode 100644 xcm/src/v1/traits.rs rename xcm/src/{v1 => v2}/junction.rs (100%) rename xcm/src/{v1 => v2}/multiasset.rs (100%) rename xcm/src/{v1 => v2}/multilocation.rs (98%) diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index 69b804fb9804..695431face9e 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -343,7 +343,7 @@ fn teleport_assets_works() { )] ); let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1); - let _check_v1_ok: xcm::v1::Xcm<()> = versioned_sent.try_into().unwrap(); + let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) @@ -385,7 +385,7 @@ fn limmited_teleport_assets_works() { )] ); let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1); - let _check_v1_ok: xcm::v1::Xcm<()> = versioned_sent.try_into().unwrap(); + let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) @@ -470,7 +470,7 @@ fn reserve_transfer_assets_works() { )] ); let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1); - let _check_v1_ok: xcm::v1::Xcm<()> = versioned_sent.try_into().unwrap(); + let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) @@ -516,7 +516,7 @@ fn limited_reserve_transfer_assets_works() { )] ); let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1); - let _check_v1_ok: xcm::v1::Xcm<()> = versioned_sent.try_into().unwrap(); + let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) @@ -714,7 +714,7 @@ fn basic_subscription_works() { let weight = BaseXcmWeight::get(); let mut message = Xcm::<()>(vec![ - // Remote supports XCM v1 + // Remote supports XCM v2 QueryResponse { query_id: 0, max_weight: 0, @@ -860,9 +860,9 @@ fn subscription_side_upgrades_work_with_notify() { new_test_ext_with_balances(vec![]).execute_with(|| { AdvertisedXcmVersion::set(1); - // An entry from a previous runtime with v1 XCM. - let v1_location = VersionedMultiLocation::V1(xcm::v1::Junction::Parachain(1001).into()); - VersionNotifyTargets::::insert(1, v1_location, (70, 0, 2)); + // An entry from a previous runtime with v2 XCM. + let v2_location = VersionedMultiLocation::V2(xcm::v2::Junction::Parachain(1001).into()); + VersionNotifyTargets::::insert(1, v2_location, (70, 0, 2)); let v3_location = Parachain(1003).into_versioned(); VersionNotifyTargets::::insert(3, v3_location, (72, 0, 2)); @@ -913,9 +913,9 @@ fn subscription_side_upgrades_work_with_notify() { #[test] fn subscription_side_upgrades_work_without_notify() { new_test_ext_with_balances(vec![]).execute_with(|| { - // An entry from a previous runtime with v1 XCM. - let v1_location = VersionedMultiLocation::V1(xcm::v1::Junction::Parachain(1001).into()); - VersionNotifyTargets::::insert(1, v1_location, (70, 0, 2)); + // An entry from a previous runtime with v2 XCM. + let v2_location = VersionedMultiLocation::V2(xcm::v2::Junction::Parachain(1001).into()); + VersionNotifyTargets::::insert(1, v2_location, (70, 0, 2)); let v3_location = Parachain(1003).into_versioned(); VersionNotifyTargets::::insert(3, v3_location, (72, 0, 2)); @@ -949,7 +949,7 @@ fn subscriber_side_subscription_works() { let weight = BaseXcmWeight::get(); let message = Xcm(vec![ - // Remote supports XCM v1 + // Remote supports XCM v2 QueryResponse { query_id: 0, max_weight: 0, @@ -991,89 +991,99 @@ fn subscriber_side_subscription_works() { #[test] fn auto_subscription_works() { new_test_ext_with_balances(vec![]).execute_with(|| { - let remote0 = Parachain(1000).into(); - let remote1 = Parachain(1001).into(); + let remote_v2: MultiLocation = Parachain(1000).into(); + let remote_v3: MultiLocation = Parachain(1001).into(); - assert_ok!(XcmPallet::force_default_xcm_version(Origin::root(), Some(1))); + assert_ok!(XcmPallet::force_default_xcm_version(Origin::root(), Some(2))); // Wrapping a version for a destination we don't know elicits a subscription. - let v1_msg = xcm::v1::Xcm::<()>::QueryResponse { - query_id: 1, - response: xcm::v1::Response::Assets(vec![].into()), - }; - let v2_msg = xcm::v2::Xcm::<()>(vec![xcm::v2::Instruction::Trap(0)]); + let msg_v2 = xcm::v2::Xcm::<()>(vec![xcm::v2::Instruction::Trap(0)]); + let msg_v3 = xcm::v3::Xcm::<()>(vec![xcm::v3::Instruction::ClearTopic]); assert_eq!( - XcmPallet::wrap_version(&remote0, v1_msg.clone()), - Ok(VersionedXcm::from(v1_msg.clone())), + XcmPallet::wrap_version(&remote_v2, msg_v2.clone()), + Ok(VersionedXcm::from(msg_v2.clone())), ); - assert_eq!(XcmPallet::wrap_version(&remote0, v2_msg.clone()), Err(())); - let expected = vec![(remote0.clone().into(), 2)]; + assert_eq!(XcmPallet::wrap_version(&remote_v2, msg_v3.clone()), Err(())); + + let expected = vec![(remote_v2.clone().into(), 2)]; assert_eq!(VersionDiscoveryQueue::::get().into_inner(), expected); - assert_eq!(XcmPallet::wrap_version(&remote0, v2_msg.clone()), Err(())); - assert_eq!(XcmPallet::wrap_version(&remote1, v2_msg.clone()), Err(())); - let expected = vec![(remote0.clone().into(), 3), (remote1.clone().into(), 1)]; + assert_eq!( + XcmPallet::wrap_version(&remote_v3, msg_v2.clone()), + Ok(VersionedXcm::from(msg_v2.clone())), + ); + assert_eq!(XcmPallet::wrap_version(&remote_v3, msg_v3.clone()), Err(())); + + let expected = vec![(remote_v2.clone().into(), 2), (remote_v3.clone().into(), 2)]; assert_eq!(VersionDiscoveryQueue::::get().into_inner(), expected); XcmPallet::on_initialize(1); assert_eq!( take_sent_xcm(), vec![( - remote0.clone(), + remote_v3.clone(), Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: 0 }]), )] ); - // Assume remote0 is working ok and XCM version 2. + // Assume remote_v3 is working ok and XCM version 3. let weight = BaseXcmWeight::get(); let message = Xcm(vec![ - // Remote supports XCM v2 + // Remote supports XCM v3 QueryResponse { query_id: 0, max_weight: 0, - response: Response::Version(2), + response: Response::Version(3), querier: None, }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(remote0.clone(), message, hash, weight); + let r = XcmExecutor::::execute_xcm(remote_v3.clone(), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); - // This message can now be sent to remote0 as it's v2. + // V2 messages can be sent to remote_v3 under XCM v3. + assert_eq!( + XcmPallet::wrap_version(&remote_v3, msg_v2.clone()), + Ok(VersionedXcm::from(msg_v2.clone()).into_version(3).unwrap()), + ); + // This message can now be sent to remote_v3 as it's v3. assert_eq!( - XcmPallet::wrap_version(&remote0, v2_msg.clone()), - Ok(VersionedXcm::from(v2_msg.clone())) + XcmPallet::wrap_version(&remote_v3, msg_v3.clone()), + Ok(VersionedXcm::from(msg_v3.clone())) ); XcmPallet::on_initialize(2); assert_eq!( take_sent_xcm(), vec![( - remote1.clone(), + remote_v2.clone(), Xcm(vec![SubscribeVersion { query_id: 1, max_response_weight: 0 }]), )] ); - // Assume remote1 is working ok and XCM version 1. + // Assume remote_v2 is working ok and XCM version 2. let weight = BaseXcmWeight::get(); let message = Xcm(vec![ - // Remote supports XCM v1 + // Remote supports XCM v2 QueryResponse { query_id: 1, max_weight: 0, - response: Response::Version(1), + response: Response::Version(2), querier: None, }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(remote1.clone(), message, hash, weight); + let r = XcmExecutor::::execute_xcm(remote_v2.clone(), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); - // v2 messages cannot be sent to remote1... - assert_eq!(XcmPallet::wrap_version(&remote1, v1_msg.clone()), Ok(VersionedXcm::V1(v1_msg))); - assert_eq!(XcmPallet::wrap_version(&remote1, v2_msg.clone()), Err(())); + // v3 messages cannot be sent to remote_v2... + assert_eq!( + XcmPallet::wrap_version(&remote_v2, msg_v2.clone()), + Ok(VersionedXcm::V2(msg_v2)) + ); + assert_eq!(XcmPallet::wrap_version(&remote_v2, msg_v3.clone()), Err(())); }) } @@ -1083,9 +1093,9 @@ fn subscription_side_upgrades_work_with_multistage_notify() { AdvertisedXcmVersion::set(1); // An entry from a previous runtime with v0 XCM. - let v1_location = VersionedMultiLocation::V1(xcm::v1::Junction::Parachain(1001).into()); - VersionNotifyTargets::::insert(1, v1_location, (70, 0, 1)); - let v2_location = VersionedMultiLocation::V1(xcm::v2::Junction::Parachain(1002).into()); + let v2_location = VersionedMultiLocation::V2(xcm::v2::Junction::Parachain(1001).into()); + VersionNotifyTargets::::insert(1, v2_location, (70, 0, 1)); + let v2_location = VersionedMultiLocation::V2(xcm::v2::Junction::Parachain(1002).into()); VersionNotifyTargets::::insert(2, v2_location, (71, 0, 1)); let v3_location = Parachain(1003).into_versioned(); VersionNotifyTargets::::insert(3, v3_location, (72, 0, 1)); diff --git a/xcm/procedural/src/lib.rs b/xcm/procedural/src/lib.rs index d16476c4f047..36181ccbd1fb 100644 --- a/xcm/procedural/src/lib.rs +++ b/xcm/procedural/src/lib.rs @@ -18,13 +18,13 @@ use proc_macro::TokenStream; -mod v1; +mod v2; mod v3; mod weight_info; #[proc_macro] -pub fn impl_conversion_functions_for_multilocation_v1(input: TokenStream) -> TokenStream { - v1::multilocation::generate_conversion_functions(input) +pub fn impl_conversion_functions_for_multilocation_v2(input: TokenStream) -> TokenStream { + v2::multilocation::generate_conversion_functions(input) .unwrap_or_else(syn::Error::into_compile_error) .into() } diff --git a/xcm/procedural/src/v1.rs b/xcm/procedural/src/v1.rs deleted file mode 100644 index 7774df4e9f8f..000000000000 --- a/xcm/procedural/src/v1.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 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 . - -pub mod multilocation; diff --git a/xcm/procedural/src/v1/multilocation.rs b/xcm/procedural/src/v1/multilocation.rs deleted file mode 100644 index 15a0d322a204..000000000000 --- a/xcm/procedural/src/v1/multilocation.rs +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright 2021 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 . - -use proc_macro2::{Span, TokenStream}; -use quote::{format_ident, quote}; -use syn::{Result, Token}; - -pub fn generate_conversion_functions(input: proc_macro::TokenStream) -> Result { - if !input.is_empty() { - return Err(syn::Error::new(Span::call_site(), "No arguments expected")) - } - - // Support up to 8 Parents in a tuple, assuming that most use cases don't go past 8 parents. - let from_tuples = generate_conversion_from_tuples(8); - let from_v3 = generate_conversion_from_v3(); - - Ok(quote! { - #from_tuples - #from_v3 - }) -} - -fn generate_conversion_from_tuples(max_parents: u8) -> TokenStream { - let mut from_tuples = (0..8usize) - .map(|num_junctions| { - let junctions = - (0..=num_junctions).map(|_| format_ident!("Junction")).collect::>(); - let idents = (0..=num_junctions).map(|i| format_ident!("j{}", i)).collect::>(); - let variant = &format_ident!("X{}", num_junctions + 1); - let array_size = num_junctions + 1; - - let mut from_tuple = quote! { - impl From<( #(#junctions,)* )> for MultiLocation { - fn from( ( #(#idents,)* ): ( #(#junctions,)* ) ) -> Self { - MultiLocation { parents: 0, interior: Junctions::#variant( #(#idents),* ) } - } - } - - impl From<(u8, #(#junctions),*)> for MultiLocation { - fn from( ( parents, #(#idents),* ): (u8, #(#junctions),* ) ) -> Self { - MultiLocation { parents, interior: Junctions::#variant( #(#idents),* ) } - } - } - - impl From<(Ancestor, #(#junctions),*)> for MultiLocation { - fn from( ( Ancestor(parents), #(#idents),* ): (Ancestor, #(#junctions),* ) ) -> Self { - MultiLocation { parents, interior: Junctions::#variant( #(#idents),* ) } - } - } - - impl From<[Junction; #array_size]> for MultiLocation { - fn from(j: [Junction; #array_size]) -> Self { - let [#(#idents),*] = j; - MultiLocation { parents: 0, interior: Junctions::#variant( #(#idents),* ) } - } - } - }; - - let from_parent_tuples = (1..=max_parents).map(|cur_parents| { - let parents = (0..cur_parents).map(|_| format_ident!("Parent")).collect::>(); - let underscores = - (0..cur_parents).map(|_| Token![_](Span::call_site())).collect::>(); - - quote! { - impl From<( #(#parents,)* #(#junctions),* )> for MultiLocation { - fn from( (#(#underscores,)* #(#idents),*): ( #(#parents,)* #(#junctions),* ) ) -> Self { - MultiLocation { parents: #cur_parents, interior: Junctions::#variant( #(#idents),* ) } - } - } - } - }); - - from_tuple.extend(from_parent_tuples); - from_tuple - }) - .collect::(); - - let from_parent_junctions_tuples = (1..=max_parents).map(|cur_parents| { - let parents = (0..cur_parents).map(|_| format_ident!("Parent")).collect::>(); - let underscores = - (0..cur_parents).map(|_| Token![_](Span::call_site())).collect::>(); - - quote! { - impl From<( #(#parents,)* Junctions )> for MultiLocation { - fn from( (#(#underscores,)* junctions): ( #(#parents,)* Junctions ) ) -> Self { - MultiLocation { parents: #cur_parents, interior: junctions } - } - } - } - }); - from_tuples.extend(from_parent_junctions_tuples); - - quote! { - impl From for MultiLocation { - fn from(junctions: Junctions) -> Self { - MultiLocation { parents: 0, interior: junctions } - } - } - - impl From<(u8, Junctions)> for MultiLocation { - fn from((parents, interior): (u8, Junctions)) -> Self { - MultiLocation { parents, interior } - } - } - - impl From<(Ancestor, Junctions)> for MultiLocation { - fn from((Ancestor(parents), interior): (Ancestor, Junctions)) -> Self { - MultiLocation { parents, interior } - } - } - - impl From<()> for MultiLocation { - fn from(_: ()) -> Self { - MultiLocation { parents: 0, interior: Junctions::Here } - } - } - - impl From<(u8,)> for MultiLocation { - fn from((parents,): (u8,)) -> Self { - MultiLocation { parents, interior: Junctions::Here } - } - } - - impl From for MultiLocation { - fn from(x: Junction) -> Self { - MultiLocation { parents: 0, interior: Junctions::X1(x) } - } - } - - impl From<[Junction; 0]> for MultiLocation { - fn from(_: [Junction; 0]) -> Self { - MultiLocation { parents: 0, interior: Junctions::Here } - } - } - - #from_tuples - } -} - -fn generate_conversion_from_v3() -> TokenStream { - let match_variants = (0..8u8) - .map(|cur_num| { - let num_ancestors = cur_num + 1; - let variant = format_ident!("X{}", num_ancestors); - let idents = (0..=cur_num).map(|i| format_ident!("j{}", i)).collect::>(); - - quote! { - crate::v3::Junctions::#variant( #(#idents),* ) => - #variant( #( core::convert::TryInto::try_into(#idents)? ),* ), - } - }) - .collect::(); - - quote! { - impl core::convert::TryFrom for Junctions { - type Error = (); - fn try_from(mut new: crate::v3::Junctions) -> core::result::Result { - use Junctions::*; - Ok(match new { - crate::v3::Junctions::Here => Here, - #match_variants - }) - } - } - } -} diff --git a/xcm/procedural/src/v2.rs b/xcm/procedural/src/v2.rs new file mode 100644 index 000000000000..6fbeeefeb128 --- /dev/null +++ b/xcm/procedural/src/v2.rs @@ -0,0 +1,183 @@ +// Copyright 2021 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 . + +pub mod multilocation { + use proc_macro2::{Span, TokenStream}; + use quote::{format_ident, quote}; + use syn::{Result, Token}; + + pub fn generate_conversion_functions(input: proc_macro::TokenStream) -> Result { + if !input.is_empty() { + return Err(syn::Error::new(Span::call_site(), "No arguments expected")) + } + + // Support up to 8 Parents in a tuple, assuming that most use cases don't go past 8 parents. + let from_tuples = generate_conversion_from_tuples(8); + let from_v3 = generate_conversion_from_v3(); + + Ok(quote! { + #from_tuples + #from_v3 + }) + } + + fn generate_conversion_from_tuples(max_parents: u8) -> TokenStream { + let mut from_tuples = (0..8usize) + .map(|num_junctions| { + let junctions = + (0..=num_junctions).map(|_| format_ident!("Junction")).collect::>(); + let idents = + (0..=num_junctions).map(|i| format_ident!("j{}", i)).collect::>(); + let variant = &format_ident!("X{}", num_junctions + 1); + let array_size = num_junctions + 1; + + let mut from_tuple = quote! { + impl From<( #(#junctions,)* )> for MultiLocation { + fn from( ( #(#idents,)* ): ( #(#junctions,)* ) ) -> Self { + MultiLocation { parents: 0, interior: Junctions::#variant( #(#idents),* ) } + } + } + + impl From<(u8, #(#junctions),*)> for MultiLocation { + fn from( ( parents, #(#idents),* ): (u8, #(#junctions),* ) ) -> Self { + MultiLocation { parents, interior: Junctions::#variant( #(#idents),* ) } + } + } + + impl From<(Ancestor, #(#junctions),*)> for MultiLocation { + fn from( ( Ancestor(parents), #(#idents),* ): (Ancestor, #(#junctions),* ) ) -> Self { + MultiLocation { parents, interior: Junctions::#variant( #(#idents),* ) } + } + } + + impl From<[Junction; #array_size]> for MultiLocation { + fn from(j: [Junction; #array_size]) -> Self { + let [#(#idents),*] = j; + MultiLocation { parents: 0, interior: Junctions::#variant( #(#idents),* ) } + } + } + }; + + let from_parent_tuples = (1..=max_parents).map(|cur_parents| { + let parents = + (0..cur_parents).map(|_| format_ident!("Parent")).collect::>(); + let underscores = + (0..cur_parents).map(|_| Token![_](Span::call_site())).collect::>(); + + quote! { + impl From<( #(#parents,)* #(#junctions),* )> for MultiLocation { + fn from( (#(#underscores,)* #(#idents),*): ( #(#parents,)* #(#junctions),* ) ) -> Self { + MultiLocation { parents: #cur_parents, interior: Junctions::#variant( #(#idents),* ) } + } + } + } + }); + + from_tuple.extend(from_parent_tuples); + from_tuple + }) + .collect::(); + + let from_parent_junctions_tuples = (1..=max_parents).map(|cur_parents| { + let parents = (0..cur_parents).map(|_| format_ident!("Parent")).collect::>(); + let underscores = + (0..cur_parents).map(|_| Token![_](Span::call_site())).collect::>(); + + quote! { + impl From<( #(#parents,)* Junctions )> for MultiLocation { + fn from( (#(#underscores,)* junctions): ( #(#parents,)* Junctions ) ) -> Self { + MultiLocation { parents: #cur_parents, interior: junctions } + } + } + } + }); + from_tuples.extend(from_parent_junctions_tuples); + + quote! { + impl From for MultiLocation { + fn from(junctions: Junctions) -> Self { + MultiLocation { parents: 0, interior: junctions } + } + } + + impl From<(u8, Junctions)> for MultiLocation { + fn from((parents, interior): (u8, Junctions)) -> Self { + MultiLocation { parents, interior } + } + } + + impl From<(Ancestor, Junctions)> for MultiLocation { + fn from((Ancestor(parents), interior): (Ancestor, Junctions)) -> Self { + MultiLocation { parents, interior } + } + } + + impl From<()> for MultiLocation { + fn from(_: ()) -> Self { + MultiLocation { parents: 0, interior: Junctions::Here } + } + } + + impl From<(u8,)> for MultiLocation { + fn from((parents,): (u8,)) -> Self { + MultiLocation { parents, interior: Junctions::Here } + } + } + + impl From for MultiLocation { + fn from(x: Junction) -> Self { + MultiLocation { parents: 0, interior: Junctions::X1(x) } + } + } + + impl From<[Junction; 0]> for MultiLocation { + fn from(_: [Junction; 0]) -> Self { + MultiLocation { parents: 0, interior: Junctions::Here } + } + } + + #from_tuples + } + } + + fn generate_conversion_from_v3() -> TokenStream { + let match_variants = (0..8u8) + .map(|cur_num| { + let num_ancestors = cur_num + 1; + let variant = format_ident!("X{}", num_ancestors); + let idents = (0..=cur_num).map(|i| format_ident!("j{}", i)).collect::>(); + + quote! { + crate::v3::Junctions::#variant( #(#idents),* ) => + #variant( #( core::convert::TryInto::try_into(#idents)? ),* ), + } + }) + .collect::(); + + quote! { + impl core::convert::TryFrom for Junctions { + type Error = (); + fn try_from(mut new: crate::v3::Junctions) -> core::result::Result { + use Junctions::*; + Ok(match new { + crate::v3::Junctions::Here => Here, + #match_variants + }) + } + } + } + } +} diff --git a/xcm/procedural/src/v3.rs b/xcm/procedural/src/v3.rs index eeaa76da0985..0897481d0949 100644 --- a/xcm/procedural/src/v3.rs +++ b/xcm/procedural/src/v3.rs @@ -128,11 +128,11 @@ pub mod junctions { } // Support up to 8 Parents in a tuple, assuming that most use cases don't go past 8 parents. - let from_v1 = generate_conversion_from_v1(MAX_JUNCTIONS); + let from_v2 = generate_conversion_from_v2(MAX_JUNCTIONS); let from_tuples = generate_conversion_from_tuples(MAX_JUNCTIONS); Ok(quote! { - #from_v1 + #from_v2 #from_tuples }) } @@ -156,7 +156,7 @@ pub mod junctions { .collect() } - fn generate_conversion_from_v1(max_junctions: usize) -> TokenStream { + fn generate_conversion_from_v2(max_junctions: usize) -> TokenStream { let match_variants = (0..max_junctions) .map(|cur_num| { let num_ancestors = cur_num + 1; @@ -164,19 +164,19 @@ pub mod junctions { let idents = (0..=cur_num).map(|i| format_ident!("j{}", i)).collect::>(); quote! { - crate::v1::Junctions::#variant( #(#idents),* ) => + crate::v2::Junctions::#variant( #(#idents),* ) => #variant( #( core::convert::TryInto::try_into(#idents)? ),* ), } }) .collect::(); quote! { - impl core::convert::TryFrom for Junctions { + impl core::convert::TryFrom for Junctions { type Error = (); - fn try_from(mut old: crate::v1::Junctions) -> core::result::Result { + fn try_from(mut old: crate::v2::Junctions) -> core::result::Result { use Junctions::*; Ok(match old { - crate::v1::Junctions::Here => Here, + crate::v2::Junctions::Here => Here, #match_variants }) } diff --git a/xcm/src/lib.rs b/xcm/src/lib.rs index bef1fa7e29fe..2c5a2552fbe1 100644 --- a/xcm/src/lib.rs +++ b/xcm/src/lib.rs @@ -31,7 +31,6 @@ use derivative::Derivative; use parity_scale_codec::{Decode, Encode, Error as CodecError, Input, MaxEncodedLen}; use scale_info::TypeInfo; -pub mod v1; pub mod v2; pub mod v3; @@ -136,7 +135,7 @@ macro_rules! versioned_type { }; ($(#[$attr:meta])* pub enum $n:ident { - V1($v1:ty), + V2($v2:ty), V3($v3:ty), }) => { #[derive(Derivative, Encode, Decode, TypeInfo)] @@ -151,7 +150,7 @@ macro_rules! versioned_type { $(#[$attr])* pub enum $n { #[codec(index = 0)] - V1($v1), + V2($v2), #[codec(index = 1)] V3($v3), } @@ -160,10 +159,10 @@ macro_rules! versioned_type { >::try_as(&self) } } - impl TryAs<$v1> for $n { - fn try_as(&self) -> Result<&$v1, ()> { + impl TryAs<$v2> for $n { + fn try_as(&self) -> Result<&$v2, ()> { match &self { - Self::V1(ref x) => Ok(x), + Self::V2(ref x) => Ok(x), _ => Err(()), } } @@ -179,15 +178,15 @@ macro_rules! versioned_type { impl IntoVersion for $n { fn into_version(self, n: Version) -> Result { Ok(match n { - 1 | 2 => Self::V1(self.try_into()?), + 1 | 2 => Self::V2(self.try_into()?), 3 => Self::V3(self.try_into()?), _ => return Err(()), }) } } - impl From<$v1> for $n { - fn from(x: $v1) -> Self { - $n::V1(x) + impl From<$v2> for $n { + fn from(x: $v2) -> Self { + $n::V2(x) } } impl> From for $n { @@ -195,12 +194,12 @@ macro_rules! versioned_type { $n::V3(x.into()) } } - impl TryFrom<$n> for $v1 { + impl TryFrom<$n> for $v2 { type Error = (); fn try_from(x: $n) -> Result { use $n::*; match x { - V1(x) => Ok(x), + V2(x) => Ok(x), V3(x) => x.try_into(), } } @@ -210,7 +209,7 @@ macro_rules! versioned_type { fn try_from(x: $n) -> Result { use $n::*; match x { - V1(x) => x.try_into(), + V2(x) => x.try_into(), V3(x) => Ok(x), } } @@ -223,7 +222,6 @@ macro_rules! versioned_type { }; ($(#[$attr:meta])* pub enum $n:ident { - V1($v1:ty), V2($v2:ty), V3($v3:ty), }) => { @@ -233,8 +231,6 @@ macro_rules! versioned_type { #[codec(decode_bound())] $(#[$attr])* pub enum $n { - #[codec(index = 0)] - V1($v1), #[codec(index = 1)] V2($v2), #[codec(index = 2)] @@ -245,14 +241,6 @@ macro_rules! versioned_type { >::try_as(&self) } } - impl TryAs<$v1> for $n { - fn try_as(&self) -> Result<&$v1, ()> { - match &self { - Self::V1(ref x) => Ok(x), - _ => Err(()), - } - } - } impl TryAs<$v2> for $n { fn try_as(&self) -> Result<&$v2, ()> { match &self { @@ -272,18 +260,12 @@ macro_rules! versioned_type { impl IntoVersion for $n { fn into_version(self, n: Version) -> Result { Ok(match n { - 1 => Self::V1(self.try_into()?), 2 => Self::V2(self.try_into()?), 3 => Self::V3(self.try_into()?), _ => return Err(()), }) } } - impl From<$v1> for $n { - fn from(x: $v1) -> Self { - $n::V1(x) - } - } impl From<$v2> for $n { fn from(x: $v2) -> Self { $n::V2(x) @@ -294,23 +276,11 @@ macro_rules! versioned_type { $n::V3(x.into()) } } - impl TryFrom<$n> for $v1 { - type Error = (); - fn try_from(x: $n) -> Result { - use $n::*; - match x { - V1(x) => Ok(x), - V2(x) => x.try_into(), - V3(x) => V2(x.try_into()?).try_into(), - } - } - } impl TryFrom<$n> for $v2 { type Error = (); fn try_from(x: $n) -> Result { use $n::*; match x { - V1(x) => x.try_into(), V2(x) => Ok(x), V3(x) => x.try_into(), } @@ -321,7 +291,6 @@ macro_rules! versioned_type { fn try_from(x: $n) -> Result { use $n::*; match x { - V1(x) => V2(x.try_into()?).try_into(), V2(x) => x.try_into(), V3(x) => Ok(x), } @@ -345,7 +314,6 @@ versioned_type! { versioned_type! { /// A single version's `Response` value, together with its version code. pub enum VersionedResponse { - V1(v1::Response), V2(v2::Response), V3(v3::Response), } @@ -355,7 +323,7 @@ versioned_type! { /// A single `MultiLocation` value, together with its version code. #[derive(Ord, PartialOrd)] pub enum VersionedMultiLocation { - V1(v1::MultiLocation), + V2(v2::MultiLocation), V3(v3::MultiLocation), } } @@ -363,7 +331,7 @@ versioned_type! { versioned_type! { /// A single `InteriorMultiLocation` value, together with its version code. pub enum VersionedInteriorMultiLocation { - V1(v1::InteriorMultiLocation), + V2(v2::InteriorMultiLocation), V3(v3::InteriorMultiLocation), } } @@ -371,7 +339,7 @@ versioned_type! { versioned_type! { /// A single `MultiAsset` value, together with its version code. pub enum VersionedMultiAsset { - V1(v1::MultiAsset), + V2(v2::MultiAsset), V3(v3::MultiAsset), } } @@ -379,7 +347,7 @@ versioned_type! { versioned_type! { /// A single `MultiAssets` value, together with its version code. pub enum VersionedMultiAssets { - V1(v1::MultiAssets), + V2(v2::MultiAssets), V3(v3::MultiAssets), } } @@ -391,8 +359,6 @@ versioned_type! { #[codec(decode_bound())] #[scale_info(bounds(), skip_type_params(Call))] pub enum VersionedXcm { - #[codec(index = 0)] - V1(v1::Xcm), #[codec(index = 1)] V2(v2::Xcm), #[codec(index = 2)] @@ -402,7 +368,6 @@ pub enum VersionedXcm { impl IntoVersion for VersionedXcm { fn into_version(self, n: Version) -> Result { Ok(match n { - 1 => Self::V1(self.try_into()?), 2 => Self::V2(self.try_into()?), 3 => Self::V3(self.try_into()?), _ => return Err(()), @@ -410,12 +375,6 @@ impl IntoVersion for VersionedXcm { } } -impl From> for VersionedXcm { - fn from(x: v1::Xcm) -> Self { - VersionedXcm::V1(x) - } -} - impl From> for VersionedXcm { fn from(x: v2::Xcm) -> Self { VersionedXcm::V2(x) @@ -428,24 +387,11 @@ impl From> for VersionedXcm { } } -impl TryFrom> for v1::Xcm { - type Error = (); - fn try_from(x: VersionedXcm) -> Result { - use VersionedXcm::*; - match x { - V1(x) => Ok(x), - V2(x) => x.try_into(), - V3(x) => V2(x.try_into()?).try_into(), - } - } -} - impl TryFrom> for v2::Xcm { type Error = (); fn try_from(x: VersionedXcm) -> Result { use VersionedXcm::*; match x { - V1(x) => x.try_into(), V2(x) => Ok(x), V3(x) => x.try_into(), } @@ -457,7 +403,6 @@ impl TryFrom> for v3::Xcm { fn try_from(x: VersionedXcm) -> Result { use VersionedXcm::*; match x { - V1(x) => V2(x.try_into()?).try_into(), V2(x) => x.try_into(), V3(x) => Ok(x), } @@ -522,12 +467,6 @@ pub mod prelude { } pub mod opaque { - pub mod v1 { - // Everything from v1 - pub use crate::v1::*; - // Then override with the opaque types in v1 - pub use crate::v1::opaque::{Order, Xcm}; - } pub mod v2 { // Everything from v2 pub use crate::v2::*; diff --git a/xcm/src/v1/mod.rs b/xcm/src/v1/mod.rs deleted file mode 100644 index 01cc80fdf96b..000000000000 --- a/xcm/src/v1/mod.rs +++ /dev/null @@ -1,595 +0,0 @@ -// Copyright 2020 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 . - -//! # XCM Version 1 -//! Version 1 of the Cross-Consensus Message format data structures. The comprehensive list of -//! changes can be found in -//! [this PR description](https://github.com/paritytech/polkadot/pull/2815#issue-608567900). -//! -//! ## Changes to be aware of -//! Most changes should automatically be resolved via the conversion traits (i.e. `TryFrom` and -//! `From`). The list here is mostly for incompatible changes that result in an `Err(())` when -//! attempting to convert XCM objects from v0. -//! -//! ### Junction -//! - `v0::Junction::Parent` cannot be converted to v1, because the way we represent parents in v1 -//! has changed - instead of being a property of the junction, v1 `MultiLocation`s now have an -//! extra field representing the number of parents that the `MultiLocation` contains. -//! -//! ### `MultiLocation` -//! - The `try_from` conversion method will always canonicalize the v0 `MultiLocation` before -//! attempting to do the proper conversion. Since canonicalization is not a fallible operation, -//! we do not expect v0 `MultiLocation` to ever fail to be upgraded to v1. -//! -//! ### `MultiAsset` -//! - Stronger typing to differentiate between a single class of `MultiAsset` and several classes -//! of `MultiAssets` is introduced. As the name suggests, a `Vec` that is used on all -//! APIs will instead be using a new type called `MultiAssets` (note the `s`). -//! - All `MultiAsset` variants whose name contains "All" in it, namely `v0::MultiAsset::All`, -//! `v0::MultiAsset::AllFungible`, `v0::MultiAsset::AllNonFungible`, -//! `v0::MultiAsset::AllAbstractFungible`, `v0::MultiAsset::AllAbstractNonFungible`, -//! `v0::MultiAsset::AllConcreteFungible` and `v0::MultiAsset::AllConcreteNonFungible`, will fail -//! to convert to v1 `MultiAsset`, since v1 does not contain these variants. -//! - Similarly, all `MultiAsset` variants whose name contains "All" in it can be converted into a -//! `WildMultiAsset`. -//! - `v0::MultiAsset::None` is not represented at all in v1. -//! -//! ### XCM -//! - No special attention necessary -//! -//! ### Order -//! - `v1::Order::DepositAsset` and `v1::Order::DepositReserveAsset` both introduced a new -//! `max_asset` field that limits the maximum classes of assets that can be deposited. During -//! conversion from v0, the `max_asset` field defaults to 1. -//! - v1 Orders that contain `MultiAsset` as argument(s) will need to explicitly specify the amount -//! and details of assets. This is to prevent accidental misuse of `All` to possibly transfer, -//! spend or otherwise perform unintended operations on `All` assets. -//! - v1 Orders that do allow the notion of `All` to be used as wildcards, will instead use a new -//! type called `MultiAssetFilter`. - -use crate::{ - v2::{Instruction, Response as NewResponse, Xcm as NewXcm}, - v3::{BodyId as NewBodyId, BodyPart as NewBodyPart, NetworkId as NewNetworkId}, - DoubleEncoded, -}; -use alloc::vec::Vec; -use core::{ - convert::{TryFrom, TryInto}, - fmt::Debug, - result, -}; -use derivative::Derivative; -use parity_scale_codec::{self, Decode, Encode}; -use scale_info::TypeInfo; - -mod junction; -mod multiasset; -mod multilocation; -mod order; -mod traits; // the new multiasset. - -pub use junction::Junction; -pub use multiasset::{ - AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssetFilter, MultiAssets, - WildFungibility, WildMultiAsset, -}; -pub use multilocation::{ - Ancestor, AncestorThen, InteriorMultiLocation, Junctions, MultiLocation, Parent, ParentThen, -}; -pub use order::Order; -pub use traits::{Error, ExecuteXcm, Outcome, Result, SendXcm}; - -/// A prelude for importing all types typically used when interacting with XCM messages. -pub mod prelude { - pub use super::{ - junction::Junction::{self, *}, - opaque, - order::Order::{self, *}, - Ancestor, AncestorThen, - AssetId::{self, *}, - AssetInstance::{self, *}, - BodyId, BodyPart, Error as XcmError, ExecuteXcm, - Fungibility::{self, *}, - InteriorMultiLocation, - Junctions::{self, *}, - MultiAsset, - MultiAssetFilter::{self, *}, - MultiAssets, MultiLocation, - NetworkId::{self, *}, - OriginKind, Outcome, Parent, ParentThen, Response, Result as XcmResult, SendXcm, - WildFungibility::{self, Fungible as WildFungible, NonFungible as WildNonFungible}, - WildMultiAsset::{self, *}, - Xcm::{self, *}, - }; -} - -/// Basically just the XCM (more general) version of `ParachainDispatchOrigin`. -#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] -pub enum OriginKind { - /// Origin should just be the native dispatch origin representation for the sender in the - /// local runtime framework. For Cumulus/Frame chains this is the `Parachain` or `Relay` origin - /// if coming from a chain, though there may be others if the `MultiLocation` XCM origin has a - /// primary/native dispatch origin form. - Native, - - /// Origin should just be the standard account-based origin with the sovereign account of - /// the sender. For Cumulus/Frame chains, this is the `Signed` origin. - SovereignAccount, - - /// Origin should be the super-user. For Cumulus/Frame chains, this is the `Root` origin. - /// This will not usually be an available option. - Superuser, - - /// Origin should be interpreted as an XCM native origin and the `MultiLocation` should be - /// encoded directly in the dispatch origin unchanged. For Cumulus/Frame chains, this will be - /// the `pallet_xcm::Origin::Xcm` type. - Xcm, -} - -/// A global identifier of an account-bearing consensus system. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] -pub enum NetworkId { - /// Unidentified/any. - Any, - /// Some named network. - Named(Vec), - /// The Polkadot Relay chain - Polkadot, - /// Kusama. - Kusama, -} - -impl TryInto for Option { - type Error = (); - fn try_into(self) -> result::Result { - use NewNetworkId::*; - Ok(match self { - None => NetworkId::Any, - Some(Polkadot) => NetworkId::Polkadot, - Some(Kusama) => NetworkId::Kusama, - _ => return Err(()), - }) - } -} - -/// An identifier of a pluralistic body. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] -pub enum BodyId { - /// The only body in its context. - Unit, - /// A named body. - Named(Vec), - /// An indexed body. - Index(#[codec(compact)] u32), - /// The unambiguous executive body (for Polkadot, this would be the Polkadot council). - Executive, - /// The unambiguous technical body (for Polkadot, this would be the Technical Committee). - Technical, - /// The unambiguous legislative body (for Polkadot, this could be considered the opinion of a majority of - /// lock-voters). - Legislative, - /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it - /// may be considered as that). - Judicial, -} - -impl From for BodyId { - fn from(n: NewBodyId) -> Self { - use NewBodyId::*; - match n { - Unit => Self::Unit, - Moniker(n) => Self::Named(n[..].to_vec()), - Index(n) => Self::Index(n), - Executive => Self::Executive, - Technical => Self::Technical, - Legislative => Self::Legislative, - Judicial => Self::Judicial, - } - } -} - -/// A part of a pluralistic body. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] -pub enum BodyPart { - /// The body's declaration, under whatever means it decides. - Voice, - /// A given number of members of the body. - Members { - #[codec(compact)] - count: u32, - }, - /// A given number of members of the body, out of some larger caucus. - Fraction { - #[codec(compact)] - nom: u32, - #[codec(compact)] - denom: u32, - }, - /// No less than the given proportion of members of the body. - AtLeastProportion { - #[codec(compact)] - nom: u32, - #[codec(compact)] - denom: u32, - }, - /// More than than the given proportion of members of the body. - MoreThanProportion { - #[codec(compact)] - nom: u32, - #[codec(compact)] - denom: u32, - }, -} - -impl BodyPart { - /// Returns `true` if the part represents a strict majority (> 50%) of the body in question. - pub fn is_majority(&self) -> bool { - match self { - BodyPart::Fraction { nom, denom } if *nom * 2 > *denom => true, - BodyPart::AtLeastProportion { nom, denom } if *nom * 2 > *denom => true, - BodyPart::MoreThanProportion { nom, denom } if *nom * 2 >= *denom => true, - _ => false, - } - } -} - -impl From for BodyPart { - fn from(n: NewBodyPart) -> Self { - use NewBodyPart::*; - match n { - Voice => Self::Voice, - Members { count } => Self::Members { count }, - Fraction { nom, denom } => Self::Fraction { nom, denom }, - AtLeastProportion { nom, denom } => Self::AtLeastProportion { nom, denom }, - MoreThanProportion { nom, denom } => Self::MoreThanProportion { nom, denom }, - } - } -} - -/// Response data to a query. -#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] -pub enum Response { - /// Some assets. - Assets(MultiAssets), - /// An XCM version. - Version(super::Version), -} - -/// Cross-Consensus Message: A message from one consensus system to another. -/// -/// Consensus systems that may send and receive messages include blockchains and smart contracts. -/// -/// All messages are delivered from a known *origin*, expressed as a `MultiLocation`. -/// -/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the outer -/// XCM format, known as `VersionedXcm`. -#[derive(Derivative, Encode, Decode, TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -#[scale_info(bounds(), skip_type_params(Call))] -pub enum Xcm { - /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into `holding`. Execute the - /// orders (`effects`). - /// - /// - `assets`: The asset(s) to be withdrawn into holding. - /// - `effects`: The order(s) to execute on the holding register. - /// - /// Kind: *Instruction*. - /// - /// Errors: - #[codec(index = 0)] - WithdrawAsset { assets: MultiAssets, effects: Vec> }, - - /// Asset(s) (`assets`) have been received into the ownership of this system on the `origin` system. - /// - /// Some orders are given (`effects`) which should be executed once the corresponding derivative assets have - /// been placed into `holding`. - /// - /// - `assets`: The asset(s) that are minted into holding. - /// - `effects`: The order(s) to execute on the holding register. - /// - /// Safety: `origin` must be trusted to have received and be storing `assets` such that they may later be - /// withdrawn should this system send a corresponding message. - /// - /// Kind: *Trusted Indication*. - /// - /// Errors: - #[codec(index = 1)] - ReserveAssetDeposited { assets: MultiAssets, effects: Vec> }, - - /// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets should be - /// created on this system. - /// - /// Some orders are given (`effects`) which should be executed once the corresponding derivative assets have - /// been placed into the Holding Register. - /// - /// - `assets`: The asset(s) that are minted into the Holding Register. - /// - `effects`: The order(s) to execute on the Holding Register. - /// - /// Safety: `origin` must be trusted to have irrevocably destroyed the corresponding `assets` prior as a consequence - /// of sending this message. - /// - /// Kind: *Trusted Indication*. - /// - /// Errors: - #[codec(index = 2)] - ReceiveTeleportedAsset { assets: MultiAssets, effects: Vec> }, - - /// Indication of the contents of the holding register corresponding to the `QueryHolding` order of `query_id`. - /// - /// - `query_id`: The identifier of the query that resulted in this message being sent. - /// - `assets`: The message content. - /// - /// Safety: No concerns. - /// - /// Kind: *Information*. - /// - /// Errors: - #[codec(index = 3)] - QueryResponse { - #[codec(compact)] - query_id: u64, - response: Response, - }, - - /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets under the - /// ownership of `beneficiary`. - /// - /// - `assets`: The asset(s) to be withdrawn. - /// - `beneficiary`: The new owner for the assets. - /// - /// Safety: No concerns. - /// - /// Kind: *Instruction*. - /// - /// Errors: - #[codec(index = 4)] - TransferAsset { assets: MultiAssets, beneficiary: MultiLocation }, - - /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets under the - /// ownership of `dest` within this consensus system (i.e. its sovereign account). - /// - /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the given `effects`. - /// - /// - `assets`: The asset(s) to be withdrawn. - /// - `dest`: The location whose sovereign account will own the assets and thus the effective beneficiary for the - /// assets and the notification target for the reserve asset deposit message. - /// - `effects`: The orders that should be contained in the `ReserveAssetDeposited` which is sent onwards to - /// `dest`. - /// - /// Safety: No concerns. - /// - /// Kind: *Instruction*. - /// - /// Errors: - #[codec(index = 5)] - TransferReserveAsset { assets: MultiAssets, dest: MultiLocation, effects: Vec> }, - - /// Apply the encoded transaction `call`, whose dispatch-origin should be `origin` as expressed by the kind - /// of origin `origin_type`. - /// - /// - `origin_type`: The means of expressing the message origin as a dispatch origin. - /// - `max_weight`: The weight of `call`; this should be at least the chain's calculated weight and will - /// be used in the weight determination arithmetic. - /// - `call`: The encoded transaction to be applied. - /// - /// Safety: No concerns. - /// - /// Kind: *Instruction*. - /// - /// Errors: - #[codec(index = 6)] - Transact { origin_type: OriginKind, require_weight_at_most: u64, call: DoubleEncoded }, - - /// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the - /// relay-chain to a para. - /// - /// - `sender`: The sender in the to-be opened channel. Also, the initiator of the channel opening. - /// - `max_message_size`: The maximum size of a message proposed by the sender. - /// - `max_capacity`: The maximum number of messages that can be queued in the channel. - /// - /// Safety: The message should originate directly from the relay-chain. - /// - /// Kind: *System Notification* - #[codec(index = 7)] - HrmpNewChannelOpenRequest { - #[codec(compact)] - sender: u32, - #[codec(compact)] - max_message_size: u32, - #[codec(compact)] - max_capacity: u32, - }, - - /// A message to notify about that a previously sent open channel request has been accepted by - /// the recipient. That means that the channel will be opened during the next relay-chain session - /// change. This message is meant to be sent by the relay-chain to a para. - /// - /// Safety: The message should originate directly from the relay-chain. - /// - /// Kind: *System Notification* - /// - /// Errors: - #[codec(index = 8)] - HrmpChannelAccepted { - #[codec(compact)] - recipient: u32, - }, - - /// A message to notify that the other party in an open channel decided to close it. In particular, - /// `initiator` is going to close the channel opened from `sender` to the `recipient`. The close - /// will be enacted at the next relay-chain session change. This message is meant to be sent by - /// the relay-chain to a para. - /// - /// Safety: The message should originate directly from the relay-chain. - /// - /// Kind: *System Notification* - /// - /// Errors: - #[codec(index = 9)] - HrmpChannelClosing { - #[codec(compact)] - initiator: u32, - #[codec(compact)] - sender: u32, - #[codec(compact)] - recipient: u32, - }, - - /// A message to indicate that the embedded XCM is actually arriving on behalf of some consensus - /// location within the origin. - /// - /// Kind: *Instruction* - /// - /// Errors: - #[codec(index = 10)] - RelayedFrom { who: InteriorMultiLocation, message: alloc::boxed::Box> }, - - /// Ask the destination system to respond with the most recent version of XCM that they - /// support in a `QueryResponse` instruction. Any changes to this should also elicit similar - /// responses when they happen. - /// - /// Kind: *Instruction* - #[codec(index = 11)] - SubscribeVersion { - #[codec(compact)] - query_id: u64, - #[codec(compact)] - max_response_weight: u64, - }, - - /// Cancel the effect of a previous `SubscribeVersion` instruction. - /// - /// Kind: *Instruction* - #[codec(index = 12)] - UnsubscribeVersion, -} - -impl Xcm { - pub fn into(self) -> Xcm { - Xcm::from(self) - } - pub fn from(xcm: Xcm) -> Self { - use Xcm::*; - match xcm { - WithdrawAsset { assets, effects } => - WithdrawAsset { assets, effects: effects.into_iter().map(Order::into).collect() }, - ReserveAssetDeposited { assets, effects } => ReserveAssetDeposited { - assets, - effects: effects.into_iter().map(Order::into).collect(), - }, - ReceiveTeleportedAsset { assets, effects } => ReceiveTeleportedAsset { - assets, - effects: effects.into_iter().map(Order::into).collect(), - }, - QueryResponse { query_id, response } => QueryResponse { query_id, response }, - TransferAsset { assets, beneficiary } => TransferAsset { assets, beneficiary }, - TransferReserveAsset { assets, dest, effects } => - TransferReserveAsset { assets, dest, effects }, - HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => - HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, - HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient }, - HrmpChannelClosing { initiator, sender, recipient } => - HrmpChannelClosing { initiator, sender, recipient }, - Transact { origin_type, require_weight_at_most, call } => - Transact { origin_type, require_weight_at_most, call: call.into() }, - RelayedFrom { who, message } => - RelayedFrom { who, message: alloc::boxed::Box::new((*message).into()) }, - SubscribeVersion { query_id, max_response_weight } => - SubscribeVersion { query_id, max_response_weight }, - UnsubscribeVersion => UnsubscribeVersion, - } - } -} - -pub mod opaque { - /// The basic concrete type of `generic::Xcm`, which doesn't make any assumptions about the format of a - /// call other than it is pre-encoded. - pub type Xcm = super::Xcm<()>; - - pub use super::order::opaque::*; -} - -impl TryFrom> for Xcm { - type Error = (); - fn try_from(old: NewXcm) -> result::Result, ()> { - use Xcm::*; - let mut iter = old.0.into_iter(); - let instruction = iter.next().ok_or(())?; - Ok(match instruction { - Instruction::WithdrawAsset(assets) => { - let effects = iter.map(Order::try_from).collect::>()?; - WithdrawAsset { assets, effects } - }, - Instruction::ReserveAssetDeposited(assets) => { - if !matches!(iter.next(), Some(Instruction::ClearOrigin)) { - return Err(()) - } - let effects = iter.map(Order::try_from).collect::>()?; - ReserveAssetDeposited { assets, effects } - }, - Instruction::ReceiveTeleportedAsset(assets) => { - if !matches!(iter.next(), Some(Instruction::ClearOrigin)) { - return Err(()) - } - let effects = iter.map(Order::try_from).collect::>()?; - ReceiveTeleportedAsset { assets, effects } - }, - Instruction::QueryResponse { query_id, response, max_weight } => { - // Cannot handle special response weights. - if max_weight > 0 { - return Err(()) - } - QueryResponse { query_id, response: response.try_into()? } - }, - Instruction::TransferAsset { assets, beneficiary } => - TransferAsset { assets, beneficiary }, - Instruction::TransferReserveAsset { assets, dest, xcm } => TransferReserveAsset { - assets, - dest, - effects: xcm - .0 - .into_iter() - .map(Order::try_from) - .collect::>()?, - }, - Instruction::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => - HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }, - Instruction::HrmpChannelAccepted { recipient } => HrmpChannelAccepted { recipient }, - Instruction::HrmpChannelClosing { initiator, sender, recipient } => - HrmpChannelClosing { initiator, sender, recipient }, - Instruction::Transact { origin_type, require_weight_at_most, call } => - Transact { origin_type, require_weight_at_most, call }, - Instruction::SubscribeVersion { query_id, max_response_weight } => - SubscribeVersion { query_id, max_response_weight }, - Instruction::UnsubscribeVersion => UnsubscribeVersion, - _ => return Err(()), - }) - } -} - -// Convert from a v2 response to a v1 response -impl TryFrom for Response { - type Error = (); - fn try_from(response: NewResponse) -> result::Result { - match response { - NewResponse::Assets(assets) => Ok(Self::Assets(assets)), - NewResponse::Version(version) => Ok(Self::Version(version)), - _ => Err(()), - } - } -} diff --git a/xcm/src/v1/order.rs b/xcm/src/v1/order.rs deleted file mode 100644 index 66f90395d8da..000000000000 --- a/xcm/src/v1/order.rs +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2020 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 . - -//! Version 1 of the Cross-Consensus Message format data structures. - -use super::{MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, Xcm}; -use crate::v2::Instruction; -use alloc::{vec, vec::Vec}; -use core::{convert::TryFrom, result}; -use derivative::Derivative; -use parity_scale_codec::{self, Decode, Encode}; -use scale_info::TypeInfo; - -/// An instruction to be executed on some or all of the assets in holding, used by asset-related XCM messages. -#[derive(Derivative, Encode, Decode, TypeInfo)] -#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] -#[codec(encode_bound())] -#[codec(decode_bound())] -#[scale_info(bounds(), skip_type_params(Call))] -pub enum Order { - /// Do nothing. Not generally used. - #[codec(index = 0)] - Noop, - - /// Remove the asset(s) (`assets`) from holding and place equivalent assets under the ownership of `beneficiary` - /// within this consensus system. - /// - /// - `assets`: The asset(s) to remove from holding. - /// - `max_assets`: The maximum number of unique assets/asset instances to remove from holding. Only the first - /// `max_assets` assets/instances of those matched by `assets` will be removed, prioritized under standard asset - /// ordering. Any others will remain in holding. - /// - `beneficiary`: The new owner for the assets. - /// - /// Errors: - #[codec(index = 1)] - DepositAsset { assets: MultiAssetFilter, max_assets: u32, beneficiary: MultiLocation }, - - /// Remove the asset(s) (`assets`) from holding and place equivalent assets under the ownership of `dest` within - /// this consensus system (i.e. its sovereign account). - /// - /// Send an onward XCM message to `dest` of `ReserveAssetDeposited` with the given `effects`. - /// - /// - `assets`: The asset(s) to remove from holding. - /// - `max_assets`: The maximum number of unique assets/asset instances to remove from holding. Only the first - /// `max_assets` assets/instances of those matched by `assets` will be removed, prioritized under standard asset - /// ordering. Any others will remain in holding. - /// - `dest`: The location whose sovereign account will own the assets and thus the effective beneficiary for the - /// assets and the notification target for the reserve asset deposit message. - /// - `effects`: The orders that should be contained in the `ReserveAssetDeposited` which is sent onwards to - /// `dest`. - /// - /// Errors: - #[codec(index = 2)] - DepositReserveAsset { - assets: MultiAssetFilter, - max_assets: u32, - dest: MultiLocation, - effects: Vec>, - }, - - /// Remove the asset(s) (`give`) from holding and replace them with alternative assets. - /// - /// The minimum amount of assets to be received into holding for the order not to fail may be stated. - /// - /// - `give`: The asset(s) to remove from holding. - /// - `receive`: The minimum amount of assets(s) which `give` should be exchanged for. - /// - /// Errors: - #[codec(index = 3)] - ExchangeAsset { give: MultiAssetFilter, receive: MultiAssets }, - - /// Remove the asset(s) (`assets`) from holding and send a `WithdrawAsset` XCM message to a reserve location. - /// - /// - `assets`: The asset(s) to remove from holding. - /// - `reserve`: A valid location that acts as a reserve for all asset(s) in `assets`. The sovereign account - /// of this consensus system *on the reserve location* will have appropriate assets withdrawn and `effects` will - /// be executed on them. There will typically be only one valid location on any given asset/chain combination. - /// - `effects`: The orders to execute on the assets once withdrawn *on the reserve location*. - /// - /// Errors: - #[codec(index = 4)] - InitiateReserveWithdraw { - assets: MultiAssetFilter, - reserve: MultiLocation, - effects: Vec>, - }, - - /// Remove the asset(s) (`assets`) from holding and send a `ReceiveTeleportedAsset` XCM message to a `destination` - /// location. - /// - /// - `assets`: The asset(s) to remove from holding. - /// - `destination`: A valid location that has a bi-lateral teleportation arrangement. - /// - `effects`: The orders to execute on the assets once arrived *on the destination location*. - /// - /// NOTE: The `destination` location *MUST* respect this origin as a valid teleportation origin for all `assets`. - /// If it does not, then the assets may be lost. - /// - /// Errors: - #[codec(index = 5)] - InitiateTeleport { assets: MultiAssetFilter, dest: MultiLocation, effects: Vec> }, - - /// Send a `Balances` XCM message with the `assets` value equal to the holding contents, or a portion thereof. - /// - /// - `query_id`: An identifier that will be replicated into the returned XCM message. - /// - `dest`: A valid destination for the returned XCM message. This may be limited to the current origin. - /// - `assets`: A filter for the assets that should be reported back. The assets reported back will be, asset- - /// wise, *the lesser of this value and the holding register*. No wildcards will be used when reporting assets - /// back. - /// - /// Errors: - #[codec(index = 6)] - QueryHolding { - #[codec(compact)] - query_id: u64, - dest: MultiLocation, - assets: MultiAssetFilter, - }, - - /// Pay for the execution of some XCM `instructions` and `orders` with up to `weight` picoseconds of execution time, - /// paying for this with up to `fees` from the Holding Register. - /// - /// - `fees`: The asset(s) to remove from holding to pay for fees. - /// - `weight`: The amount of weight to purchase; this should be at least the shallow weight of `effects` and `xcm`. - /// - `debt`: The amount of weight-debt already incurred to be paid off; this should be equal to the unpaid weight of - /// any surrounding operations/orders. - /// - `halt_on_error`: If `true`, the execution of the `orders` and `operations` will halt on the first failure. If - /// `false`, then execution will continue regardless. - /// - `instructions`: XCM instructions to be executed outside of the context of the current Holding Register; - /// execution of these instructions happens AFTER the execution of the `orders`. The (shallow) weight for these - /// must be paid for with the `weight` purchased. - /// Errors: - #[codec(index = 7)] - BuyExecution { - fees: MultiAsset, - weight: u64, - debt: u64, - halt_on_error: bool, - instructions: Vec>, - }, -} - -pub mod opaque { - pub type Order = super::Order<()>; -} - -impl Order { - pub fn into(self) -> Order { - Order::from(self) - } - pub fn from(order: Order) -> Self { - use Order::*; - match order { - Noop => Noop, - DepositAsset { assets, max_assets, beneficiary } => - DepositAsset { assets, max_assets, beneficiary }, - DepositReserveAsset { assets, max_assets, dest, effects } => - DepositReserveAsset { assets, max_assets, dest, effects }, - ExchangeAsset { give, receive } => ExchangeAsset { give, receive }, - InitiateReserveWithdraw { assets, reserve, effects } => - InitiateReserveWithdraw { assets, reserve, effects }, - InitiateTeleport { assets, dest, effects } => - InitiateTeleport { assets, dest, effects }, - QueryHolding { query_id, dest, assets } => QueryHolding { query_id, dest, assets }, - BuyExecution { fees, weight, debt, halt_on_error, instructions } => { - let instructions = instructions.into_iter().map(Xcm::from).collect(); - BuyExecution { fees, weight, debt, halt_on_error, instructions } - }, - } - } -} - -impl TryFrom> for Order { - type Error = (); - fn try_from(old: Instruction) -> result::Result, ()> { - use Order::*; - Ok(match old { - Instruction::DepositAsset { assets, max_assets, beneficiary } => - DepositAsset { assets, max_assets, beneficiary }, - Instruction::DepositReserveAsset { assets, max_assets, dest, xcm } => - DepositReserveAsset { - assets, - max_assets, - dest, - effects: xcm - .0 - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - Instruction::ExchangeAsset { give, receive } => ExchangeAsset { give, receive }, - Instruction::InitiateReserveWithdraw { assets, reserve, xcm } => - InitiateReserveWithdraw { - assets, - reserve, - effects: xcm - .0 - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - Instruction::InitiateTeleport { assets, dest, xcm } => InitiateTeleport { - assets, - dest, - effects: xcm - .0 - .into_iter() - .map(Order::<()>::try_from) - .collect::>()?, - }, - Instruction::QueryHolding { query_id, dest, assets, max_response_weight } => { - // Cannot handle special response weights. - if max_response_weight > 0 { - return Err(()) - } - QueryHolding { query_id, dest, assets } - }, - Instruction::BuyExecution { fees, weight_limit } => { - let instructions = vec![]; - let halt_on_error = true; - let weight = 0; - let debt = Option::::from(weight_limit).ok_or(())?; - BuyExecution { fees, weight, debt, halt_on_error, instructions } - }, - _ => return Err(()), - }) - } -} diff --git a/xcm/src/v1/traits.rs b/xcm/src/v1/traits.rs deleted file mode 100644 index c896ef38f8a5..000000000000 --- a/xcm/src/v1/traits.rs +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright 2020 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 . - -//! Cross-Consensus Message format data structures. - -use core::result; -use parity_scale_codec::{Decode, Encode}; -use scale_info::TypeInfo; - -use super::{MultiLocation, Xcm}; - -#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] -pub enum Error { - Undefined, - /// An arithmetic overflow happened. - Overflow, - /// The operation is intentionally unsupported. - Unimplemented, - UnhandledXcmVersion, - /// The implementation does not handle a given XCM. - UnhandledXcmMessage, - /// The implementation does not handle an effect present in an XCM. - UnhandledEffect, - EscalationOfPrivilege, - UntrustedReserveLocation, - UntrustedTeleportLocation, - DestinationBufferOverflow, - /// The message and destination was recognized as being reachable but the operation could not be completed. - /// A human-readable explanation of the specific issue is provided. - SendFailed(#[codec(skip)] &'static str), - /// The message and destination combination was not recognized as being reachable. - NotApplicable(MultiLocation, Xcm<()>), - MultiLocationFull, - FailedToDecode, - BadOrigin, - ExceedsMaxMessageSize, - /// An asset transaction (like withdraw or deposit) failed. - /// See implementers of the `TransactAsset` trait for sources. - /// Causes can include type conversion failures between id or balance types. - FailedToTransactAsset(#[codec(skip)] &'static str), - /// Execution of the XCM would potentially result in a greater weight used than the pre-specified - /// weight limit. The amount that is potentially required is the parameter. - WeightLimitReached(Weight), - /// An asset wildcard was passed where it was not expected (e.g. as the asset to withdraw in a - /// `WithdrawAsset` XCM). - Wildcard, - /// The case where an XCM message has specified a weight limit on an interior call and this - /// limit is too low. - /// - /// Used by: - /// - `Transact` - MaxWeightInvalid, - /// The fees specified by the XCM message were not found in the holding register. - /// - /// Used by: - /// - `BuyExecution` - NotHoldingFees, - /// The weight of an XCM message is not computable ahead of execution. This generally means at least part - /// of the message is invalid, which could be due to it containing overly nested structures or an invalid - /// nested data segment (e.g. for the call in `Transact`). - WeightNotComputable, - /// The XCM did not pass the barrier condition for execution. The barrier condition differs on different - /// chains and in different circumstances, but generally it means that the conditions surrounding the message - /// were not such that the chain considers the message worth spending time executing. Since most chains - /// lift the barrier to execution on appropriate payment, presentation of an NFT voucher, or based on the - /// message origin, it means that none of those were the case. - Barrier, - /// Indicates that it is not possible for a location to have an asset be withdrawn or transferred from its - /// ownership. This probably means it doesn't own (enough of) it, but may also indicate that it is under a - /// lock, hold, freeze or is otherwise unavailable. - NotWithdrawable, - /// Indicates that the consensus system cannot deposit an asset under the ownership of a particular location. - LocationCannotHold, - /// The assets given to purchase weight is are insufficient for the weight desired. - TooExpensive, - /// The given asset is not handled. - AssetNotFound, - /// The given message cannot be translated into a format that the destination can be expected to interpret. - DestinationUnsupported, - /// `execute_xcm` has been called too many times recursively. - RecursionLimitReached, -} - -impl From<()> for Error { - fn from(_: ()) -> Self { - Self::Undefined - } -} - -pub type Result = result::Result<(), Error>; - -/// Local weight type; execution time in picoseconds. -pub type Weight = u64; - -/// Outcome of an XCM execution. -#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] -pub enum Outcome { - /// Execution completed successfully; given weight was used. - Complete(Weight), - /// Execution started, but did not complete successfully due to the given error; given weight was used. - Incomplete(Weight, Error), - /// Execution did not start due to the given error. - Error(Error), -} - -impl Outcome { - pub fn ensure_complete(self) -> Result { - match self { - Outcome::Complete(_) => Ok(()), - Outcome::Incomplete(_, e) => Err(e), - Outcome::Error(e) => Err(e), - } - } - pub fn ensure_execution(self) -> result::Result { - match self { - Outcome::Complete(w) => Ok(w), - Outcome::Incomplete(w, _) => Ok(w), - Outcome::Error(e) => Err(e), - } - } - /// How much weight was used by the XCM execution attempt. - pub fn weight_used(&self) -> Weight { - match self { - Outcome::Complete(w) => *w, - Outcome::Incomplete(w, _) => *w, - Outcome::Error(_) => 0, - } - } -} - -/// Type of XCM message executor. -pub trait ExecuteXcm { - /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is - /// a basic hard-limit and the implementation may place further restrictions or requirements on weight and - /// other aspects. - fn execute_xcm( - origin: impl Into, - message: Xcm, - weight_limit: Weight, - ) -> Outcome { - let origin = origin.into(); - log::debug!( - target: "xcm::execute_xcm", - "origin: {:?}, message: {:?}, weight_limit: {:?}", - origin, - message, - weight_limit, - ); - Self::execute_xcm_in_credit(origin, message, weight_limit, 0) - } - - /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. - /// - /// Some amount of `weight_credit` may be provided which, depending on the implementation, may allow - /// execution without associated payment. - fn execute_xcm_in_credit( - origin: impl Into, - message: Xcm, - weight_limit: Weight, - weight_credit: Weight, - ) -> Outcome; -} - -impl ExecuteXcm for () { - fn execute_xcm_in_credit( - _origin: impl Into, - _message: Xcm, - _weight_limit: Weight, - _weight_credit: Weight, - ) -> Outcome { - Outcome::Error(Error::Unimplemented) - } -} - -/// Utility for sending an XCM message. -/// -/// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each router might return -/// `NotApplicable` to pass the execution to the next sender item. Note that each `NotApplicable` -/// might alter the destination and the XCM message for to the next router. -/// -/// -/// # Example -/// ```rust -/// # use xcm::v1::{MultiLocation, Xcm, Junction, Junctions, Error, OriginKind, SendXcm, Result, Parent}; -/// # use parity_scale_codec::Encode; -/// -/// /// A sender that only passes the message through and does nothing. -/// struct Sender1; -/// impl SendXcm for Sender1 { -/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> Result { -/// return Err(Error::NotApplicable(destination.into(), message)) -/// } -/// } -/// -/// /// A sender that accepts a message that has an X2 junction, otherwise stops the routing. -/// struct Sender2; -/// impl SendXcm for Sender2 { -/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> Result { -/// let destination = destination.into(); -/// if matches!(destination.interior(), Junctions::X2(j1, j2)) -/// && destination.parent_count() == 0 -/// { -/// Ok(()) -/// } else { -/// Err(Error::Undefined) -/// } -/// } -/// } -/// -/// /// A sender that accepts a message from an X1 parent junction, passing through otherwise. -/// struct Sender3; -/// impl SendXcm for Sender3 { -/// fn send_xcm(destination: impl Into, message: Xcm<()>) -> Result { -/// let destination = destination.into(); -/// if matches!(destination.interior(), Junctions::Here) -/// && destination.parent_count() == 1 -/// { -/// Ok(()) -/// } else { -/// Err(Error::NotApplicable(destination, message)) -/// } -/// } -/// } -/// -/// // A call to send via XCM. We don't really care about this. -/// # fn main() { -/// let call: Vec = ().encode(); -/// let message = Xcm::Transact { origin_type: OriginKind::Superuser, require_weight_at_most: 0, call: call.into() }; -/// -/// assert!( -/// // Sender2 will block this. -/// <(Sender1, Sender2, Sender3) as SendXcm>::send_xcm(Parent, message.clone()) -/// .is_err() -/// ); -/// -/// assert!( -/// // Sender3 will catch this. -/// <(Sender1, Sender3) as SendXcm>::send_xcm(Parent, message.clone()) -/// .is_ok() -/// ); -/// # } -/// ``` -pub trait SendXcm { - /// Send an XCM `message` to a given `destination`. - /// - /// If it is not a destination which can be reached with this type but possibly could by others, then it *MUST* - /// return `NotApplicable`. Any other error will cause the tuple implementation to exit early without - /// trying other type fields. - fn send_xcm(destination: impl Into, message: Xcm<()>) -> Result; -} - -#[impl_trait_for_tuples::impl_for_tuples(30)] -impl SendXcm for Tuple { - fn send_xcm(destination: impl Into, message: Xcm<()>) -> Result { - for_tuples!( #( - // we shadow `destination` and `message` in each expansion for the next one. - let (destination, message) = match Tuple::send_xcm(destination, message) { - Err(Error::NotApplicable(d, m)) => (d, m), - o @ _ => return o, - }; - )* ); - Err(Error::NotApplicable(destination.into(), message)) - } -} diff --git a/xcm/src/v1/junction.rs b/xcm/src/v2/junction.rs similarity index 100% rename from xcm/src/v1/junction.rs rename to xcm/src/v2/junction.rs diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index 813d0e95d15a..629fc9715916 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -51,10 +51,12 @@ //! `reserve_transfer_assets` will fail with `UnweighableMessage`. use super::{ - v1::{Order as OldOrder, Response as OldResponse, Xcm as OldXcm}, - v3::{Instruction as NewInstruction, Response as NewResponse, Xcm as NewXcm}, + v3::{ + BodyId as NewBodyId, BodyPart as NewBodyPart, Instruction as NewInstruction, + NetworkId as NewNetworkId, Response as NewResponse, Xcm as NewXcm, + }, + DoubleEncoded, GetWeight, }; -use crate::{DoubleEncoded, GetWeight}; use alloc::{vec, vec::Vec}; use core::{ convert::{TryFrom, TryInto}, @@ -65,15 +67,163 @@ use derivative::Derivative; use parity_scale_codec::{self, Decode, Encode}; use scale_info::TypeInfo; +mod junction; +mod multiasset; +mod multilocation; mod traits; -pub use traits::{Error, ExecuteXcm, Outcome, Result, SendError, SendResult, SendXcm}; -// These parts of XCM v1 have been unchanged in XCM v2, and are re-imported here. -pub use super::v1::{ - Ancestor, AncestorThen, AssetId, AssetInstance, BodyId, BodyPart, Fungibility, - InteriorMultiLocation, Junction, Junctions, MultiAsset, MultiAssetFilter, MultiAssets, - MultiLocation, NetworkId, OriginKind, Parent, ParentThen, WildFungibility, WildMultiAsset, +pub use junction::Junction; +pub use multiasset::{ + AssetId, AssetInstance, Fungibility, MultiAsset, MultiAssetFilter, MultiAssets, + WildFungibility, WildMultiAsset, +}; +pub use multilocation::{ + Ancestor, AncestorThen, InteriorMultiLocation, Junctions, MultiLocation, Parent, ParentThen, }; +pub use traits::{Error, ExecuteXcm, Outcome, Result, SendError, SendResult, SendXcm}; + +/// Basically just the XCM (more general) version of `ParachainDispatchOrigin`. +#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] +pub enum OriginKind { + /// Origin should just be the native dispatch origin representation for the sender in the + /// local runtime framework. For Cumulus/Frame chains this is the `Parachain` or `Relay` origin + /// if coming from a chain, though there may be others if the `MultiLocation` XCM origin has a + /// primary/native dispatch origin form. + Native, + + /// Origin should just be the standard account-based origin with the sovereign account of + /// the sender. For Cumulus/Frame chains, this is the `Signed` origin. + SovereignAccount, + + /// Origin should be the super-user. For Cumulus/Frame chains, this is the `Root` origin. + /// This will not usually be an available option. + Superuser, + + /// Origin should be interpreted as an XCM native origin and the `MultiLocation` should be + /// encoded directly in the dispatch origin unchanged. For Cumulus/Frame chains, this will be + /// the `pallet_xcm::Origin::Xcm` type. + Xcm, +} + +/// A global identifier of an account-bearing consensus system. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum NetworkId { + /// Unidentified/any. + Any, + /// Some named network. + Named(Vec), + /// The Polkadot Relay chain + Polkadot, + /// Kusama. + Kusama, +} + +impl TryInto for Option { + type Error = (); + fn try_into(self) -> result::Result { + use NewNetworkId::*; + Ok(match self { + None => NetworkId::Any, + Some(Polkadot) => NetworkId::Polkadot, + Some(Kusama) => NetworkId::Kusama, + _ => return Err(()), + }) + } +} + +/// An identifier of a pluralistic body. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum BodyId { + /// The only body in its context. + Unit, + /// A named body. + Named(Vec), + /// An indexed body. + Index(#[codec(compact)] u32), + /// The unambiguous executive body (for Polkadot, this would be the Polkadot council). + Executive, + /// The unambiguous technical body (for Polkadot, this would be the Technical Committee). + Technical, + /// The unambiguous legislative body (for Polkadot, this could be considered the opinion of a majority of + /// lock-voters). + Legislative, + /// The unambiguous judicial body (this doesn't exist on Polkadot, but if it were to get a "grand oracle", it + /// may be considered as that). + Judicial, +} + +impl From for BodyId { + fn from(n: NewBodyId) -> Self { + use NewBodyId::*; + match n { + Unit => Self::Unit, + Moniker(n) => Self::Named(n[..].to_vec()), + Index(n) => Self::Index(n), + Executive => Self::Executive, + Technical => Self::Technical, + Legislative => Self::Legislative, + Judicial => Self::Judicial, + } + } +} + +/// A part of a pluralistic body. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +pub enum BodyPart { + /// The body's declaration, under whatever means it decides. + Voice, + /// A given number of members of the body. + Members { + #[codec(compact)] + count: u32, + }, + /// A given number of members of the body, out of some larger caucus. + Fraction { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + /// No less than the given proportion of members of the body. + AtLeastProportion { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, + /// More than than the given proportion of members of the body. + MoreThanProportion { + #[codec(compact)] + nom: u32, + #[codec(compact)] + denom: u32, + }, +} + +impl BodyPart { + /// Returns `true` if the part represents a strict majority (> 50%) of the body in question. + pub fn is_majority(&self) -> bool { + match self { + BodyPart::Fraction { nom, denom } if *nom * 2 > *denom => true, + BodyPart::AtLeastProportion { nom, denom } if *nom * 2 > *denom => true, + BodyPart::MoreThanProportion { nom, denom } if *nom * 2 >= *denom => true, + _ => false, + } + } +} + +impl From for BodyPart { + fn from(n: NewBodyPart) -> Self { + use NewBodyPart::*; + match n { + Voice => Self::Voice, + Members { count } => Self::Members { count }, + Fraction { nom, denom } => Self::Fraction { nom, denom }, + AtLeastProportion { nom, denom } => Self::AtLeastProportion { nom, denom }, + MoreThanProportion { nom, denom } => Self::MoreThanProportion { nom, denom }, + } + } +} /// This module's XCM version. pub const VERSION: super::Version = 2; @@ -786,17 +936,6 @@ pub mod opaque { pub type Instruction = super::Instruction<()>; } -// Convert from a v1 response to a v2 response -impl TryFrom for Response { - type Error = (); - fn try_from(old_response: OldResponse) -> result::Result { - match old_response { - OldResponse::Assets(assets) => Ok(Self::Assets(assets)), - OldResponse::Version(version) => Ok(Self::Version(version)), - } - } -} - // Convert from a v3 response to a v2 response impl TryFrom for Response { type Error = (); @@ -814,58 +953,6 @@ impl TryFrom for Response { } } -impl TryFrom> for Xcm { - type Error = (); - fn try_from(old: OldXcm) -> result::Result, ()> { - use Instruction::*; - Ok(Xcm(match old { - OldXcm::WithdrawAsset { assets, effects } => Some(Ok(WithdrawAsset(assets))) - .into_iter() - .chain(effects.into_iter().map(Instruction::try_from)) - .collect::, _>>()?, - OldXcm::ReserveAssetDeposited { assets, effects } => - Some(Ok(ReserveAssetDeposited(assets))) - .into_iter() - .chain(Some(Ok(ClearOrigin)).into_iter()) - .chain(effects.into_iter().map(Instruction::try_from)) - .collect::, _>>()?, - OldXcm::ReceiveTeleportedAsset { assets, effects } => - Some(Ok(ReceiveTeleportedAsset(assets))) - .into_iter() - .chain(Some(Ok(ClearOrigin)).into_iter()) - .chain(effects.into_iter().map(Instruction::try_from)) - .collect::, _>>()?, - OldXcm::QueryResponse { query_id, response } => vec![QueryResponse { - query_id, - response: response.try_into()?, - max_weight: 50_000_000, - }], - OldXcm::TransferAsset { assets, beneficiary } => - vec![TransferAsset { assets, beneficiary }], - OldXcm::TransferReserveAsset { assets, dest, effects } => vec![TransferReserveAsset { - assets, - dest, - xcm: Xcm(effects - .into_iter() - .map(Instruction::<()>::try_from) - .collect::>()?), - }], - OldXcm::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => - vec![HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity }], - OldXcm::HrmpChannelAccepted { recipient } => vec![HrmpChannelAccepted { recipient }], - OldXcm::HrmpChannelClosing { initiator, sender, recipient } => - vec![HrmpChannelClosing { initiator, sender, recipient }], - OldXcm::Transact { origin_type, require_weight_at_most, call } => - vec![Transact { origin_type, require_weight_at_most, call }], - // We don't handle this one at all due to nested XCM. - OldXcm::RelayedFrom { .. } => return Err(()), - OldXcm::SubscribeVersion { query_id, max_response_weight } => - vec![SubscribeVersion { query_id, max_response_weight }], - OldXcm::UnsubscribeVersion => vec![UnsubscribeVersion], - })) - } -} - // Convert from a v3 XCM to a v2 XCM. impl TryFrom> for Xcm { type Error = (); @@ -874,55 +961,6 @@ impl TryFrom> for Xcm { } } -impl TryFrom> for Instruction { - type Error = (); - fn try_from(old: OldOrder) -> result::Result, ()> { - use Instruction::*; - Ok(match old { - OldOrder::Noop => return Err(()), - OldOrder::DepositAsset { assets, max_assets, beneficiary } => - DepositAsset { assets, max_assets, beneficiary }, - OldOrder::DepositReserveAsset { assets, max_assets, dest, effects } => - DepositReserveAsset { - assets, - max_assets, - dest, - xcm: Xcm(effects - .into_iter() - .map(Instruction::<()>::try_from) - .collect::>()?), - }, - OldOrder::ExchangeAsset { give, receive } => ExchangeAsset { give, receive }, - OldOrder::InitiateReserveWithdraw { assets, reserve, effects } => - InitiateReserveWithdraw { - assets, - reserve, - xcm: Xcm(effects - .into_iter() - .map(Instruction::<()>::try_from) - .collect::>()?), - }, - OldOrder::InitiateTeleport { assets, dest, effects } => InitiateTeleport { - assets, - dest, - xcm: Xcm(effects - .into_iter() - .map(Instruction::<()>::try_from) - .collect::>()?), - }, - OldOrder::QueryHolding { query_id, dest, assets } => - QueryHolding { query_id, dest, assets, max_response_weight: 0 }, - OldOrder::BuyExecution { fees, debt, instructions, .. } => { - // We don't handle nested XCM. - if !instructions.is_empty() { - return Err(()) - } - BuyExecution { fees, weight_limit: WeightLimit::Limited(debt) } - }, - }) - } -} - // Convert from a v3 instruction to a v2 instruction impl TryFrom> for Instruction { type Error = (); @@ -1019,71 +1057,3 @@ impl TryFrom> for Instruction { }) } } - -#[cfg(test)] -mod tests { - use super::{prelude::*, *}; - - #[test] - fn basic_roundtrip_works() { - let xcm = Xcm::<()>(vec![TransferAsset { - assets: (Here, 1u128).into(), - beneficiary: Here.into(), - }]); - let old_xcm = - OldXcm::<()>::TransferAsset { assets: (Here, 1u128).into(), beneficiary: Here.into() }; - assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); - let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); - assert_eq!(new_xcm, xcm); - } - - #[test] - fn teleport_roundtrip_works() { - let xcm = Xcm::<()>(vec![ - ReceiveTeleportedAsset((Here, 1u128).into()), - ClearOrigin, - DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Here.into() }, - ]); - let old_xcm: OldXcm<()> = OldXcm::<()>::ReceiveTeleportedAsset { - assets: (Here, 1u128).into(), - effects: vec![OldOrder::DepositAsset { - assets: Wild(All), - max_assets: 1, - beneficiary: Here.into(), - }], - }; - assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); - let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); - assert_eq!(new_xcm, xcm); - } - - #[test] - fn reserve_deposit_roundtrip_works() { - let xcm = Xcm::<()>(vec![ - ReserveAssetDeposited((Here, 1u128).into()), - ClearOrigin, - BuyExecution { fees: (Here, 1u128).into(), weight_limit: Some(1).into() }, - DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Here.into() }, - ]); - let old_xcm: OldXcm<()> = OldXcm::<()>::ReserveAssetDeposited { - assets: (Here, 1u128).into(), - effects: vec![ - OldOrder::BuyExecution { - fees: (Here, 1u128).into(), - debt: 1, - weight: 0, - instructions: vec![], - halt_on_error: true, - }, - OldOrder::DepositAsset { - assets: Wild(All), - max_assets: 1, - beneficiary: Here.into(), - }, - ], - }; - assert_eq!(old_xcm, OldXcm::<()>::try_from(xcm.clone()).unwrap()); - let new_xcm: Xcm<()> = old_xcm.try_into().unwrap(); - assert_eq!(new_xcm, xcm); - } -} diff --git a/xcm/src/v1/multiasset.rs b/xcm/src/v2/multiasset.rs similarity index 100% rename from xcm/src/v1/multiasset.rs rename to xcm/src/v2/multiasset.rs diff --git a/xcm/src/v1/multilocation.rs b/xcm/src/v2/multilocation.rs similarity index 98% rename from xcm/src/v1/multilocation.rs rename to xcm/src/v2/multilocation.rs index a47f4b8ceec0..0df640805c95 100644 --- a/xcm/src/v1/multilocation.rs +++ b/xcm/src/v2/multilocation.rs @@ -240,7 +240,7 @@ impl MultiLocation { /// /// # Example /// ```rust - /// # use xcm::v1::{Junctions::*, Junction::*, MultiLocation}; + /// # use xcm::v2::{Junctions::*, Junction::*, MultiLocation}; /// # fn main() { /// let mut m = MultiLocation::new(1, X2(PalletInstance(3), OnlyChild)); /// assert_eq!( @@ -262,7 +262,7 @@ impl MultiLocation { /// /// # Example /// ```rust - /// # use xcm::v1::{Junctions::*, Junction::*, MultiLocation}; + /// # use xcm::v2::{Junctions::*, Junction::*, MultiLocation}; /// let m = MultiLocation::new(1, X3(PalletInstance(3), OnlyChild, OnlyChild)); /// assert!(m.starts_with(&MultiLocation::new(1, X1(PalletInstance(3))))); /// assert!(!m.starts_with(&MultiLocation::new(1, X1(GeneralIndex(99))))); @@ -281,7 +281,7 @@ impl MultiLocation { /// /// # Example /// ```rust - /// # use xcm::v1::{Junctions::*, Junction::*, MultiLocation}; + /// # use xcm::v2::{Junctions::*, Junction::*, MultiLocation}; /// # fn main() { /// let mut m = MultiLocation::new(1, X1(Parachain(21))); /// assert_eq!(m.append_with(X1(PalletInstance(3))), Ok(())); @@ -304,7 +304,7 @@ impl MultiLocation { /// /// # Example /// ```rust - /// # use xcm::v1::{Junctions::*, Junction::*, MultiLocation}; + /// # use xcm::v2::{Junctions::*, Junction::*, MultiLocation}; /// # fn main() { /// let mut m = MultiLocation::new(2, X1(PalletInstance(3))); /// assert_eq!(m.prepend_with(MultiLocation::new(1, X2(Parachain(21), OnlyChild))), Ok(())); @@ -459,7 +459,7 @@ impl> From> for MultiLocation { } } -xcm_procedural::impl_conversion_functions_for_multilocation_v1!(); +xcm_procedural::impl_conversion_functions_for_multilocation_v2!(); /// Maximum number of `Junction`s that a `Junctions` can contain. const MAX_JUNCTIONS: usize = 8; @@ -837,7 +837,7 @@ impl Junctions { /// /// # Example /// ```rust - /// # use xcm::v1::{Junctions::*, Junction::*}; + /// # use xcm::v2::{Junctions::*, Junction::*}; /// # fn main() { /// let mut m = X3(Parachain(2), PalletInstance(3), OnlyChild); /// assert_eq!(m.match_and_split(&X2(Parachain(2), PalletInstance(3))), Some(&OnlyChild)); @@ -855,7 +855,7 @@ impl Junctions { /// /// # Example /// ```rust - /// # use xcm::v1::{Junctions::*, Junction::*}; + /// # use xcm::v2::{Junctions::*, Junction::*}; /// let mut j = X3(Parachain(2), PalletInstance(3), OnlyChild); /// assert!(j.starts_with(&X2(Parachain(2), PalletInstance(3)))); /// assert!(j.starts_with(&j)); @@ -885,7 +885,7 @@ impl TryFrom for Junctions { #[cfg(test)] mod tests { use super::{Ancestor, AncestorThen, Junctions::*, MultiLocation, Parent, ParentThen}; - use crate::opaque::v1::{Junction::*, NetworkId::*}; + use crate::opaque::v2::{Junction::*, NetworkId::*}; use parity_scale_codec::{Decode, Encode}; #[test] diff --git a/xcm/src/v3/junction.rs b/xcm/src/v3/junction.rs index e778df963591..e508eea4ab4f 100644 --- a/xcm/src/v3/junction.rs +++ b/xcm/src/v3/junction.rs @@ -18,8 +18,10 @@ use super::{Junctions, MultiLocation}; use crate::{ - v1::{BodyId as OldBodyId, BodyPart as OldBodyPart}, - v2::{Junction as OldJunction, NetworkId as OldNetworkId}, + v2::{ + BodyId as OldBodyId, BodyPart as OldBodyPart, Junction as OldJunction, + NetworkId as OldNetworkId, + }, VersionedMultiLocation, }; use core::convert::{TryFrom, TryInto}; diff --git a/xcm/src/v3/multilocation.rs b/xcm/src/v3/multilocation.rs index 28e2cf84cca6..d03759d986aa 100644 --- a/xcm/src/v3/multilocation.rs +++ b/xcm/src/v3/multilocation.rs @@ -675,7 +675,7 @@ mod tests { #[test] fn conversion_from_other_types_works() { - use crate::v1; + use crate::v2; use core::convert::TryInto; fn takes_multilocation>(_arg: Arg) {} @@ -696,12 +696,12 @@ mod tests { takes_multilocation([Parachain(100), PalletInstance(3)]); assert_eq!( - v1::MultiLocation::from(v1::Junctions::Here).try_into(), + v2::MultiLocation::from(v2::Junctions::Here).try_into(), Ok(MultiLocation::here()) ); - assert_eq!(v1::MultiLocation::from(v1::Parent).try_into(), Ok(MultiLocation::parent())); + assert_eq!(v2::MultiLocation::from(v2::Parent).try_into(), Ok(MultiLocation::parent())); assert_eq!( - v1::MultiLocation::from((v1::Parent, v1::Parent, v1::Junction::GeneralIndex(42u128),)) + v2::MultiLocation::from((v2::Parent, v2::Parent, v2::Junction::GeneralIndex(42u128),)) .try_into(), Ok(MultiLocation { parents: 2, interior: X1(GeneralIndex(42u128)) }), ); From 069c75fa55b6543917c8630d343d1e956a6cec67 Mon Sep 17 00:00:00 2001 From: stanly-johnson Date: Mon, 14 Mar 2022 13:09:23 +0400 Subject: [PATCH 084/231] derive serialize/deserialize for xcm primitives (#5036) * derive serialize/deserialize for xcm primitives * derive serialize/deserialize for xcm primitives * update v3 * update v2 Co-authored-by: Gav Wood --- Cargo.lock | 1 + xcm/Cargo.toml | 2 ++ xcm/src/v2/junction.rs | 1 + xcm/src/v2/mod.rs | 3 +++ xcm/src/v2/multiasset.rs | 8 ++++++++ xcm/src/v2/multilocation.rs | 2 ++ xcm/src/v3/junction.rs | 4 ++++ xcm/src/v3/junctions.rs | 1 + xcm/src/v3/multiasset.rs | 8 ++++++++ xcm/src/v3/multilocation.rs | 1 + 10 files changed, 31 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index fbaa979d937d..e6b45ae09125 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12531,6 +12531,7 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", + "serde", "sp-io", "xcm-procedural", ] diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index ab4078a42c37..01c1faa0853f 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -11,6 +11,7 @@ parity-scale-codec = { version = "3.0.0", default-features = false, features = [ scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } derivative = {version = "2.2.0", default-features = false, features = [ "use_core" ] } +serde = { version = "1.0.136", optional = true, features = ["derive"] } log = { version = "0.4.14", default-features = false } xcm-procedural = { path = "procedural" } @@ -21,5 +22,6 @@ runtime-benchmarks = [] std = [ "parity-scale-codec/std", "scale-info/std", + "serde", "sp-io/std" ] diff --git a/xcm/src/v2/junction.rs b/xcm/src/v2/junction.rs index 613160aa42dd..8820c5b26119 100644 --- a/xcm/src/v2/junction.rs +++ b/xcm/src/v2/junction.rs @@ -27,6 +27,7 @@ use scale_info::TypeInfo; /// /// Each item assumes a pre-existing location as its context and is defined in terms of it. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Junction { /// An indexed parachain belonging to and operated by the context. /// diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index 629fc9715916..84ade3f837ca 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -107,6 +107,7 @@ pub enum OriginKind { /// A global identifier of an account-bearing consensus system. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum NetworkId { /// Unidentified/any. Any, @@ -133,6 +134,7 @@ impl TryInto for Option { /// An identifier of a pluralistic body. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum BodyId { /// The only body in its context. Unit, @@ -169,6 +171,7 @@ impl From for BodyId { /// A part of a pluralistic body. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum BodyPart { /// The body's declaration, under whatever means it decides. Voice, diff --git a/xcm/src/v2/multiasset.rs b/xcm/src/v2/multiasset.rs index 037b72070672..525be929c072 100644 --- a/xcm/src/v2/multiasset.rs +++ b/xcm/src/v2/multiasset.rs @@ -40,6 +40,7 @@ use scale_info::TypeInfo; /// A general identifier for an instance of a non-fungible asset class. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum AssetInstance { /// Undefined - used if the non-fungible asset class has only one instance. Undefined, @@ -117,6 +118,7 @@ impl TryFrom for AssetInstance { /// Classification of an asset being concrete or abstract. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum AssetId { Concrete(MultiLocation), Abstract(Vec), @@ -180,6 +182,7 @@ impl AssetId { /// Classification of whether an asset is fungible or not, along with a mandatory amount or instance. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Fungibility { Fungible(#[codec(compact)] u128), NonFungible(AssetInstance), @@ -218,6 +221,7 @@ impl TryFrom for Fungibility { } #[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct MultiAsset { pub id: AssetId, pub fun: Fungibility, @@ -301,6 +305,7 @@ impl TryFrom for MultiAsset { /// A `Vec` of `MultiAsset`s. There may be no duplicate fungible items in here and when decoding, they must be sorted. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct MultiAssets(Vec); impl Decode for MultiAssets { @@ -466,6 +471,7 @@ impl MultiAssets { /// Classification of whether an asset is fungible or not. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum WildFungibility { Fungible, NonFungible, @@ -484,6 +490,7 @@ impl TryFrom for WildFungibility { /// A wildcard representing a set of assets. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum WildMultiAsset { /// All assets in the holding register, up to `usize` individual assets (different instances of non-fungibles could /// be separate assets). @@ -528,6 +535,7 @@ impl, B: Into> From<(A, B)> for WildMultiAsset /// Note: Vectors of wildcards whose encoding is supported in XCM v0 are unsupported /// in this implementation and will result in a decode error. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum MultiAssetFilter { Definite(MultiAssets), Wild(WildMultiAsset), diff --git a/xcm/src/v2/multilocation.rs b/xcm/src/v2/multilocation.rs index 0df640805c95..cbcd8d5a50b8 100644 --- a/xcm/src/v2/multilocation.rs +++ b/xcm/src/v2/multilocation.rs @@ -52,6 +52,7 @@ use scale_info::TypeInfo; /// /// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system. #[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct MultiLocation { /// The number of parent junctions at the beginning of this `MultiLocation`. pub parents: u8, @@ -470,6 +471,7 @@ const MAX_JUNCTIONS: usize = 8; /// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for /// instructions on constructing parent junctions. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Junctions { /// The interpreting consensus system. Here, diff --git a/xcm/src/v3/junction.rs b/xcm/src/v3/junction.rs index e508eea4ab4f..17200f985de2 100644 --- a/xcm/src/v3/junction.rs +++ b/xcm/src/v3/junction.rs @@ -35,6 +35,7 @@ use scale_info::TypeInfo; #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum NetworkId { /// Network specified by the first 32 bytes of its genesis block. ByGenesis([u8; 32]), @@ -76,6 +77,7 @@ impl From for Option { #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum BodyId { /// The only body in its context. Unit, @@ -122,6 +124,7 @@ impl TryFrom for BodyId { #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum BodyPart { /// The body's declaration, under whatever means it decides. Voice, @@ -185,6 +188,7 @@ impl TryFrom for BodyPart { #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Junction { /// An indexed parachain belonging to and operated by the context. /// diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs index 27580eb61643..34815add7fb2 100644 --- a/xcm/src/v3/junctions.rs +++ b/xcm/src/v3/junctions.rs @@ -32,6 +32,7 @@ pub(crate) const MAX_JUNCTIONS: usize = 8; #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Junctions { /// The interpreting consensus system. Here, diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index d5064faab8d3..507e8f931728 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -42,6 +42,7 @@ use scale_info::TypeInfo; #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum AssetInstance { /// Undefined - used if the non-fungible asset class has only one instance. Undefined, @@ -235,6 +236,7 @@ impl TryFrom for u128 { /// Classification of whether an asset is fungible or not, along with a mandatory amount or instance. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Fungibility { Fungible(#[codec(compact)] u128), NonFungible(AssetInstance), @@ -283,6 +285,7 @@ impl TryFrom for Fungibility { #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum WildFungibility { Fungible, NonFungible, @@ -303,6 +306,7 @@ impl TryFrom for WildFungibility { #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum AssetId { Concrete(MultiLocation), Abstract([u8; 32]), @@ -371,6 +375,7 @@ impl AssetId { } #[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct MultiAsset { pub id: AssetId, pub fun: Fungibility, @@ -458,6 +463,7 @@ impl TryFrom for MultiAsset { /// A `Vec` of `MultiAsset`s. There may be no duplicate fungible items in here and when decoding, they must be sorted. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo, Default)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] // TODO: Change to a `BoundedVec`. pub struct MultiAssets(Vec); @@ -644,6 +650,7 @@ impl MultiAssets { /// A wildcard representing a set of assets. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum WildMultiAsset { /// All assets in Holding. All, @@ -758,6 +765,7 @@ impl, B: Into> From<(A, B)> for WildMultiAsset /// `MultiAsset` collection, either `MultiAssets` or a single wildcard. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum MultiAssetFilter { Definite(MultiAssets), Wild(WildMultiAsset), diff --git a/xcm/src/v3/multilocation.rs b/xcm/src/v3/multilocation.rs index d03759d986aa..698276627afa 100644 --- a/xcm/src/v3/multilocation.rs +++ b/xcm/src/v3/multilocation.rs @@ -54,6 +54,7 @@ use scale_info::TypeInfo; #[derive( Copy, Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo, MaxEncodedLen, )] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct MultiLocation { /// The number of parent junctions at the beginning of this `MultiLocation`. pub parents: u8, From 9cca36a73901c3867e1431d9bd3ae3c48f97bb2f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 15 Mar 2022 11:11:25 +0100 Subject: [PATCH 085/231] Update lock --- Cargo.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index e5f6093fb793..0b4cdcc21af5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12550,7 +12550,6 @@ dependencies = [ "assert_matches", "frame-support", "frame-system", - "impl-trait-for-tuples", "log", "pallet-balances", "pallet-transaction-payment", From bedb342d23334f2f08f1abb72cfb290a55715bb9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 15 Mar 2022 11:30:13 +0100 Subject: [PATCH 086/231] Fixes --- Cargo.lock | 1 + xcm/xcm-builder/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 0b4cdcc21af5..e5f6093fb793 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12550,6 +12550,7 @@ dependencies = [ "assert_matches", "frame-support", "frame-system", + "impl-trait-for-tuples", "log", "pallet-balances", "pallet-transaction-payment", diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index 3bd4ccbe3b3d..8e68aa039df2 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -6,6 +6,7 @@ description = "Tools & types for building with XCM and its executor." version = "0.9.18" [dependencies] +impl-trait-for-tuples = "0.2.1" parity-scale-codec = { version = "3.1.0", default-features = false, features = ["derive"] } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } xcm = { path = "..", default-features = false } From a261384a475869e5384da2c29dc453a9daed7df9 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sun, 20 Mar 2022 07:36:09 -0700 Subject: [PATCH 087/231] Add benchmarks for the ExchangeAsset instruction --- runtime/westend/src/lib.rs | 5 +++++ runtime/westend/src/weights/xcm/mod.rs | 4 ++-- .../xcm/pallet_xcm_benchmarks_generic.rs | 3 +++ .../src/generic/benchmarking.rs | 19 ++++++++++++++++++- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 8 ++++++-- xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 9 +++++++++ xcm/xcm-builder/src/test_utils.rs | 15 ++++++++++++++- 7 files changed, 57 insertions(+), 6 deletions(-) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index d34dfe36b993..1b948ab9ae20 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1574,6 +1574,11 @@ sp_api::impl_runtime_apis! { (0u64, Response::Version(Default::default())) } + fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> { + // Westend doesn't support asset exchanges + Err(BenchmarkError::Skip) + } + fn transact_origin() -> Result { Ok(Westmint::get()) } diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index cd5543e6dc70..8a09ee9fdd94 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -139,8 +139,8 @@ impl XcmWeightInfo for WestendXcmWeight { ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { - Weight::MAX // todo fix + fn exchange_asset(give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { + give.weigh_multi_assets(XcmGeneic::::exchange_asset()) } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 0c5ab409be77..9ee70142fbc7 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -173,4 +173,7 @@ impl WeightInfo { pub(crate) fn clear_topic() -> Weight { (3_268_000 as Weight) } + pub(crate) fn exchange_asset() -> Weight { + (2_000_000_000_000 as Weight) + } } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 88743c0347ef..e77a875049be 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -475,10 +475,27 @@ benchmarks! { assert_eq!(executor.topic(), &None); } + exchange_asset { + let (give, want) = T::worst_case_asset_exchange().map_err(|_| BenchmarkError::Skip)?; + let assets = give.clone(); + + let mut executor = new_executor::(Default::default()); + executor.set_holding(give.into()); + let instruction = Instruction::ExchangeAsset { + give: assets.into(), + want: want.clone(), + maximal: true, + }; + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + assert_eq!(executor.holding(), &want.into()); + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), crate::generic::mock::Test ); - } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index ec34975e3a0d..e0ecd1eda08c 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -29,7 +29,7 @@ use sp_runtime::{ BuildStorage, }; use xcm_builder::{ - test_utils::{Assets, TestAssetTrap, TestSubscriptionService}, + test_utils::{Assets, TestAssetExchanger, TestAssetTrap, TestSubscriptionService}, AllowUnpaidExecutionFrom, }; use xcm_executor::traits::ConvertOrigin; @@ -117,7 +117,7 @@ impl xcm_executor::Config for XcmConfig { type ResponseHandler = DevNull; type AssetTrap = TestAssetTrap; type AssetLocker = (); - type AssetExchanger = (); + type AssetExchanger = TestAssetExchanger; type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; type PalletInstancesInfo = AllPalletsWithSystem; @@ -153,6 +153,10 @@ impl generic::Config for Test { (0, Response::Assets(assets)) } + fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> { + Ok(Default::default()) + } + fn transact_origin() -> Result { Ok(Default::default()) } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 270eaf896e7e..4ad88b8d1dc6 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -20,6 +20,15 @@ pub mod pallet { /// The response which causes the most runtime weight. fn worst_case_response() -> (u64, Response); + /// The pair of asset collections which causes the most runtime weight if demanded to be + /// exchanged. + /// + /// The first element in the returned tuple represents the assets that are being exchanged + /// from, whereas the second element represents the assets that are being exchanged to. + /// + /// If set to `None`, benchmarks which rely on an `exchange_asset` will be skipped. + fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError>; + /// The `MultiLocation` used for successful transaction XCMs. /// /// If set to `None`, benchmarks which rely on a `transact_origin` will be skipped. diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index b56e39f4266a..e55b88f4dfe4 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -25,7 +25,7 @@ use sp_std::vec::Vec; pub use xcm::latest::prelude::*; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ - traits::{ConvertOrigin, OnResponse, TransactAsset}, + traits::{AssetExchange, ConvertOrigin, OnResponse, TransactAsset}, Assets, Config, }; @@ -97,6 +97,19 @@ impl ClaimAssets for TestAssetTrap { } } +pub struct TestAssetExchanger; + +impl AssetExchange for TestAssetExchanger { + fn exchange_asset( + _origin: Option<&MultiLocation>, + _give: Assets, + want: &MultiAssets, + _maximal: bool, + ) -> Result { + Ok(want.clone().into()) + } +} + pub struct TestPalletsInfo; impl PalletsInfoAccess for TestPalletsInfo { fn count() -> usize { From 92a0d768f94cc7ad38a4363fcaac7d0b84f906f2 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sun, 20 Mar 2022 23:46:42 +0100 Subject: [PATCH 088/231] `AliasOrigin` instruction stub (#5122) * AliasOrigin instruction stub * Fixes --- runtime/westend/src/weights/xcm/mod.rs | 3 +++ xcm/src/v3/mod.rs | 9 +++++++++ xcm/src/v3/traits.rs | 3 +++ xcm/xcm-executor/src/lib.rs | 1 + 4 files changed, 16 insertions(+) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 8a09ee9fdd94..29ca8b6fc8c0 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -243,4 +243,7 @@ impl XcmWeightInfo for WestendXcmWeight { fn clear_topic() -> Weight { XcmGeneric::::clear_topic() } + fn alias_origin(_: &MultiLocation) -> Weight { + Weight::MAX // todo fix + } } diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index f8dc413a858f..cd4060566aac 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -979,6 +979,13 @@ pub enum Instruction { /// /// Errors: None. ClearTopic, + + /// Alter the current Origin to another given origin. + /// + /// Kind: *Instruction* + /// + /// Errors: If the existing state would not allow such a change. + AliasOrigin(MultiLocation), } impl Xcm { @@ -1052,6 +1059,7 @@ impl Instruction { SetFeesMode { jit_withdraw } => SetFeesMode { jit_withdraw }, SetTopic(topic) => SetTopic(topic), ClearTopic => ClearTopic, + AliasOrigin(location) => AliasOrigin(location), } } } @@ -1117,6 +1125,7 @@ impl> GetWeight for Instruction { SetFeesMode { jit_withdraw } => W::set_fees_mode(jit_withdraw), SetTopic(topic) => W::set_topic(topic), ClearTopic => W::clear_topic(), + AliasOrigin(location) => W::alias_origin(location), } } } diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index b5b3f6adaff2..6f78cb19ef67 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -123,6 +123,9 @@ pub enum Error { /// Some other error with locking. #[codec(index = 31)] LockError, + /// The state was not in a condition where the operation was valid to make. + #[codec(index = 32)] + NoPermission, // Errors that happen prior to instructions being executed. These fall outside of the XCM spec. /// XCM version not able to be handled. diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 61fa76be551f..b61bd0fea65b 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -845,6 +845,7 @@ impl XcmExecutor { self.topic = None; Ok(()) }, + AliasOrigin(_) => Err(XcmError::NoPermission), HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), HrmpChannelClosing { .. } => Err(XcmError::Unimplemented), From 9de612c313c5b20be59d2681e8a74a602a37e0e6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 21 Mar 2022 09:35:00 +0000 Subject: [PATCH 089/231] Fixes --- runtime/westend/src/weights/xcm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 29ca8b6fc8c0..130f4d218289 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -140,7 +140,7 @@ impl XcmWeightInfo for WestendXcmWeight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } fn exchange_asset(give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { - give.weigh_multi_assets(XcmGeneic::::exchange_asset()) + give.weigh_multi_assets(XcmGeneric::::exchange_asset()) } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, From 5e0d072e0af65e2be0c8dcdb56b5b95d4de5d020 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 21 Mar 2022 09:24:41 -0700 Subject: [PATCH 090/231] Update substrate --- Cargo.lock | 335 +++++++++++++++++++++++++++-------------------------- 1 file changed, 171 insertions(+), 164 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f86462ca5179..83667e780233 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -450,7 +450,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "beefy-primitives", "fnv", @@ -480,7 +480,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -503,12 +503,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "scale-info", @@ -1646,6 +1646,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "dissimilar" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31ad93652f40969dead8d4bf897a41e9462095152eb21c56e5830537e41179dd" + [[package]] name = "dlmalloc" version = "0.2.3" @@ -2084,7 +2090,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", ] @@ -2102,7 +2108,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -2124,7 +2130,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "Inflector", "chrono", @@ -2167,7 +2173,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -2178,7 +2184,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2194,7 +2200,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -2222,7 +2228,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "bitflags", "frame-metadata", @@ -2251,7 +2257,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2263,7 +2269,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.3", @@ -2275,7 +2281,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "proc-macro2", "quote", @@ -2285,7 +2291,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2308,7 +2314,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -2319,7 +2325,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "log", @@ -2336,7 +2342,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -2351,7 +2357,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "sp-api", @@ -2360,7 +2366,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "sp-api", @@ -2556,7 +2562,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "chrono", "frame-election-provider-support", @@ -5014,7 +5020,7 @@ checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5028,7 +5034,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5044,7 +5050,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5059,7 +5065,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5083,7 +5089,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5103,7 +5109,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-election-provider-support", "frame-support", @@ -5123,7 +5129,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5138,7 +5144,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "beefy-primitives", "frame-support", @@ -5154,7 +5160,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -5179,7 +5185,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5261,7 +5267,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5280,7 +5286,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5297,7 +5303,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5313,7 +5319,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5336,7 +5342,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5354,7 +5360,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5369,7 +5375,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5392,7 +5398,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5408,7 +5414,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5428,7 +5434,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5445,7 +5451,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5462,7 +5468,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5480,7 +5486,7 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5496,7 +5502,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5513,7 +5519,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5528,7 +5534,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5542,7 +5548,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5559,7 +5565,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5582,7 +5588,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5598,7 +5604,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5613,7 +5619,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5627,7 +5633,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5643,7 +5649,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5664,7 +5670,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5680,7 +5686,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5694,7 +5700,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5717,7 +5723,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -5728,7 +5734,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "log", "sp-arithmetic", @@ -5737,7 +5743,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5751,7 +5757,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5769,7 +5775,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5788,7 +5794,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-support", "frame-system", @@ -5805,7 +5811,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5822,7 +5828,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5833,7 +5839,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5850,7 +5856,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5865,7 +5871,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -5881,7 +5887,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-benchmarking", "frame-support", @@ -8345,7 +8351,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "env_logger", "jsonrpsee 0.8.0", @@ -8692,7 +8698,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "log", "sp-core", @@ -8703,7 +8709,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "futures 0.3.21", @@ -8730,7 +8736,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "futures-timer", @@ -8753,7 +8759,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8769,7 +8775,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.3", @@ -8786,7 +8792,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -8797,7 +8803,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "chrono", "clap", @@ -8835,7 +8841,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "fnv", "futures 0.3.21", @@ -8863,7 +8869,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "hash-db", "kvdb", @@ -8888,7 +8894,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "futures 0.3.21", @@ -8912,7 +8918,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "fork-tree", @@ -8955,7 +8961,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -8979,7 +8985,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8992,7 +8998,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "futures 0.3.21", @@ -9017,7 +9023,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "sc-client-api", "sp-authorship", @@ -9028,7 +9034,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "lazy_static", "lru 0.6.6", @@ -9055,7 +9061,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "environmental", "parity-scale-codec", @@ -9072,7 +9078,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "log", "parity-scale-codec", @@ -9088,7 +9094,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "cfg-if 1.0.0", "libc", @@ -9106,7 +9112,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "ahash", "async-trait", @@ -9146,7 +9152,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "finality-grandpa", "futures 0.3.21", @@ -9170,7 +9176,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "ansi_term", "futures 0.3.21", @@ -9187,7 +9193,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "hex", @@ -9202,7 +9208,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "asynchronous-codec 0.5.0", @@ -9251,7 +9257,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "ahash", "futures 0.3.21", @@ -9268,7 +9274,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "bytes 1.1.0", "fnv", @@ -9296,7 +9302,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "libp2p", @@ -9309,7 +9315,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9318,7 +9324,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "hash-db", @@ -9349,7 +9355,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9374,7 +9380,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "jsonrpc-core", @@ -9391,7 +9397,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "directories", @@ -9455,7 +9461,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "log", "parity-scale-codec", @@ -9469,7 +9475,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -9490,7 +9496,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "chrono", "futures 0.3.21", @@ -9508,7 +9514,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "ansi_term", "atty", @@ -9539,7 +9545,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -9550,7 +9556,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "futures-timer", @@ -9577,7 +9583,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "log", @@ -9590,7 +9596,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "futures-timer", @@ -10094,7 +10100,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "hash-db", "log", @@ -10111,7 +10117,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "blake2 0.10.4", "proc-macro-crate 1.1.3", @@ -10123,7 +10129,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "scale-info", @@ -10136,7 +10142,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "integer-sqrt", "num-traits", @@ -10151,7 +10157,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "scale-info", @@ -10164,7 +10170,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "parity-scale-codec", @@ -10176,7 +10182,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "sp-api", @@ -10188,7 +10194,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "log", @@ -10206,7 +10212,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "futures 0.3.21", @@ -10225,7 +10231,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "merlin", @@ -10248,7 +10254,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "scale-info", @@ -10262,7 +10268,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -10274,7 +10280,7 @@ dependencies = [ [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "base58", "bitflags", @@ -10320,7 +10326,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "blake2 0.10.4", "byteorder", @@ -10334,7 +10340,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "proc-macro2", "quote", @@ -10345,7 +10351,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "kvdb", "parking_lot 0.12.0", @@ -10354,7 +10360,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "proc-macro2", "quote", @@ -10364,7 +10370,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "environmental", "parity-scale-codec", @@ -10375,7 +10381,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "finality-grandpa", "log", @@ -10393,7 +10399,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10407,7 +10413,7 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "hash-db", @@ -10432,7 +10438,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "lazy_static", "sp-core", @@ -10443,7 +10449,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "futures 0.3.21", @@ -10460,7 +10466,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "thiserror", "zstd", @@ -10469,7 +10475,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "scale-info", @@ -10483,7 +10489,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "sp-api", "sp-core", @@ -10493,7 +10499,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "backtrace", "lazy_static", @@ -10503,7 +10509,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "rustc-hash", "serde", @@ -10513,7 +10519,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "either", "hash256-std-hasher", @@ -10535,7 +10541,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10552,7 +10558,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "Inflector", "proc-macro-crate 1.1.3", @@ -10564,7 +10570,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "serde", "serde_json", @@ -10573,7 +10579,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "scale-info", @@ -10587,7 +10593,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "scale-info", @@ -10598,7 +10604,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "hash-db", "log", @@ -10620,12 +10626,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10638,7 +10644,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "log", "sp-core", @@ -10651,7 +10657,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "futures-timer", @@ -10667,7 +10673,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "sp-std", @@ -10679,7 +10685,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "sp-api", "sp-runtime", @@ -10688,7 +10694,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "log", @@ -10704,7 +10710,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "hash-db", "memory-db", @@ -10720,7 +10726,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10737,7 +10743,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10748,7 +10754,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "impl-trait-for-tuples", "log", @@ -10949,7 +10955,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "platforms", ] @@ -10957,7 +10963,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.21", @@ -10979,7 +10985,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures-util", "hyper", @@ -10992,7 +10998,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "async-trait", "futures 0.3.21", @@ -11018,7 +11024,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "futures 0.3.21", "substrate-test-utils-derive", @@ -11028,7 +11034,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -11039,7 +11045,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "ansi_term", "build-helper", @@ -11720,7 +11726,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6506784c95c2b6ee1db19cdbfc8142e9c7a071dc" +source = "git+https://github.com/paritytech/substrate?branch=master#1bd5d786fda99d5a0c27c339226789ac047ea4ae" dependencies = [ "clap", "jsonrpsee 0.4.1", @@ -11748,6 +11754,7 @@ version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d60539445867cdd9680b2bfe2d0428f1814b7d5c9652f09d8d3eae9d19308db" dependencies = [ + "dissimilar", "glob", "once_cell", "serde", From 0e27b1863724ba98a36446313924374feee9c7e0 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 25 Mar 2022 07:11:02 -0700 Subject: [PATCH 091/231] Fixes --- runtime/kusama/src/xcm_config.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 1d848c5a0dda..d6deff1b7cb1 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -20,7 +20,11 @@ use super::{ parachains_origin, AccountId, AllPalletsWithSystem, Balances, Call, CouncilCollective, Event, Origin, ParaId, Runtime, WeightToFee, XcmPallet, }; -use frame_support::{match_types, parameter_types, traits::Everything, weights::Weight}; +use frame_support::{ + match_types, parameter_types, + traits::{Everything, Nothing}, + weights::Weight, +}; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ From 5c0290180a4e733724c3216a4fb6d39983b31cb3 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 7 Apr 2022 17:52:27 -0700 Subject: [PATCH 092/231] Ensure same array length before using copy_from_slice --- xcm/src/v3/multiasset.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index 507e8f931728..bbd26b9e2dcd 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -332,7 +332,8 @@ impl TryFrom for AssetId { Concrete(l) => Self::Concrete(l.try_into()?), Abstract(v) if v.len() <= 32 => { let mut r = [0u8; 32]; - r.copy_from_slice(&v[..]); + let (left, _right) = r.split_at_mut(v.len()); + left.copy_from_slice(&v[..]); Self::Abstract(r) }, _ => return Err(()), From 990a5d1168bc6527a1697f3920f3823bf154c8de Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 8 Apr 2022 00:57:25 -0700 Subject: [PATCH 093/231] Fixes --- xcm/xcm-builder/src/currency_adapter.rs | 3 ++- xcm/xcm-builder/tests/scenarios.rs | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/xcm/xcm-builder/src/currency_adapter.rs b/xcm/xcm-builder/src/currency_adapter.rs index 1a31d9f566c8..681607b7b038 100644 --- a/xcm/xcm-builder/src/currency_adapter.rs +++ b/xcm/xcm-builder/src/currency_adapter.rs @@ -17,7 +17,7 @@ //! Adapters to work with `frame_support::traits::Currency` through XCM. use frame_support::traits::{ExistenceRequirement::AllowDeath, Get, WithdrawReasons}; -use sp_runtime::traits::{CheckedSub, SaturatedConversion}; +use sp_runtime::traits::CheckedSub; use sp_std::{marker::PhantomData, result}; use xcm::latest::{Error as XcmError, MultiAsset, MultiLocation, Result, XcmContext}; use xcm_executor::{ @@ -174,6 +174,7 @@ impl< asset: &MultiAsset, from: &MultiLocation, to: &MultiLocation, + _context: &XcmContext, ) -> result::Result { log::trace!(target: "xcm::currency_adapter", "internal_transfer_asset asset: {:?}, from: {:?}, to: {:?}", asset, from, to); let amount = Matcher::matches_fungible(asset).ok_or(Error::AssetNotFound)?; diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index 3e8f18172662..27f57f3ecf7e 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -75,13 +75,16 @@ fn transfer_asset_works() { kusama_like_with_balances(balances).execute_with(|| { let amount = REGISTER_AMOUNT; let weight = BaseXcmWeight::get(); + let message = Xcm(vec![TransferAsset { + assets: (Here, amount).into(), + beneficiary: AccountId32 { network: None, id: bob.clone().into() }.into(), + }]); + let hash = fake_message_hash(&message); // Use `execute_xcm_in_credit` here to pass through the barrier let r = XcmExecutor::::execute_xcm_in_credit( - AccountId32 { network: NetworkId::Any, id: ALICE.into() }, - Xcm(vec![TransferAsset { - assets: (Here, amount).into(), - beneficiary: AccountId32 { network: NetworkId::Any, id: bob.clone().into() }.into(), - }]), + AccountId32 { network: None, id: ALICE.into() }, + message, + hash, weight, weight, ); From a1828ac15969a73b4bbe28cc0e4b9d5bde43ba80 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 8 Apr 2022 16:20:00 -0700 Subject: [PATCH 094/231] Add benchmarks for the UniversalOrigin instruction --- runtime/westend/src/weights/xcm/mod.rs | 2 +- .../src/weights/xcm/pallet_xcm_benchmarks_generic.rs | 3 +++ xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 11 +++++++++++ xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 8 +++++--- xcm/xcm-builder/src/test_utils.rs | 9 ++++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 130f4d218289..881b512218ae 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -217,7 +217,7 @@ impl XcmWeightInfo for WestendXcmWeight { XcmGeneric::::clear_transact_status() } fn universal_origin(_: &Junction) -> Weight { - Weight::MAX // todo fix + XcmGeneric::::universal_origin() } fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { Weight::MAX // todo fix diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 9ee70142fbc7..f2d0f0b9ffd3 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -176,4 +176,7 @@ impl WeightInfo { pub(crate) fn exchange_asset() -> Weight { (2_000_000_000_000 as Weight) } + pub(crate) fn universal_origin() -> Weight { + (2_000_000_000_000 as Weight) + } } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index e77a875049be..41998b1568ab 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -493,6 +493,17 @@ benchmarks! { assert_eq!(executor.holding(), &want.into()); } + universal_origin { + let mut executor = new_executor::(Here.into_location()); + + let instruction = Instruction::UniversalOrigin(GlobalConsensus(ByGenesis([0; 32]))); + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + assert_eq!(executor.origin(), &Some((Parent, GlobalConsensus(ByGenesis([0; 32]))).into())); + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index e0ecd1eda08c..18ea2551d069 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -20,7 +20,7 @@ use crate::{generic, mock::*, *}; use codec::Decode; use frame_support::{ parameter_types, - traits::{Everything, Nothing, OriginTrait}, + traits::{Everything, OriginTrait}, }; use sp_core::H256; use sp_runtime::{ @@ -29,7 +29,9 @@ use sp_runtime::{ BuildStorage, }; use xcm_builder::{ - test_utils::{Assets, TestAssetExchanger, TestAssetTrap, TestSubscriptionService}, + test_utils::{ + Assets, TestAssetExchanger, TestAssetTrap, TestSubscriptionService, TestUniversalAliases, + }, AllowUnpaidExecutionFrom, }; use xcm_executor::traits::ConvertOrigin; @@ -125,7 +127,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); // No bridges yet... type MessageExporter = (); - type UniversalAliases = Nothing; + type UniversalAliases = TestUniversalAliases; } impl crate::Config for Test { diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index e55b88f4dfe4..39b5a00e0eaf 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -19,7 +19,7 @@ use frame_support::{ dispatch::Weight, parameter_types, - traits::{CrateVersion, PalletInfoData, PalletsInfoAccess}, + traits::{Contains, CrateVersion, PalletInfoData, PalletsInfoAccess}, }; use sp_std::vec::Vec; pub use xcm::latest::prelude::*; @@ -130,3 +130,10 @@ impl PalletsInfoAccess for TestPalletsInfo { }); } } + +pub struct TestUniversalAliases; +impl Contains<(MultiLocation, Junction)> for TestUniversalAliases { + fn contains(aliases: &(MultiLocation, Junction)) -> bool { + &aliases.0 == &Here.into_location() && &aliases.1 == &GlobalConsensus(ByGenesis([0; 32])) + } +} From 7d05afd1dce242e32095cd5751f82d59874a25a7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 8 Apr 2022 16:20:50 -0700 Subject: [PATCH 095/231] Remove unused import --- runtime/polkadot/src/xcm_config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index ff1a5efa3aa3..f8f22149ab52 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -34,7 +34,6 @@ use xcm_builder::{ IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; -use xcm_executor::XcmExecutor; parameter_types! { /// The location of the DOT token, from the context of this chain. Since this token is native to this From e5052da1f6a21883f843680f6ba5b0a28f5e52dd Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 11 Apr 2022 11:05:28 -0700 Subject: [PATCH 096/231] Remove unused import --- runtime/kusama/src/xcm_config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index d6deff1b7cb1..c739e2bd0f9b 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -35,7 +35,6 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; -use xcm_executor::XcmExecutor; parameter_types! { /// The location of the KSM token, from the context of this chain. Since this token is native to this From 6632bffe17950f06e2fdb3bd9406d91fa4188335 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 11 Apr 2022 18:50:24 -0700 Subject: [PATCH 097/231] Add benchmarks for SetFeesMode instruction --- runtime/westend/src/weights/xcm/mod.rs | 2 +- .../weights/xcm/pallet_xcm_benchmarks_generic.rs | 3 +++ .../src/generic/benchmarking.rs | 14 +++++++++++++- xcm/xcm-executor/src/lib.rs | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 881b512218ae..47fb36c03242 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -235,7 +235,7 @@ impl XcmWeightInfo for WestendXcmWeight { Weight::MAX // todo fix } fn set_fees_mode(_: &bool) -> Weight { - Weight::MAX // todo fix + XcmGeneric::::set_fees_mode() } fn set_topic(_topic: &[u8; 32]) -> Weight { XcmGeneric::::set_topic() diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index f2d0f0b9ffd3..e1a6b2dc2181 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -179,4 +179,7 @@ impl WeightInfo { pub(crate) fn universal_origin() -> Weight { (2_000_000_000_000 as Weight) } + pub(crate) fn set_fees_mode() -> Weight { + (2_000_000_000_000 as Weight) + } } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 41998b1568ab..79d042d253c4 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -25,7 +25,7 @@ use xcm::{ latest::{prelude::*, MaybeErrorCode, MultiAssets}, DoubleEncoded, }; -use xcm_executor::ExecutorError; +use xcm_executor::{ExecutorError, FeesMode}; benchmarks! { report_holding { @@ -504,6 +504,18 @@ benchmarks! { assert_eq!(executor.origin(), &Some((Parent, GlobalConsensus(ByGenesis([0; 32]))).into())); } + set_fees_mode { + let mut executor = new_executor::(Default::default()); + executor.set_fees_mode(FeesMode { jit_withdraw: false }); + + let instruction = Instruction::SetFeesMode { jit_withdraw: true }; + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + assert_eq!(executor.fees_mode(), &FeesMode { jit_withdraw: true }); + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index f9458aae2351..9c6843b8b6a2 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -40,7 +40,7 @@ pub use assets::Assets; mod config; pub use config::Config; -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct FeesMode { pub jit_withdraw: bool, } From 865ee38af03cc71d9104af19c491805421cf9d8d Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 14 Apr 2022 19:57:38 -0700 Subject: [PATCH 098/231] Add benchmarks for asset (un)locking instructions --- runtime/westend/src/lib.rs | 5 + runtime/westend/src/weights/xcm/mod.rs | 8 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 12 +++ .../src/generic/benchmarking.rs | 91 +++++++++++++++++++ xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 10 +- xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 5 +- xcm/xcm-builder/src/test_utils.rs | 74 ++++++++++++++- 7 files changed, 197 insertions(+), 8 deletions(-) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index f59352aea3c7..6a403cab09cf 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1606,6 +1606,11 @@ sp_api::impl_runtime_apis! { let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } + + fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> { + // Westend doesn't support asset locking + Err(BenchmarkError::Skip) + } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 47fb36c03242..462035a14d91 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -223,16 +223,16 @@ impl XcmWeightInfo for WestendXcmWeight { Weight::MAX // todo fix } fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { - Weight::MAX // todo fix + XcmGeneric::::lock_asset() } fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { - Weight::MAX // todo fix + XcmGeneric::::unlock_asset() } fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { - Weight::MAX // todo fix + XcmGeneric::::note_unlockable() } fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { - Weight::MAX // todo fix + XcmGeneric::::request_unlock() } fn set_fees_mode(_: &bool) -> Weight { XcmGeneric::::set_fees_mode() diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index e1a6b2dc2181..f1034c704787 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -173,6 +173,18 @@ impl WeightInfo { pub(crate) fn clear_topic() -> Weight { (3_268_000 as Weight) } + pub(crate) fn lock_asset() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn unlock_asset() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn note_unlockable() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn request_unlock() -> Weight { + (2_000_000_000_000 as Weight) + } pub(crate) fn exchange_asset() -> Weight { (2_000_000_000_000 as Weight) } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 79d042d253c4..326e9988e300 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -516,6 +516,97 @@ benchmarks! { assert_eq!(executor.fees_mode(), &FeesMode { jit_withdraw: true }); } + lock_asset { + let (unlocker, owner, asset) = T::unlockable_asset()?; + + let mut executor = new_executor::(owner); + executor.set_holding(asset.clone().into()); + + let instruction = Instruction::LockAsset { asset, unlocker }; + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 + } + + unlock_asset { + use xcm_executor::traits::{AssetLock, Enact}; + + let (unlocker, owner, asset) = T::unlockable_asset()?; + + let mut executor = new_executor::(unlocker.clone()); + + // We first place the asset in lock first... + ::AssetLocker::prepare_lock( + unlocker, + asset.clone(), + owner.clone(), + ) + .map_err(|_| BenchmarkError::Skip)? + .enact() + .map_err(|_| BenchmarkError::Skip)?; + + // ... then unlock them with the UnlockAsset instruction. + let instruction = Instruction::UnlockAsset { asset, target: owner }; + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + + } + + note_unlockable { + use xcm_executor::traits::{AssetLock, Enact}; + + let (unlocker, owner, asset) = T::unlockable_asset()?; + + let mut executor = new_executor::(unlocker.clone()); + + // We first place the asset in lock first... + ::AssetLocker::prepare_lock( + unlocker, + asset.clone(), + owner.clone(), + ) + .map_err(|_| BenchmarkError::Skip)? + .enact() + .map_err(|_| BenchmarkError::Skip)?; + + // ... then note them as unlockable with the NoteUnlockable instruction. + let instruction = Instruction::NoteUnlockable { asset, owner }; + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + + } + + request_unlock { + use xcm_executor::traits::{AssetLock, Enact}; + + let (locker, owner, asset) = T::unlockable_asset()?; + + // We first place the asset in lock first... + ::AssetLocker::prepare_lock( + locker.clone(), + asset.clone(), + owner.clone(), + ) + .map_err(|_| BenchmarkError::Skip)? + .enact() + .map_err(|_| BenchmarkError::Skip)?; + + // ... then request for an unlock with the RequestUnlock instruction. + let mut executor = new_executor::(owner); + let instruction = Instruction::RequestUnlock { asset, locker }; + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 18ea2551d069..d0f670721f27 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -30,7 +30,8 @@ use sp_runtime::{ }; use xcm_builder::{ test_utils::{ - Assets, TestAssetExchanger, TestAssetTrap, TestSubscriptionService, TestUniversalAliases, + Assets, TestAssetExchanger, TestAssetLocker, TestAssetTrap, TestSubscriptionService, + TestUniversalAliases, }, AllowUnpaidExecutionFrom, }; @@ -118,7 +119,7 @@ impl xcm_executor::Config for XcmConfig { type Trader = xcm_builder::FixedRateOfFungible; type ResponseHandler = DevNull; type AssetTrap = TestAssetTrap; - type AssetLocker = (); + type AssetLocker = TestAssetLocker; type AssetExchanger = TestAssetExchanger; type AssetClaims = TestAssetTrap; type SubscriptionService = TestSubscriptionService; @@ -172,6 +173,11 @@ impl generic::Config for Test { let ticket = MultiLocation { parents: 0, interior: X1(GeneralIndex(0)) }; Ok((Default::default(), ticket, assets)) } + + fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> { + let assets: MultiAsset = (Concrete(Here.into()), 100).into(); + Ok((Default::default(), Default::default(), assets)) + } } pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 4ad88b8d1dc6..1e7bb14a2c61 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -8,7 +8,7 @@ mod mock; pub mod pallet { use frame_benchmarking::BenchmarkError; use frame_support::{dispatch::Dispatchable, pallet_prelude::Encode, weights::GetDispatchInfo}; - use xcm::latest::{MultiAssets, MultiLocation, Response}; + use xcm::latest::{MultiAsset, MultiAssets, MultiLocation, Response}; #[pallet::config] pub trait Config: frame_system::Config + crate::Config { @@ -41,6 +41,9 @@ pub mod pallet { /// Return an origin, ticket, and assets that can be trapped and claimed. fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError>; + + /// Return an unlocker, owner and assets that can be locked and unlocked. + fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError>; } #[pallet::pallet] diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index 39b5a00e0eaf..99c4a56cda20 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -25,7 +25,7 @@ use sp_std::vec::Vec; pub use xcm::latest::prelude::*; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ - traits::{AssetExchange, ConvertOrigin, OnResponse, TransactAsset}, + traits::{AssetExchange, AssetLock, ConvertOrigin, Enact, LockError, OnResponse, TransactAsset}, Assets, Config, }; @@ -137,3 +137,75 @@ impl Contains<(MultiLocation, Junction)> for TestUniversalAliases { &aliases.0 == &Here.into_location() && &aliases.1 == &GlobalConsensus(ByGenesis([0; 32])) } } + +parameter_types! { + pub static LockedAssets: Vec<(MultiLocation, MultiAsset)> = vec![]; +} + +pub struct TestLockTicket(MultiLocation, MultiAsset); +impl Enact for TestLockTicket { + fn enact(self) -> Result<(), LockError> { + let mut locked_assets = LockedAssets::get(); + locked_assets.push((self.0, self.1)); + LockedAssets::set(locked_assets); + Ok(()) + } +} +pub struct TestUnlockTicket(MultiLocation, MultiAsset); +impl Enact for TestUnlockTicket { + fn enact(self) -> Result<(), LockError> { + let mut locked_assets = LockedAssets::get(); + if let Some((idx, _)) = locked_assets + .iter() + .enumerate() + .find(|(_, (origin, asset))| origin == &self.0 && asset == &self.1) + { + locked_assets.remove(idx); + } + LockedAssets::set(locked_assets); + Ok(()) + } +} +pub struct TestReduceTicket; +impl Enact for TestReduceTicket { + fn enact(self) -> Result<(), LockError> { Ok(()) } +} + +pub struct TestAssetLocker; +impl AssetLock for TestAssetLocker { + type LockTicket = TestLockTicket; + type UnlockTicket = TestUnlockTicket; + type ReduceTicket = TestReduceTicket; + + fn prepare_lock( + unlocker: MultiLocation, + asset: MultiAsset, + _owner: MultiLocation, + ) -> Result { + Ok(TestLockTicket(unlocker, asset)) + } + + fn prepare_unlock( + unlocker: MultiLocation, + asset: MultiAsset, + _owner: MultiLocation, + ) -> Result { + Ok(TestUnlockTicket(unlocker, asset)) + } + + fn note_unlockable( + _locker: MultiLocation, + _asset: MultiAsset, + _owner: MultiLocation, + ) -> Result<(), LockError> { + Ok(()) + } + + fn prepare_reduce_unlockable( + _locker: MultiLocation, + _asset: MultiAsset, + _owner: MultiLocation, + ) -> Result { + Ok(TestReduceTicket) + } +} From 774945c43ed98b2e955019f8139ac4c51b2a2acb Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 14 Apr 2022 20:32:21 -0700 Subject: [PATCH 099/231] Leave AliasOrigin unbenchmarked --- runtime/westend/src/weights/xcm/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 462035a14d91..55c47c6034da 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -244,6 +244,7 @@ impl XcmWeightInfo for WestendXcmWeight { XcmGeneric::::clear_topic() } fn alias_origin(_: &MultiLocation) -> Weight { - Weight::MAX // todo fix + // XCM Executor does not currently support alias origin operations + Weight::MAX } } From 342532410bbacd9afb31a8b233b3c135de274ae9 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 14 Apr 2022 20:52:24 -0700 Subject: [PATCH 100/231] Fixes after merge --- runtime/kusama/src/lib.rs | 10 ++ runtime/kusama/src/weights/xcm/mod.rs | 94 ++++++++++++++----- .../xcm/pallet_xcm_benchmarks_generic.rs | 67 ++++++++++++- runtime/kusama/src/xcm_config.rs | 2 +- 4 files changed, 150 insertions(+), 23 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index d2647ba0009d..b4d25cd845af 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2033,6 +2033,11 @@ sp_api::impl_runtime_apis! { (0u64, Response::Version(Default::default())) } + fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> { + // Kusama doesn't support asset exchanges + Err(BenchmarkError::Skip) + } + fn transact_origin() -> Result { Ok(Statemine::get()) } @@ -2047,6 +2052,11 @@ sp_api::impl_runtime_apis! { let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } + + fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> { + // Kusama doesn't support asset locking + Err(BenchmarkError::Skip) + } } let whitelist: Vec = vec![ diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index f266e076636f..ebc1e7db18b9 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -75,7 +75,12 @@ impl XcmWeightInfo for KusamaXcmWeight { fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) } - fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> Weight { + fn query_response( + _query_id: &u64, + _response: &Response, + _max_weight: &u64, + _querier: &Option, + ) -> Weight { XcmGeneric::::query_response() } fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { @@ -117,31 +122,22 @@ impl XcmWeightInfo for KusamaXcmWeight { fn descend_origin(_who: &InteriorMultiLocation) -> Weight { XcmGeneric::::descend_origin() } - fn report_error( - _query_id: &QueryId, - _dest: &MultiLocation, - _max_response_weight: &u64, - ) -> Weight { + fn report_error(_query_response_info: &QueryResponseInfo) -> Weight { XcmGeneric::::report_error() } - fn deposit_asset( - assets: &MultiAssetFilter, - _max_assets: &u32, // TODO use max assets? - _dest: &MultiLocation, - ) -> Weight { + fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset( assets: &MultiAssetFilter, - _max_assets: &u32, // TODO use max assets? _dest: &MultiLocation, _xcm: &Xcm<()>, ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> Weight { - Weight::MAX // todo fix + fn exchange_asset(give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { + give.weigh_multi_assets(XcmGeneric::::exchange_asset()) } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, @@ -157,13 +153,8 @@ impl XcmWeightInfo for KusamaXcmWeight { ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } - fn query_holding( - _query_id: &u64, - _dest: &MultiLocation, - _assets: &MultiAssetFilter, - _max_response_weight: &u64, - ) -> Weight { - XcmGeneric::::query_holding() + fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight { + XcmGeneric::::report_holding() } fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { XcmGeneric::::buy_execution() @@ -192,4 +183,65 @@ impl XcmWeightInfo for KusamaXcmWeight { fn unsubscribe_version() -> Weight { XcmGeneric::::unsubscribe_version() } + fn burn_asset(assets: &MultiAssets) -> Weight { + assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + } + fn expect_asset(assets: &MultiAssets) -> Weight { + assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + } + fn expect_origin(_origin: &Option) -> Weight { + XcmGeneric::::expect_origin() + } + fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight { + XcmGeneric::::expect_error() + } + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::query_pallet() + } + fn expect_pallet( + _index: &u32, + _name: &Vec, + _module_name: &Vec, + _crate_major: &u32, + _min_crate_minor: &u32, + ) -> Weight { + XcmGeneric::::expect_pallet() + } + fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_transact_status() + } + fn clear_transact_status() -> Weight { + XcmGeneric::::clear_transact_status() + } + fn universal_origin(_: &Junction) -> Weight { + XcmGeneric::::universal_origin() + } + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { + Weight::MAX // todo fix + } + fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { + XcmGeneric::::lock_asset() + } + fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { + XcmGeneric::::unlock_asset() + } + fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { + XcmGeneric::::note_unlockable() + } + fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { + XcmGeneric::::request_unlock() + } + fn set_fees_mode(_: &bool) -> Weight { + XcmGeneric::::set_fees_mode() + } + fn set_topic(_topic: &[u8; 32]) -> Weight { + XcmGeneric::::set_topic() + } + fn clear_topic() -> Weight { + XcmGeneric::::clear_topic() + } + fn alias_origin(_: &MultiLocation) -> Weight { + // XCM Executor does not currently support alias origin operations + Weight::MAX + } } diff --git a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index b3d256cbd880..d590d5ea1cb9 100644 --- a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -51,7 +51,7 @@ impl WeightInfo { // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) - pub(crate) fn query_holding() -> Weight { + pub(crate) fn report_holding() -> Weight { (21_822_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) @@ -133,4 +133,69 @@ impl WeightInfo { .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + pub(crate) fn burn_asset() -> Weight { + (4_910_000 as Weight) + } + pub(crate) fn expect_asset() -> Weight { + (3_488_000 as Weight) + } + pub(crate) fn expect_origin() -> Weight { + (3_400_000 as Weight) + } + pub(crate) fn expect_error() -> Weight { + (3_358_000 as Weight) + } + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn query_pallet() -> Weight { + (21_841_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + pub(crate) fn expect_pallet() -> Weight { + (3_716_000 as Weight) + } + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn report_transact_status() -> Weight { + (20_503_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + pub(crate) fn clear_transact_status() -> Weight { + (3_270_000 as Weight) + } + pub(crate) fn set_topic() -> Weight { + (3_269_000 as Weight) + } + pub(crate) fn clear_topic() -> Weight { + (3_268_000 as Weight) + } + pub(crate) fn lock_asset() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn unlock_asset() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn note_unlockable() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn request_unlock() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn exchange_asset() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn universal_origin() -> Weight { + (2_000_000_000_000 as Weight) + } + pub(crate) fn set_fees_mode() -> Weight { + (2_000_000_000_000 as Weight) + } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index e44bcb5ebe22..71fb2cafbdc0 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -106,7 +106,7 @@ pub type XcmRouter = ( parameter_types! { pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const Statemine: MultiLocation = Parachain(1000).into(); + pub const Statemine: MultiLocation = Parachain(1000).into_location(); pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get()); pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Parachain(1001).into_location()); pub const MaxAssetsIntoHolding: u32 = 64; From c4a8da54bf3318d9a8a5a7fbbb7163ba9321d43e Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 14 Apr 2022 20:53:36 -0700 Subject: [PATCH 101/231] cargo fmt --- runtime/kusama/src/xcm_config.rs | 2 +- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 2 +- xcm/xcm-builder/src/test_utils.rs | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 71fb2cafbdc0..e273bc36e638 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -33,7 +33,7 @@ use xcm_builder::{ ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds + UsingComponents, WeightInfoBounds, }; parameter_types! { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index d0f670721f27..06405be0390c 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -174,7 +174,7 @@ impl generic::Config for Test { Ok((Default::default(), ticket, assets)) } - fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> { + fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> { let assets: MultiAsset = (Concrete(Here.into()), 100).into(); Ok((Default::default(), Default::default(), assets)) } diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index 99c4a56cda20..6376e46110e2 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -25,7 +25,9 @@ use sp_std::vec::Vec; pub use xcm::latest::prelude::*; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ - traits::{AssetExchange, AssetLock, ConvertOrigin, Enact, LockError, OnResponse, TransactAsset}, + traits::{ + AssetExchange, AssetLock, ConvertOrigin, Enact, LockError, OnResponse, TransactAsset, + }, Assets, Config, }; @@ -168,7 +170,9 @@ impl Enact for TestUnlockTicket { } pub struct TestReduceTicket; impl Enact for TestReduceTicket { - fn enact(self) -> Result<(), LockError> { Ok(()) } + fn enact(self) -> Result<(), LockError> { + Ok(()) + } } pub struct TestAssetLocker; From 81ec7d2fab3276952fd0576d176f6e48f06ef46a Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 14 Apr 2022 21:01:00 -0700 Subject: [PATCH 102/231] Fixes --- runtime/kusama/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index b4d25cd845af..861ef951693a 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1978,7 +1978,7 @@ sp_api::impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; - use xcm_config::{CheckAccount, KsmLocation, SovereignAccountOf, Statemine, XcmConfig}; + use xcm_config::{CheckAccount, Ksm, SovereignAccountOf, Statemine, XcmConfig}; impl pallet_session_benchmarking::Config for Runtime {} impl pallet_offences_benchmarking::Config for Runtime {} @@ -1994,7 +1994,7 @@ sp_api::impl_runtime_apis! { fn worst_case_holding() -> MultiAssets { // Kusama only knows about KSM. vec![MultiAsset{ - id: Concrete(KsmLocation::get()), + id: Concrete(Ksm::get()), fun: Fungible(1_000_000 * UNITS), }].into() } @@ -2003,11 +2003,11 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( Statemine::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(Ksm::get()) }, )); pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( Statemine::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(Ksm::get()) }, )); } @@ -2020,7 +2020,7 @@ sp_api::impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { - id: Concrete(KsmLocation::get()), + id: Concrete(Ksm::get()), fun: Fungible(1 * UNITS), } } @@ -2048,7 +2048,7 @@ sp_api::impl_runtime_apis! { fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { let origin = Statemine::get(); - let assets: MultiAssets = (Concrete(KsmLocation::get()), 1_000 * UNITS).into(); + let assets: MultiAssets = (Concrete(Ksm::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } From 325d4692ef2bc4f104eb600d57345f3a5e47c067 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 14 Apr 2022 22:10:45 -0700 Subject: [PATCH 103/231] Fixes --- runtime/kusama/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 861ef951693a..e67945033c1a 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1978,7 +1978,7 @@ sp_api::impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; - use xcm_config::{CheckAccount, Ksm, SovereignAccountOf, Statemine, XcmConfig}; + use xcm_config::{CheckAccount, SovereignAccountOf, Statemine, TokenLocation, XcmConfig}; impl pallet_session_benchmarking::Config for Runtime {} impl pallet_offences_benchmarking::Config for Runtime {} @@ -1991,10 +1991,10 @@ sp_api::impl_runtime_apis! { fn valid_destination() -> Result { Ok(Statemine::get()) } - fn worst_case_holding() -> MultiAssets { + fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Kusama only knows about KSM. vec![MultiAsset{ - id: Concrete(Ksm::get()), + id: Concrete(TokenLocation::get()), fun: Fungible(1_000_000 * UNITS), }].into() } @@ -2003,11 +2003,11 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( Statemine::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(Ksm::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( Statemine::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(Ksm::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); } @@ -2020,7 +2020,7 @@ sp_api::impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { - id: Concrete(Ksm::get()), + id: Concrete(TokenLocation::get()), fun: Fungible(1 * UNITS), } } @@ -2048,7 +2048,7 @@ sp_api::impl_runtime_apis! { fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { let origin = Statemine::get(); - let assets: MultiAssets = (Concrete(Ksm::get()), 1_000 * UNITS).into(); + let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } From a8b2f7f7cca7ef14d603e660d28c6c99436ac4be Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 15 Apr 2022 14:10:04 -0700 Subject: [PATCH 104/231] Set TrustedReserves to None on both Kusama and Westend --- runtime/kusama/src/lib.rs | 5 +---- runtime/westend/src/lib.rs | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 52293a9c01a6..dc6b42da6424 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2016,10 +2016,7 @@ sp_api::impl_runtime_apis! { Statemine::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); - pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( - Statemine::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, - )); + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None; } impl pallet_xcm_benchmarks::fungible::Config for Runtime { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 74696746bb90..435290f953ea 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1571,10 +1571,7 @@ sp_api::impl_runtime_apis! { Westmint::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); - pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( - Westmint::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, - )); + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None; } impl pallet_xcm_benchmarks::fungible::Config for Runtime { From 5a409eb7e9c62a7b211d7d9720240c076c4d5049 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 15 Apr 2022 22:43:20 -0700 Subject: [PATCH 105/231] Remove extraneous reserve_asset_deposited benchmark --- runtime/kusama/src/lib.rs | 2 -- runtime/westend/src/lib.rs | 2 -- .../src/fungible/benchmarking.rs | 19 ------------------- .../src/fungible/mock.rs | 8 +------- xcm/pallet-xcm-benchmarks/src/fungible/mod.rs | 4 ---- 5 files changed, 1 insertion(+), 34 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index dc6b42da6424..341a491ebda0 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2016,7 +2016,6 @@ sp_api::impl_runtime_apis! { Statemine::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); - pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None; } impl pallet_xcm_benchmarks::fungible::Config for Runtime { @@ -2024,7 +2023,6 @@ sp_api::impl_runtime_apis! { type CheckedAccount = CheckAccount; type TrustedTeleporter = TrustedTeleporter; - type TrustedReserve = TrustedReserve; fn get_multi_asset() -> MultiAsset { MultiAsset { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 435290f953ea..10c124386389 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1571,7 +1571,6 @@ sp_api::impl_runtime_apis! { Westmint::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); - pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None; } impl pallet_xcm_benchmarks::fungible::Config for Runtime { @@ -1579,7 +1578,6 @@ sp_api::impl_runtime_apis! { type CheckedAccount = xcm_config::CheckAccount; type TrustedTeleporter = TrustedTeleporter; - type TrustedReserve = TrustedReserve; fn get_multi_asset() -> MultiAsset { MultiAsset { diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 9a644d37824a..7a68e7ed939e 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -131,25 +131,6 @@ benchmarks_instance_pallet! { // TODO: Check sender queue is not empty. #4426 } - reserve_asset_deposited { - let (trusted_reserve, transferable_reserve_asset) = T::TrustedReserve::get() - .ok_or(BenchmarkError::Skip)?; - - let assets: MultiAssets = vec![ transferable_reserve_asset ].into(); - - let mut executor = new_executor::(trusted_reserve); - let instruction = Instruction::ReserveAssetDeposited(assets.clone()); - let xcm = Xcm(vec![instruction]); - }: { - executor.bench_process(xcm).map_err(|_| { - BenchmarkError::Override( - BenchmarkResult::from_weight(T::BlockWeights::get().max_block) - ) - })?; - } verify { - assert!(executor.holding().ensure_contains(&assets).is_ok()); - } - receive_teleported_asset { // If there is no trusted teleporter, then we skip this benchmark. let (trusted_teleporter, teleportable_asset) = T::TrustedTeleporter::get() diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index f20fe23146a8..8a657c5163bf 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -136,7 +136,7 @@ impl xcm_executor::Config for XcmConfig { type XcmSender = DevNull; type AssetTransactor = AssetTransactor; type OriginConverter = (); - type IsReserve = TrustedReserves; + type IsReserve = (); type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = AllowUnpaidExecutionFrom; @@ -173,7 +173,6 @@ impl crate::Config for Test { } pub type TrustedTeleporters = (xcm_builder::Case,); -pub type TrustedReserves = (xcm_builder::Case,); parameter_types! { pub const CheckedAccount: Option = Some(100); @@ -182,10 +181,6 @@ parameter_types! { ChildTeleporter::get(), MultiAsset { id: Concrete(Here.into_location()), fun: Fungible(100) }, )); - pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( - ChildTeleporter::get(), - MultiAsset { id: Concrete(Here.into_location()), fun: Fungible(100) }, - )); pub const TeleportConcreteFungible: (MultiAssetFilter, MultiLocation) = (Wild(AllOf { fun: WildFungible, id: Concrete(Here.into_location()) }), ChildTeleporter::get()); pub const ReserveConcreteFungible: (MultiAssetFilter, MultiLocation) = @@ -196,7 +191,6 @@ impl xcm_balances_benchmark::Config for Test { type TransactAsset = Balances; type CheckedAccount = CheckedAccount; type TrustedTeleporter = TrustedTeleporter; - type TrustedReserve = TrustedReserve; fn get_multi_asset() -> MultiAsset { let amount = diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs index 1acf61cf0010..e5062c310494 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs @@ -38,10 +38,6 @@ pub mod pallet { /// A trusted location which we allow teleports from, and the asset we allow to teleport. type TrustedTeleporter: Get>; - /// A trusted location where reserve assets are stored, and the asset we allow to be - /// reserves. - type TrustedReserve: Get>; - /// Give me a fungible asset that your asset transactor is going to accept. fn get_multi_asset() -> xcm::latest::MultiAsset; } From 49cb4d78ce574467753479f6ebfe0a17b2323dd9 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sun, 17 Apr 2022 01:36:09 -0700 Subject: [PATCH 106/231] Fix universal_origin benchmark --- runtime/kusama/src/lib.rs | 5 +++++ runtime/westend/src/lib.rs | 9 +++++++-- xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 8 ++++++-- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 4 ++++ xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 7 ++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 341a491ebda0..505adef83940 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2044,6 +2044,11 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } + fn universal_alias() -> Result { + // The XCM executor of Kusama doesn't have a configured `UniversalAliases` + Err(BenchmarkError::Skip) + } + fn transact_origin() -> Result { Ok(Statemine::get()) } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 10c124386389..c4a853eafbc6 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1546,8 +1546,8 @@ sp_api::impl_runtime_apis! { impl frame_system_benchmarking::Config for Runtime {} use xcm::latest::{ - AssetId::*, Fungibility::*, Junctions::*, MultiAsset, MultiAssets, MultiLocation, - Response, + AssetId::*, Fungibility::*, Junction, Junctions::*, MultiAsset, MultiAssets, + MultiLocation, Response, }; use xcm_config::{Westmint, TokenLocation}; @@ -1599,6 +1599,11 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } + fn universal_alias() -> Result { + // The XCM executor of Westend doesn't have a configured `UniversalAliases` + Err(BenchmarkError::Skip) + } + fn transact_origin() -> Result { Ok(Westmint::get()) } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 326e9988e300..05db22b287ac 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -494,14 +494,18 @@ benchmarks! { } universal_origin { + let alias = T::universal_alias().map_err(|_| BenchmarkError::Skip)?; + let mut executor = new_executor::(Here.into_location()); - let instruction = Instruction::UniversalOrigin(GlobalConsensus(ByGenesis([0; 32]))); + let instruction = Instruction::UniversalOrigin(alias.clone()); let xcm = Xcm(vec![instruction]); }: { executor.bench_process(xcm)?; } verify { - assert_eq!(executor.origin(), &Some((Parent, GlobalConsensus(ByGenesis([0; 32]))).into())); + use frame_support::traits::Get; + let universal_location = ::UniversalLocation::get(); + assert_eq!(executor.origin(), &Some(X1(alias).relative_to(&universal_location))); } set_fees_mode { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 06405be0390c..26b69fc527aa 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -160,6 +160,10 @@ impl generic::Config for Test { Ok(Default::default()) } + fn universal_alias() -> Result { + Ok(GlobalConsensus(ByGenesis([0; 32]))) + } + fn transact_origin() -> Result { Ok(Default::default()) } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 1e7bb14a2c61..cf5c03d2757c 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -8,7 +8,7 @@ mod mock; pub mod pallet { use frame_benchmarking::BenchmarkError; use frame_support::{dispatch::Dispatchable, pallet_prelude::Encode, weights::GetDispatchInfo}; - use xcm::latest::{MultiAsset, MultiAssets, MultiLocation, Response}; + use xcm::latest::{Junction, MultiAsset, MultiAssets, MultiLocation, Response}; #[pallet::config] pub trait Config: frame_system::Config + crate::Config { @@ -29,6 +29,11 @@ pub mod pallet { /// If set to `None`, benchmarks which rely on an `exchange_asset` will be skipped. fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError>; + /// A `Junction` that is one of the `UniversalAliases` configured by the XCM executor. + /// + /// If set to `None`, benchmarks which rely on a universal alais will be skipped. + fn universal_alias() -> Result; + /// The `MultiLocation` used for successful transaction XCMs. /// /// If set to `None`, benchmarks which rely on a `transact_origin` will be skipped. From 784941baa04853b577a87bb0561841c049127cc9 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Sun, 17 Apr 2022 09:20:42 +0000 Subject: [PATCH 107/231] cargo run --quiet --profile=production --features=runtime-benchmarks -- benchmark pallet --chain=westend-dev --steps=50 --repeat=20 --pallet=pallet_xcm_benchmarks::generic --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs --- .../xcm/pallet_xcm_benchmarks_generic.rs | 75 +++++++------------ 1 file changed, 29 insertions(+), 46 deletions(-) diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index f1034c704787..73a615cf0dee 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,12 +17,13 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-02-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-04-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: // target/production/polkadot // benchmark +// pallet // --chain=westend-dev // --steps=50 // --repeat=20 @@ -51,38 +52,38 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_holding() -> Weight { - (24_000_000 as Weight) + (24_686_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn buy_execution() -> Weight { - (3_377_000 as Weight) + (3_620_000 as Weight) } // Storage: XcmPallet Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (12_418_000 as Weight) + (12_946_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } pub(crate) fn transact() -> Weight { - (12_795_000 as Weight) + (13_206_000 as Weight) } pub(crate) fn refund_surplus() -> Weight { - (3_485_000 as Weight) + (3_879_000 as Weight) } pub(crate) fn set_error_handler() -> Weight { - (3_314_000 as Weight) + (3_659_000 as Weight) } pub(crate) fn set_appendix() -> Weight { - (3_334_000 as Weight) + (3_743_000 as Weight) } pub(crate) fn clear_error() -> Weight { - (3_240_000 as Weight) + (3_711_000 as Weight) } pub(crate) fn descend_origin() -> Weight { - (4_339_000 as Weight) + (4_618_000 as Weight) } pub(crate) fn clear_origin() -> Weight { - (3_338_000 as Weight) + (3_588_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -90,18 +91,18 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_error() -> Weight { - (20_469_000 as Weight) + (20_331_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: XcmPallet AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (7_749_000 as Weight) + (7_650_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } pub(crate) fn trap() -> Weight { - (3_271_000 as Weight) + (3_617_000 as Weight) } // Storage: XcmPallet VersionNotifyTargets (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -110,13 +111,13 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (22_263_000 as Weight) + (28_613_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: XcmPallet VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (5_366_000 as Weight) + (5_443_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -125,21 +126,21 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (23_659_000 as Weight) + (24_401_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn burn_asset() -> Weight { - (4_910_000 as Weight) + (5_259_000 as Weight) } pub(crate) fn expect_asset() -> Weight { - (3_488_000 as Weight) + (3_745_000 as Weight) } pub(crate) fn expect_origin() -> Weight { - (3_400_000 as Weight) + (3_847_000 as Weight) } pub(crate) fn expect_error() -> Weight { - (3_358_000 as Weight) + (3_633_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -147,12 +148,12 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn query_pallet() -> Weight { - (21_841_000 as Weight) + (21_645_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn expect_pallet() -> Weight { - (3_716_000 as Weight) + (4_017_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -160,38 +161,20 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_transact_status() -> Weight { - (20_503_000 as Weight) + (20_465_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn clear_transact_status() -> Weight { - (3_270_000 as Weight) + (3_723_000 as Weight) } pub(crate) fn set_topic() -> Weight { - (3_269_000 as Weight) + (3_687_000 as Weight) } pub(crate) fn clear_topic() -> Weight { - (3_268_000 as Weight) - } - pub(crate) fn lock_asset() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn unlock_asset() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn note_unlockable() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn request_unlock() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn exchange_asset() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn universal_origin() -> Weight { - (2_000_000_000_000 as Weight) + (3_654_000 as Weight) } pub(crate) fn set_fees_mode() -> Weight { - (2_000_000_000_000 as Weight) + (3_721_000 as Weight) } } From 923acc8f6b29db50b3d0e6315ca9f37caed6436c Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sun, 17 Apr 2022 02:31:57 -0700 Subject: [PATCH 108/231] Don't rely on skipped benchmark functions --- runtime/kusama/src/weights/xcm/mod.rs | 15 ++++++++++----- runtime/westend/src/weights/xcm/mod.rs | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index ebc1e7db18b9..5a0fec25f03c 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -214,22 +214,27 @@ impl XcmWeightInfo for KusamaXcmWeight { XcmGeneric::::clear_transact_status() } fn universal_origin(_: &Junction) -> Weight { - XcmGeneric::::universal_origin() + // Kusama does not currently support universal origin operations + Weight::MAX } fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { Weight::MAX // todo fix } fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { - XcmGeneric::::lock_asset() + // Kusama does not currently support asset locking operations + Weight::MAX } fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { - XcmGeneric::::unlock_asset() + // Kusama does not currently support asset locking operations + Weight::MAX } fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { - XcmGeneric::::note_unlockable() + // Kusama does not currently support asset locking operations + Weight::MAX } fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { - XcmGeneric::::request_unlock() + // Kusama does not currently support asset locking operations + Weight::MAX } fn set_fees_mode(_: &bool) -> Weight { XcmGeneric::::set_fees_mode() diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 55c47c6034da..21ed609284a9 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -217,22 +217,27 @@ impl XcmWeightInfo for WestendXcmWeight { XcmGeneric::::clear_transact_status() } fn universal_origin(_: &Junction) -> Weight { - XcmGeneric::::universal_origin() + // Westend does not currently support universal origin operations + Weight::MAX } fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { Weight::MAX // todo fix } fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { - XcmGeneric::::lock_asset() + // Westend does not currently support asset locking operations + Weight::MAX } fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { - XcmGeneric::::unlock_asset() + // Westend does not currently support asset locking operations + Weight::MAX } fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { - XcmGeneric::::note_unlockable() + // Westend does not currently support asset locking operations + Weight::MAX } fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { - XcmGeneric::::request_unlock() + // Westend does not currently support asset locking operations + Weight::MAX } fn set_fees_mode(_: &bool) -> Weight { XcmGeneric::::set_fees_mode() From 5e53cf5fca37b45e6801166d9221804bcf21966e Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 18 Apr 2022 13:17:47 -0700 Subject: [PATCH 109/231] Fixes --- runtime/kusama/src/weights/xcm/mod.rs | 3 ++- runtime/westend/src/weights/xcm/mod.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index 5a0fec25f03c..f9f0bfd343e3 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -137,7 +137,8 @@ impl XcmWeightInfo for KusamaXcmWeight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } fn exchange_asset(give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { - give.weigh_multi_assets(XcmGeneric::::exchange_asset()) + // Kusama does not currently support exchange asset operations + Weight::MAX } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 21ed609284a9..c997a8d6af2c 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -140,7 +140,8 @@ impl XcmWeightInfo for WestendXcmWeight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } fn exchange_asset(give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { - give.weigh_multi_assets(XcmGeneric::::exchange_asset()) + // Westend does not currently support exchange asset operations + Weight::MAX } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, From 94c76ce3cbabf124c18a4c6f2645b01fbd0648c9 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Mon, 18 Apr 2022 20:56:39 +0000 Subject: [PATCH 110/231] cargo run --quiet --profile=production --features=runtime-benchmarks -- benchmark pallet --chain=kusama-dev --steps=50 --repeat=20 --pallet=pallet_xcm_benchmarks::generic --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs --- .../xcm/pallet_xcm_benchmarks_generic.rs | 89 +++++++------------ 1 file changed, 34 insertions(+), 55 deletions(-) diff --git a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index d590d5ea1cb9..21cf6088b319 100644 --- a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Parity Technologies (UK) Ltd. +// Copyright 2021 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -17,12 +17,13 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-03-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-04-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 // Executed Command: // target/production/polkadot // benchmark +// pallet // --chain=kusama-dev // --steps=50 // --repeat=20 @@ -48,102 +49,98 @@ impl WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_holding() -> Weight { - (21_822_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) + (25_878_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn buy_execution() -> Weight { - (3_109_000 as Weight) + (3_697_000 as Weight) } // Storage: XcmPallet Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (12_087_000 as Weight) + (13_458_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } pub(crate) fn transact() -> Weight { - (12_398_000 as Weight) + (13_597_000 as Weight) } pub(crate) fn refund_surplus() -> Weight { - (3_247_000 as Weight) + (3_839_000 as Weight) } pub(crate) fn set_error_handler() -> Weight { - (3_086_000 as Weight) + (3_657_000 as Weight) } pub(crate) fn set_appendix() -> Weight { - (3_112_000 as Weight) + (3_757_000 as Weight) } pub(crate) fn clear_error() -> Weight { - (3_118_000 as Weight) + (3_651_000 as Weight) } pub(crate) fn descend_origin() -> Weight { - (4_054_000 as Weight) + (4_589_000 as Weight) } pub(crate) fn clear_origin() -> Weight { - (3_111_000 as Weight) + (3_661_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_error() -> Weight { - (18_425_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) + (21_351_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: XcmPallet AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (7_144_000 as Weight) + (7_674_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } pub(crate) fn trap() -> Weight { - (3_060_000 as Weight) + (3_606_000 as Weight) } // Storage: XcmPallet VersionNotifyTargets (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (21_642_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) + (30_453_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: XcmPallet VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (4_873_000 as Weight) + (5_543_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (22_809_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) + (25_464_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn burn_asset() -> Weight { - (4_910_000 as Weight) + (5_194_000 as Weight) } pub(crate) fn expect_asset() -> Weight { - (3_488_000 as Weight) + (3_698_000 as Weight) } pub(crate) fn expect_origin() -> Weight { - (3_400_000 as Weight) + (3_786_000 as Weight) } pub(crate) fn expect_error() -> Weight { - (3_358_000 as Weight) + (3_645_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -151,12 +148,12 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn query_pallet() -> Weight { - (21_841_000 as Weight) + (22_993_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn expect_pallet() -> Weight { - (3_716_000 as Weight) + (4_043_000 as Weight) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -164,38 +161,20 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_transact_status() -> Weight { - (20_503_000 as Weight) + (21_668_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } pub(crate) fn clear_transact_status() -> Weight { - (3_270_000 as Weight) + (3_673_000 as Weight) } pub(crate) fn set_topic() -> Weight { - (3_269_000 as Weight) + (3_661_000 as Weight) } pub(crate) fn clear_topic() -> Weight { - (3_268_000 as Weight) - } - pub(crate) fn lock_asset() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn unlock_asset() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn note_unlockable() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn request_unlock() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn exchange_asset() -> Weight { - (2_000_000_000_000 as Weight) - } - pub(crate) fn universal_origin() -> Weight { - (2_000_000_000_000 as Weight) + (3_647_000 as Weight) } pub(crate) fn set_fees_mode() -> Weight { - (2_000_000_000_000 as Weight) + (3_599_000 as Weight) } } From ae53f58f9975a03c6d6b282e51b9d46f5a92f991 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 18 Apr 2022 14:09:38 -0700 Subject: [PATCH 111/231] Fix unused variables --- runtime/kusama/src/weights/xcm/mod.rs | 2 +- runtime/westend/src/weights/xcm/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index f9f0bfd343e3..0084315d7b52 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -136,7 +136,7 @@ impl XcmWeightInfo for KusamaXcmWeight { ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset(give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { + fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { // Kusama does not currently support exchange asset operations Weight::MAX } diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index c997a8d6af2c..4dcfaf6889f0 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -139,7 +139,7 @@ impl XcmWeightInfo for WestendXcmWeight { ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset(give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { + fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { // Westend does not currently support exchange asset operations Weight::MAX } From 34a969bc788714b01aed1d5125f619ca5b3c3e34 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 22 Jun 2022 18:11:22 +0800 Subject: [PATCH 112/231] Fixes --- xcm/pallet-xcm/src/lib.rs | 10 ++++++++-- xcm/pallet-xcm/src/tests.rs | 6 ++++-- xcm/xcm-builder/src/nonfungibles_adapter.rs | 10 +++++----- xcm/xcm-simulator/example/src/lib.rs | 4 ++-- xcm/xcm-simulator/example/src/parachain.rs | 9 +++++---- xcm/xcm-simulator/example/src/relay_chain.rs | 9 +++++---- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 8d09ed2ac2d1..b87294fd6cd1 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -29,7 +29,9 @@ use frame_support::traits::{ }; use scale_info::TypeInfo; use sp_runtime::{ - traits::{BadOrigin, Saturating, Zero}, + traits::{ + AccountIdConversion, BadOrigin, BlakeTwo256, BlockNumberProvider, Hash, Saturating, Zero, + }, RuntimeDebug, }; use sp_std::{boxed::Box, marker::PhantomData, prelude::*, result::Result, vec}; @@ -44,7 +46,6 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; pub use pallet::*; -use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash}; use xcm_executor::{ traits::{ ClaimAssets, DropAssets, MatchesFungible, OnResponse, VersionChangeNotifier, WeightBounds, @@ -1283,6 +1284,11 @@ impl Pallet { T::XcmRouter::deliver(ticket) } + pub fn check_account() -> T::AccountId { + const ID: PalletId = PalletId(*b"py/xcmch"); + AccountIdConversion::::into_account_truncating(&ID) + } + /// Create a new expectation of a query response with the querier being here. fn do_new_query( responder: impl Into, diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index 95075831e412..da60cfb15ab4 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -158,8 +158,10 @@ fn report_outcome_works() { #[test] fn custom_querier_works() { - let balances = - vec![(ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account(), INITIAL_BALANCE)]; + let balances = vec![ + (ALICE, INITIAL_BALANCE), + (ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE), + ]; new_test_ext_with_balances(balances).execute_with(|| { let querier: MultiLocation = (Parent, AccountId32 { network: None, id: ALICE.into() }).into(); diff --git a/xcm/xcm-builder/src/nonfungibles_adapter.rs b/xcm/xcm-builder/src/nonfungibles_adapter.rs index d717145cc4fc..7c03ca47e755 100644 --- a/xcm/xcm-builder/src/nonfungibles_adapter.rs +++ b/xcm/xcm-builder/src/nonfungibles_adapter.rs @@ -29,7 +29,7 @@ pub struct NonFungiblesTransferAdapter, - Matcher: MatchesNonFungibles, + Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone, // can't get away without it since Currency is generic over it. > TransactAsset for NonFungiblesTransferAdapter @@ -65,10 +65,10 @@ pub struct NonFungiblesMutateAdapter< >(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>); impl< Assets: nonfungibles::Mutate, - Matcher: MatchesNonFungibles, + Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. - CheckAsset: Contains, + CheckAsset: Contains, CheckingAccount: Get>, > TransactAsset for NonFungiblesMutateAdapter< @@ -176,10 +176,10 @@ pub struct NonFungiblesAdapter< >(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>); impl< Assets: nonfungibles::Mutate + nonfungibles::Transfer, - Matcher: MatchesNonFungibles, + Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. - CheckAsset: Contains, + CheckAsset: Contains, CheckingAccount: Get>, > TransactAsset for NonFungiblesAdapter diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index d9c08a5f369f..dae82f0fedf2 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -495,7 +495,7 @@ mod tests { origin_kind: OriginKind::Xcm, require_weight_at_most: 1_000_000_000, call: parachain::Call::from(pallet_uniques::Call::::create { - class: (Parent, 2u64).into(), + collection: (Parent, 2u64).into(), admin: parent_account_id(), }) .encode() @@ -523,7 +523,7 @@ mod tests { ParaA::execute_with(|| { assert_eq!(parachain::Balances::reserved_balance(&parent_account_id()), 1000); assert_eq!( - parachain::ForeignUniques::class_owner((Parent, 2u64).into()), + parachain::ForeignUniques::collection_owner((Parent, 2u64).into()), Some(parent_account_id()) ); }); diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 77dfa962bf37..799a297b5ada 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -119,19 +119,20 @@ impl pallet_uniques::BenchmarkHelper for UniquesHe impl pallet_uniques::Config for Runtime { type Event = Event; - type ClassId = MultiLocation; - type InstanceId = AssetInstance; + type CollectionId = MultiLocation; + type ItemId = AssetInstance; type Currency = Balances; type CreateOrigin = ForeignCreators; type ForceOrigin = frame_system::EnsureRoot; - type ClassDeposit = frame_support::traits::ConstU128<1_000>; - type InstanceDeposit = frame_support::traits::ConstU128<1_000>; + type CollectionDeposit = frame_support::traits::ConstU128<1_000>; + type ItemDeposit = frame_support::traits::ConstU128<1_000>; type MetadataDepositBase = frame_support::traits::ConstU128<1_000>; type AttributeDepositBase = frame_support::traits::ConstU128<1_000>; type DepositPerByte = frame_support::traits::ConstU128<1>; type StringLimit = frame_support::traits::ConstU32<64>; type KeyLimit = frame_support::traits::ConstU32<64>; type ValueLimit = frame_support::traits::ConstU32<128>; + type Locker = (); type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type Helper = UniquesHelper; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index b7a7a13f0bf6..0726836bf190 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -90,19 +90,20 @@ impl pallet_balances::Config for Runtime { impl pallet_uniques::Config for Runtime { type Event = Event; - type ClassId = u32; - type InstanceId = u32; + type CollectionId = u32; + type ItemId = u32; type Currency = Balances; type CreateOrigin = AsEnsureOriginWithArg>; type ForceOrigin = frame_system::EnsureRoot; - type ClassDeposit = frame_support::traits::ConstU128<1_000>; - type InstanceDeposit = frame_support::traits::ConstU128<1_000>; + type CollectionDeposit = frame_support::traits::ConstU128<1_000>; + type ItemDeposit = frame_support::traits::ConstU128<1_000>; type MetadataDepositBase = frame_support::traits::ConstU128<1_000>; type AttributeDepositBase = frame_support::traits::ConstU128<1_000>; type DepositPerByte = frame_support::traits::ConstU128<1>; type StringLimit = frame_support::traits::ConstU32<64>; type KeyLimit = frame_support::traits::ConstU32<64>; type ValueLimit = frame_support::traits::ConstU32<128>; + type Locker = (); type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type Helper = (); From b63a68aa426f2d37eb0fd10de714f242ff7a35d0 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 22 Jun 2022 18:15:44 +0800 Subject: [PATCH 113/231] Spelling --- xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index cf5c03d2757c..fb891951d846 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -31,7 +31,7 @@ pub mod pallet { /// A `Junction` that is one of the `UniversalAliases` configured by the XCM executor. /// - /// If set to `None`, benchmarks which rely on a universal alais will be skipped. + /// If set to `None`, benchmarks which rely on a universal alias will be skipped. fn universal_alias() -> Result; /// The `MultiLocation` used for successful transaction XCMs. From 6b28a4b659e6e408bcdee2c0f0f81b1b4e368ae2 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 22 Jun 2022 18:32:03 +0800 Subject: [PATCH 114/231] Fixes --- xcm/xcm-simulator/example/src/parachain.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 799a297b5ada..8c66df971756 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -109,10 +109,10 @@ impl pallet_balances::Config for Runtime { pub struct UniquesHelper; #[cfg(feature = "runtime-benchmarks")] impl pallet_uniques::BenchmarkHelper for UniquesHelper { - fn class(i: u16) -> MultiLocation { + fn collection(i: u16) -> MultiLocation { GeneralIndex(i as u128).into() } - fn instance(i: u16) -> AssetInstance { + fn item(i: u16) -> AssetInstance { AssetInstance::Index(i as u128) } } From 99bf04dc146c75db335eaa61d3e7ad5d836c3f31 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 23 Jun 2022 16:50:16 +0800 Subject: [PATCH 115/231] Fix codec index of VersionedXcm --- xcm/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/src/lib.rs b/xcm/src/lib.rs index 5e3a0a6fe6dd..564508b953b4 100644 --- a/xcm/src/lib.rs +++ b/xcm/src/lib.rs @@ -355,9 +355,9 @@ versioned_type! { #[codec(decode_bound())] #[scale_info(bounds(), skip_type_params(Call))] pub enum VersionedXcm { - #[codec(index = 1)] - V2(v2::Xcm), #[codec(index = 2)] + V2(v2::Xcm), + #[codec(index = 3)] V3(v3::Xcm), } From 119a494672ca6b6f619561caea2eea16bff4dd45 Mon Sep 17 00:00:00 2001 From: nanocryk <6422796+nanocryk@users.noreply.github.com> Date: Wed, 29 Jun 2022 04:27:50 +0200 Subject: [PATCH 116/231] Allows to customize how calls are dispatched from XCM (#5657) * CallDispatcher trait * fmt * unused import * fix test-runtime * remove JustDispatch type * fix typo in test-runtime * missing CallDispatcher * more missing CallDispatcher --- .../bin/rialto-parachain/runtime/src/lib.rs | 1 + runtime/kusama/src/xcm_config.rs | 1 + runtime/polkadot/src/xcm_config.rs | 1 + runtime/rococo/src/xcm_config.rs | 1 + runtime/test-runtime/src/xcm_config.rs | 1 + runtime/westend/src/xcm_config.rs | 1 + .../src/fungible/mock.rs | 1 + xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 1 + xcm/pallet-xcm/src/mock.rs | 1 + xcm/xcm-builder/src/tests/mock.rs | 1 + xcm/xcm-builder/tests/mock/mod.rs | 1 + xcm/xcm-executor/src/config.rs | 11 ++++++-- xcm/xcm-executor/src/lib.rs | 27 ++++++++++--------- xcm/xcm-executor/src/traits/conversion.rs | 22 +++++++++++++++ xcm/xcm-executor/src/traits/mod.rs | 2 +- xcm/xcm-simulator/example/src/parachain.rs | 1 + xcm/xcm-simulator/example/src/relay_chain.rs | 1 + xcm/xcm-simulator/fuzzer/src/parachain.rs | 1 + xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 1 + 19 files changed, 61 insertions(+), 16 deletions(-) diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index 61e415c7990a..462c5afd1e16 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -385,6 +385,7 @@ impl Config for XcmConfig { type AssetExchanger = (); type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; + type CallDispatcher = Call; } /// No local origins on this chain are allowed to dispatch XCM sends/executions. diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index cdc00e5846f7..dce2b3cf746d 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -161,6 +161,7 @@ impl xcm_executor::Config for XcmConfig { // No bridges yet... type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } parameter_types! { diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 6e93e3c26e73..6c1a4b2c8ac6 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -158,6 +158,7 @@ impl xcm_executor::Config for XcmConfig { // No bridges yet... type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } parameter_types! { diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 8e71ca8daffe..c2625cc78e80 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -144,6 +144,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } parameter_types! { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 284a1d3dc21b..001f6b81e17e 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -103,4 +103,5 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = super::Call; } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index ecf1a8be21bb..4ea6c7e0e58d 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -123,6 +123,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 8a657c5163bf..1e7b65bf2a4f 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -153,6 +153,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } impl crate::Config for Test { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 26b69fc527aa..bb798cf94890 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -129,6 +129,7 @@ impl xcm_executor::Config for XcmConfig { // No bridges yet... type MessageExporter = (); type UniversalAliases = TestUniversalAliases; + type CallDispatcher = Call; } impl crate::Config for Test { diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 2a6018ac35f1..5ca57c1d3e98 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -300,6 +300,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index dc5b427e9674..1b8aeb2f679e 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -608,6 +608,7 @@ impl Config for TestConfig { type FeeManager = TestFeeManager; type UniversalAliases = TestUniversalAliases; type MessageExporter = TestMessageExporter; + type CallDispatcher = TestCall; } pub fn fungible_multi_asset(location: MultiLocation, amount: u128) -> MultiAsset { diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index b3e078b50f49..9da95f42b85a 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -195,6 +195,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 1184f77c6712..165a98875061 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -15,8 +15,9 @@ // along with Polkadot. If not, see . use crate::traits::{ - AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, - OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, + AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, + FeeManager, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, + WeightTrader, }; use frame_support::{ dispatch::{Dispatchable, Parameter}, @@ -94,4 +95,10 @@ pub trait Config { /// The origin locations and specific universal junctions to which they are allowed to elevate /// themselves. type UniversalAliases: Contains<(MultiLocation, Junction)>; + + /// The call dispatcher used by XCM. + /// + /// XCM will use this to dispatch any calls. When no special call dispatcher is required, + /// this can be set to the same type as `Self::Call`. + type CallDispatcher: CallDispatcher; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 9c6843b8b6a2..e0f9d5a85347 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -17,7 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ - dispatch::{Dispatchable, Weight}, + dispatch::Weight, ensure, traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, weights::GetDispatchInfo, @@ -30,8 +30,8 @@ use xcm::latest::prelude::*; pub mod traits; use traits::{ - validate_export, AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, Enact, - ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, + validate_export, AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, + DropAssets, Enact, ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; @@ -512,16 +512,17 @@ impl XcmExecutor { .map_err(|_| XcmError::BadOrigin)?; let weight = message_call.get_dispatch_info().weight; ensure!(weight <= require_weight_at_most, XcmError::MaxWeightInvalid); - let maybe_actual_weight = match message_call.dispatch(dispatch_origin) { - Ok(post_info) => { - self.transact_status = MaybeErrorCode::Success; - post_info.actual_weight - }, - Err(error_and_info) => { - self.transact_status = error_and_info.error.encode().into(); - error_and_info.post_info.actual_weight - }, - }; + let maybe_actual_weight = + match Config::CallDispatcher::dispatch(message_call, dispatch_origin) { + Ok(post_info) => { + self.transact_status = MaybeErrorCode::Success; + post_info.actual_weight + }, + Err(error_and_info) => { + self.transact_status = error_and_info.error.encode().into(); + error_and_info.post_info.actual_weight + }, + }; let actual_weight = maybe_actual_weight.unwrap_or(weight); let surplus = weight.saturating_sub(actual_weight); // We assume that the `Config::Weigher` will counts the `require_weight_at_most` diff --git a/xcm/xcm-executor/src/traits/conversion.rs b/xcm/xcm-executor/src/traits/conversion.rs index ee5c84f2c78b..512cf3c05093 100644 --- a/xcm/xcm-executor/src/traits/conversion.rs +++ b/xcm/xcm-executor/src/traits/conversion.rs @@ -15,6 +15,7 @@ // along with Polkadot. If not, see . use parity_scale_codec::{Decode, Encode}; +use sp_runtime::{traits::Dispatchable, DispatchErrorWithPostInfo}; use sp_std::{borrow::Borrow, prelude::*, result::Result}; use xcm::latest::prelude::*; @@ -203,3 +204,24 @@ impl ConvertOrigin for Tuple { Err(origin) } } + +/// Defines how a call is dispatched with given origin. +/// Allows to customize call dispatch, such as adapting the origin based on the call +/// or modifying the call. +pub trait CallDispatcher { + fn dispatch( + call: Call, + origin: Call::Origin, + ) -> Result>; +} + +// We implement it for every calls so they can dispatch themselves +// (without any change). +impl CallDispatcher for Call { + fn dispatch( + call: Call, + origin: Call::Origin, + ) -> Result> { + call.dispatch(origin) + } +} diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index ead19f79eea5..989c9d4e0006 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -17,7 +17,7 @@ //! Various traits used in configuring the executor. mod conversion; -pub use conversion::{Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry}; +pub use conversion::{CallDispatcher, Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry}; mod drop_assets; pub use drop_assets::{ClaimAssets, DropAssets}; mod asset_lock; diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 8c66df971756..cfaf86b2bffd 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -237,6 +237,7 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 0726836bf190..05c88ae5714e 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -181,6 +181,7 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 11eacc7f5963..67a941d45925 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -155,6 +155,7 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 4a0267214a8a..e6c10533e8e2 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -147,6 +147,7 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = Call; } pub type LocalOriginToLocation = SignedToAccountId32; From b4f0aee18b9ad319adb1bf3e756cc2b6195ddd83 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 26 Jul 2022 15:10:39 +0800 Subject: [PATCH 117/231] Update comment `NoteAssetLocked` -> `NoteUnlockable` --- xcm/src/v3/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index cd4060566aac..611987e80305 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -901,7 +901,7 @@ pub enum Instruction { /// This restriction may be removed by the `UnlockAsset` instruction being called with an /// Origin of `unlocker` and a `target` equal to the current `Origin`. /// - /// If the locking is successful, then a `NoteAssetLocked` instruction is sent to `unlocker`. + /// If the locking is successful, then a `NoteUnlockable` instruction is sent to `unlocker`. /// /// - `asset`: The asset(s) which should be locked. /// - `unlocker`: The value which the Origin must be for a corresponding `UnlockAsset` From dc5bb376dbe9cfc6897f38febbc1c1a0a0c335d8 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 24 Aug 2022 16:52:19 +0800 Subject: [PATCH 118/231] Fixes --- xcm/xcm-builder/src/test_utils.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index 6376e46110e2..20a5b5b87129 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -117,19 +117,21 @@ impl PalletsInfoAccess for TestPalletsInfo { fn count() -> usize { 2 } - fn accumulate(acc: &mut Vec) { - acc.push(PalletInfoData { - index: 0, - name: "System", - module_name: "pallet_system", - crate_version: CrateVersion { major: 1, minor: 10, patch: 1 }, - }); - acc.push(PalletInfoData { - index: 1, - name: "Balances", - module_name: "pallet_balances", - crate_version: CrateVersion { major: 1, minor: 42, patch: 69 }, - }); + fn infos() -> Vec { + vec![ + PalletInfoData { + index: 0, + name: "System", + module_name: "pallet_system", + crate_version: CrateVersion { major: 1, minor: 10, patch: 1 }, + }, + PalletInfoData { + index: 1, + name: "Balances", + module_name: "pallet_balances", + crate_version: CrateVersion { major: 1, minor: 42, patch: 69 }, + }, + ] } } From 29499baf1c323d0c2199c4da88ccfa58c007046d Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 24 Aug 2022 18:30:32 +0800 Subject: [PATCH 119/231] Fixes --- node/subsystem-util/src/determine_new_blocks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/subsystem-util/src/determine_new_blocks.rs b/node/subsystem-util/src/determine_new_blocks.rs index c2b54160cc86..aad1625798c2 100644 --- a/node/subsystem-util/src/determine_new_blocks.rs +++ b/node/subsystem-util/src/determine_new_blocks.rs @@ -124,7 +124,7 @@ where Ok(Ok(h)) => h, } }) - .for_each(|x| requests.push(x)); + .for_each(|x| requests.push_back(x)); let batch_headers: Vec<_> = requests.flat_map(|x: Option

| stream::iter(x)).collect().await; From 6d2bae494b457801c262c101f65a0929aa97c03a Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 20 Sep 2022 16:49:59 +0800 Subject: [PATCH 120/231] Adjust MultiAssets weights based on new wild card variants --- runtime/kusama/src/weights/xcm/mod.rs | 4 +++- runtime/westend/src/weights/xcm/mod.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index 0084315d7b52..4d95f8eddce8 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -46,7 +46,9 @@ impl WeighMultiAssets for MultiAssetFilter { AssetTypes::Unknown => Weight::MAX, }) .fold(0, |acc, x| acc.saturating_add(x)), - Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(balances_weight), + Self::Wild(AllOf(..) | AllOfCounted { .. }) => balances_weight, + Self::Wild(AllCounted(count)) => (*count as Weight).saturating_mul(balances_weight), + Self::Wild(All) => (MAX_ASSETS as Weight).saturating_mul(balances_weight), } } } diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 4dcfaf6889f0..127b69e8f909 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -49,7 +49,9 @@ impl WeighMultiAssets for MultiAssetFilter { AssetTypes::Unknown => Weight::MAX, }) .fold(0, |acc, x| acc.saturating_add(x)), - Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(balances_weight), + Self::Wild(AllOf(..) | AllOfCounted(..)) => balances_weight, + Self::Wild(AllCounted(count)) => (*count as Weight).saturating_mul(balances_weight), + Self::Wild(All) => (MAX_ASSETS as Weight).saturating_mul(balances_weight), } } } From bf26e0d9c10b1155ea09ccb5b10956865272f1b0 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 21 Sep 2022 02:53:41 +0800 Subject: [PATCH 121/231] Fixes --- runtime/kusama/src/weights/xcm/mod.rs | 2 +- runtime/westend/src/weights/xcm/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index 4d95f8eddce8..f7d02724aac9 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -46,7 +46,7 @@ impl WeighMultiAssets for MultiAssetFilter { AssetTypes::Unknown => Weight::MAX, }) .fold(0, |acc, x| acc.saturating_add(x)), - Self::Wild(AllOf(..) | AllOfCounted { .. }) => balances_weight, + Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight, Self::Wild(AllCounted(count)) => (*count as Weight).saturating_mul(balances_weight), Self::Wild(All) => (MAX_ASSETS as Weight).saturating_mul(balances_weight), } diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 127b69e8f909..f4c8facc04f9 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -49,7 +49,7 @@ impl WeighMultiAssets for MultiAssetFilter { AssetTypes::Unknown => Weight::MAX, }) .fold(0, |acc, x| acc.saturating_add(x)), - Self::Wild(AllOf(..) | AllOfCounted(..)) => balances_weight, + Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight, Self::Wild(AllCounted(count)) => (*count as Weight).saturating_mul(balances_weight), Self::Wild(All) => (MAX_ASSETS as Weight).saturating_mul(balances_weight), } From 7bd9d5fe9e783be439e414c8dc5a53cefc4014ce Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 22 Sep 2022 02:15:11 +0800 Subject: [PATCH 122/231] Fixes --- Cargo.lock | 4 ++-- xcm/xcm-builder/src/origin_conversion.rs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2633469627e7..f0584fa809da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "arbitrary" -version = "1.1.6" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f44124848854b941eafdb34f05b3bcf59472f643c7e151eba7c2b69daa469ed5" +checksum = "510c76ecefdceada737ea728f4f9a84bd2e1ef29f1ba555e560940fe279954de" [[package]] name = "array-bytes" diff --git a/xcm/xcm-builder/src/origin_conversion.rs b/xcm/xcm-builder/src/origin_conversion.rs index 0ba64d5bb0c3..19cb1261b200 100644 --- a/xcm/xcm-builder/src/origin_conversion.rs +++ b/xcm/xcm-builder/src/origin_conversion.rs @@ -277,8 +277,11 @@ where pub struct SignedToAccountId32( PhantomData<(RuntimeOrigin, AccountId, Network)>, ); -impl, Network: Get>> - Convert for SignedToAccountId32 +impl< + RuntimeOrigin: OriginTrait + Clone, + AccountId: Into<[u8; 32]>, + Network: Get>, + > Convert for SignedToAccountId32 where RuntimeOrigin::PalletsOrigin: From> + TryInto, Error = RuntimeOrigin::PalletsOrigin>, From ecdea0532dea6982877a23fd6f31f4cb47d77e89 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 22 Sep 2022 02:33:07 +0800 Subject: [PATCH 123/231] Fixes --- runtime/rococo/src/lib.rs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index f27905b66e29..67405f591986 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1904,20 +1904,20 @@ sp_api::impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; - use xcm_config::{CheckAccount, RocLocation, SovereignAccountOf, Statemine, XcmConfig}; + use xcm_config::{CheckAccount, LocationConverter, Statemine, TokenLocation, XcmConfig}; impl frame_system_benchmarking::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {} impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = XcmConfig; - type AccountIdConverter = SovereignAccountOf; + type AccountIdConverter = LocationConverter; fn valid_destination() -> Result { Ok(Statemine::get()) } - fn worst_case_holding() -> MultiAssets { + fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Rococo only knows about ROC vec![MultiAsset{ - id: Concrete(RocLocation::get()), + id: Concrete(TokenLocation::get()), fun: Fungible(1_000_000 * UNITS), }].into() } @@ -1926,11 +1926,11 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( Statemine::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(RocLocation::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( Statemine::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(RocLocation::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); } @@ -1939,11 +1939,10 @@ sp_api::impl_runtime_apis! { type CheckedAccount = CheckAccount; type TrustedTeleporter = TrustedTeleporter; - type TrustedReserve = TrustedReserve; fn get_multi_asset() -> MultiAsset { MultiAsset { - id: Concrete(RocLocation::get()), + id: Concrete(TokenLocation::get()), fun: Fungible(1 * UNITS), } } @@ -1956,6 +1955,16 @@ sp_api::impl_runtime_apis! { (0u64, Response::Version(Default::default())) } + fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> { + // Rococo doesn't support asset exchanges + Err(BenchmarkError::Skip) + } + + fn universal_alias() -> Result { + // The XCM executor of Rococo doesn't have a configured `UniversalAliases` + Err(BenchmarkError::Skip) + } + fn transact_origin() -> Result { Ok(Statemine::get()) } @@ -1966,10 +1975,15 @@ sp_api::impl_runtime_apis! { fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { let origin = Statemine::get(); - let assets: MultiAssets = (Concrete(RocLocation::get()), 1_000 * UNITS).into(); + let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } + + fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> { + // Rococo doesn't support asset locking + Err(BenchmarkError::Skip) + } } let whitelist: Vec = vec![ From 64b29965951ae049fcb2a93a458c4b043a879320 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 22 Sep 2022 10:47:54 +0800 Subject: [PATCH 124/231] Fixes --- xcm/xcm-simulator/example/src/parachain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 14529c66c1b1..abe9e0612689 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -156,7 +156,7 @@ impl EnsureOriginWithArg for ForeignCreators { } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin(a: &MultiLocation) -> Origin { + fn successful_origin(a: &MultiLocation) -> RuntimeOrigin { pallet_xcm::Origin::Xcm(a.clone()).into() } } From 3c2106789b8949b5ec71c995f3924d46a9a10590 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 22 Sep 2022 10:58:30 +0800 Subject: [PATCH 125/231] Fixes --- xcm/xcm-simulator/fuzzer/src/parachain.rs | 2 +- xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 8c1c2df959e2..1785e1178bf6 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -155,7 +155,7 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; - type CallDispatcher = Call; + type CallDispatcher = RuntimeCall; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 8aa1981ec247..aa6d4fd99583 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -146,7 +146,7 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; - type CallDispatcher = Call; + type CallDispatcher = RuntimeCall; } pub type LocalOriginToLocation = SignedToAccountId32; From fbc4327ea8922ad86cd2c3ff1352a3b9863aeb84 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Fri, 7 Oct 2022 14:22:19 +0100 Subject: [PATCH 126/231] Some late fixes for XCMv3 (#5237) * Maximise chances that trapped assets can be reclaimed * Do origin check as part of ExportMessage for security * Formatting * Fixes * Cleanup export XCM APIs * Formatting * Update xcm/src/v3/junctions.rs * UnpaidExecution instruction and associated barrier. * Tighten barriers (ClearOrigin/QueryResponse) * Allow only 1 ClearOrigin instruction in AllowTopLevelPaidExecutionFrom * Bi-directional teleport accounting * Revert other fix * Build fixes] * Tests build * Benchmark fixes Co-authored-by: Keith Yeung --- Cargo.lock | 6 +- runtime/kusama/src/weights/xcm/mod.rs | 3 + .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + runtime/kusama/src/xcm_config.rs | 6 +- runtime/polkadot/src/xcm_config.rs | 6 +- runtime/rococo/src/weights/xcm/mod.rs | 3 + .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + runtime/rococo/src/xcm_config.rs | 6 +- runtime/westend/src/weights/xcm/mod.rs | 3 + .../xcm/pallet_xcm_benchmarks_generic.rs | 3 + runtime/westend/src/xcm_config.rs | 4 +- xcm/pallet-xcm-benchmarks/Cargo.toml | 4 +- .../src/fungible/benchmarking.rs | 6 +- .../src/fungible/mock.rs | 8 +- xcm/pallet-xcm-benchmarks/src/fungible/mod.rs | 2 +- xcm/pallet-xcm/src/lib.rs | 15 +- xcm/src/v2/traits.rs | 4 +- xcm/src/v3/junctions.rs | 30 ++++ xcm/src/v3/mod.rs | 16 ++ xcm/src/v3/traits.rs | 14 +- xcm/xcm-builder/src/barriers.rs | 39 ++++- xcm/xcm-builder/src/currency_adapter.rs | 93 +++++++--- xcm/xcm-builder/src/fungibles_adapter.rs | 165 +++++++++++++++--- xcm/xcm-builder/src/lib.rs | 10 +- xcm/xcm-builder/src/nonfungibles_adapter.rs | 115 +++++++++--- xcm/xcm-builder/src/tests/barriers.rs | 50 ++++++ xcm/xcm-builder/src/tests/bridging/mod.rs | 6 +- xcm/xcm-builder/src/tests/mock.rs | 66 +++++-- xcm/xcm-builder/src/tests/origins.rs | 32 +++- xcm/xcm-builder/src/universal_exports.rs | 95 ++++------ xcm/xcm-builder/tests/mock/mod.rs | 6 +- xcm/xcm-executor/src/lib.rs | 43 ++++- xcm/xcm-executor/src/traits/export.rs | 22 ++- xcm/xcm-executor/src/traits/transact_asset.rs | 54 +++++- xcm/xcm-simulator/example/src/parachain.rs | 7 +- xcm/xcm-simulator/example/src/relay_chain.rs | 4 +- 36 files changed, 739 insertions(+), 213 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1c6206ead8d..432164a8120f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3395,7 +3395,7 @@ dependencies = [ [[package]] name = "libloading" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" dependencies = [ @@ -11862,8 +11862,8 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", - "digest 0.10.3", + "cfg-if 0.1.10", + "digest 0.10.5", "rand 0.8.5", "static_assertions", ] diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index a2996a0278de..64c19a79edfd 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -264,4 +264,7 @@ impl XcmWeightInfo for KusamaXcmWeight { // XCM Executor does not currently support alias origin operations Weight::MAX.ref_time() } + fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { + XcmGeneric::::unpaid_execution().ref_time() + } } diff --git a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 5ad10df2f5a8..69421bdb414b 100644 --- a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -177,4 +177,7 @@ impl WeightInfo { pub(crate) fn set_fees_mode() -> Weight { Weight::from_ref_time(3_599_000 as u64) } + pub(crate) fn unpaid_execution() -> Weight { + Weight::from_ref_time(3_111_000 as u64) + } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 443fb6f30058..b3b15a3443ce 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -31,8 +31,8 @@ use xcm_builder::{ AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, + MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + TakeWeightCredit, UsingComponents, WeightInfoBounds, }; parameter_types! { @@ -47,7 +47,7 @@ parameter_types! { /// Since Kusama is a top-level relay-chain with its own consensus, it's just our network ID. pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); /// The check account, which holds any native assets that have been teleported out and not back in (yet). - pub CheckAccount: AccountId = XcmPallet::check_account(); + pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); } /// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index a9dc71d274a2..9e1eeaa67f41 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -30,8 +30,8 @@ use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, - IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, - TakeWeightCredit, UsingComponents, + IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; parameter_types! { @@ -44,7 +44,7 @@ parameter_types! { /// Our location in the universe of consensus systems. pub const UniversalLocation: InteriorMultiLocation = X1(GlobalConsensus(ThisNetwork::get())); /// The check account, which holds any native assets that have been teleported out and not back in (yet). - pub CheckAccount: AccountId = XcmPallet::check_account(); + pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); } /// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine diff --git a/runtime/rococo/src/weights/xcm/mod.rs b/runtime/rococo/src/weights/xcm/mod.rs index 84bc50dff739..e0221357d24a 100644 --- a/runtime/rococo/src/weights/xcm/mod.rs +++ b/runtime/rococo/src/weights/xcm/mod.rs @@ -264,4 +264,7 @@ impl XcmWeightInfo for RococoXcmWeight { // XCM Executor does not currently support alias origin operations Weight::MAX.ref_time() } + fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { + XcmGeneric::::unpaid_execution().ref_time() + } } diff --git a/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index f9308d051ad6..f2d786e85a46 100644 --- a/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -180,4 +180,7 @@ impl WeightInfo { pub(crate) fn set_fees_mode() -> Weight { Weight::from_ref_time(3_721_000 as u64) } + pub(crate) fn unpaid_execution() -> Weight { + Weight::from_ref_time(3_111_000 as u64) + } } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 937446d78c94..503af148e8ce 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -31,8 +31,8 @@ use xcm_builder::{ AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, + MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + TakeWeightCredit, UsingComponents, WeightInfoBounds, }; use xcm_executor::XcmExecutor; @@ -40,7 +40,7 @@ parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub const ThisNetwork: NetworkId = NetworkId::Rococo; pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); - pub CheckAccount: AccountId = XcmPallet::check_account(); + pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); } pub type LocationConverter = diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 0c3ebe4b0cd7..4913ea15ae92 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -265,4 +265,7 @@ impl XcmWeightInfo for WestendXcmWeight { // XCM Executor does not currently support alias origin operations Weight::MAX.ref_time() } + fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { + XcmGeneric::::unpaid_execution().ref_time() + } } diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index e61ce93093c7..2a811ac3d2f0 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -177,4 +177,7 @@ impl WeightInfo { pub(crate) fn set_fees_mode() -> Weight { Weight::from_ref_time(3_721_000 as u64) } + pub(crate) fn unpaid_execution() -> Weight { + Weight::from_ref_time(3_111_000 as u64) + } } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 878842964b14..94098bbfc406 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -30,7 +30,7 @@ use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, + CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; @@ -40,7 +40,7 @@ parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub const ThisNetwork: NetworkId = Westend; pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); - pub CheckAccount: AccountId = XcmPallet::check_account(); + pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); } pub type LocationConverter = diff --git a/xcm/pallet-xcm-benchmarks/Cargo.toml b/xcm/pallet-xcm-benchmarks/Cargo.toml index 91872fc2f3b7..c2b1de663813 100644 --- a/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -18,6 +18,7 @@ sp-io = { default-features = false, branch = "master", git = "https://github.com xcm-executor = { path = "../xcm-executor", default-features = false } frame-benchmarking = { default-features = false, branch = "master", git = "https://github.com/paritytech/substrate" } xcm = { path = "..", default-features = false } +xcm-builder = { path = "../xcm-builder", default-features = false } log = "0.4.17" [dev-dependencies] @@ -25,7 +26,6 @@ pallet-balances = { branch = "master", git = "https://github.com/paritytech/subs pallet-assets = { branch = "master", git = "https://github.com/paritytech/substrate" } sp-core = { branch = "master", git = "https://github.com/paritytech/substrate" } sp-tracing = { branch = "master", git = "https://github.com/paritytech/substrate" } -xcm-builder = { path = "../xcm-builder" } xcm = { path = ".." } # temp pallet-xcm = { path = "../pallet-xcm" } @@ -43,10 +43,12 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", + "xcm-builder/std", "xcm-executor/std" ] runtime-benchmarks = [ "xcm/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 7a68e7ed939e..fade0d4869b3 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -136,7 +136,7 @@ benchmarks_instance_pallet! { let (trusted_teleporter, teleportable_asset) = T::TrustedTeleporter::get() .ok_or(BenchmarkError::Skip)?; - if let Some(checked_account) = T::CheckedAccount::get() { + if let Some((checked_account, _)) = T::CheckedAccount::get() { T::TransactAsset::mint_into( &checked_account, < @@ -223,7 +223,7 @@ benchmarks_instance_pallet! { holding.push(asset.clone()); // Checked account starts at zero - assert!(T::CheckedAccount::get().map_or(true, |c| T::TransactAsset::balance(&c).is_zero())); + assert!(T::CheckedAccount::get().map_or(true, |(c, _)| T::TransactAsset::balance(&c).is_zero())); let mut executor = new_executor::(Default::default()); executor.set_holding(holding.into()); @@ -236,7 +236,7 @@ benchmarks_instance_pallet! { }: { executor.bench_process(xcm)?; } verify { - if let Some(checked_account) = T::CheckedAccount::get() { + if let Some((checked_account, _)) = T::CheckedAccount::get() { // teleport checked account should have received some asset. assert!(!T::TransactAsset::balance(&checked_account).is_zero()); } diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 77cdd058e800..b1004818e685 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -30,7 +30,7 @@ use sp_runtime::{ BuildStorage, }; use xcm::latest::prelude::*; -use xcm_builder::AllowUnpaidExecutionFrom; +use xcm_builder::{AllowUnpaidExecutionFrom, MintLocation}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -123,7 +123,7 @@ pub type AssetTransactor = xcm_builder::CurrencyAdapter< MatchAnyFungible, AccountIdConverter, u64, - CheckedAccount, + CheckingAccount, >; parameter_types! { @@ -179,7 +179,7 @@ impl crate::Config for Test { pub type TrustedTeleporters = (xcm_builder::Case,); parameter_types! { - pub const CheckedAccount: Option = Some(100); + pub const CheckingAccount: Option<(u64, MintLocation)> = Some((100, MintLocation::Local)); pub const ChildTeleporter: MultiLocation = Parachain(1000).into_location(); pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( ChildTeleporter::get(), @@ -193,7 +193,7 @@ parameter_types! { impl xcm_balances_benchmark::Config for Test { type TransactAsset = Balances; - type CheckedAccount = CheckedAccount; + type CheckedAccount = CheckingAccount; type TrustedTeleporter = TrustedTeleporter; fn get_multi_asset() -> MultiAsset { diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs index 0194c3b97a07..011e84a0e42e 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs @@ -34,7 +34,7 @@ pub mod pallet { type TransactAsset: frame_support::traits::fungible::Mutate; /// The account used to check assets being teleported. - type CheckedAccount: Get>; + type CheckedAccount: Get>; /// A trusted location which we allow teleports from, and the asset we allow to teleport. type TrustedTeleporter: Get>; diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 649fa8e4cf92..0073221d30fa 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -35,7 +35,10 @@ use sp_runtime::{ RuntimeDebug, }; use sp_std::{boxed::Box, marker::PhantomData, prelude::*, result::Result, vec}; -use xcm::{latest::{QueryResponseInfo, Weight as XcmWeight}, prelude::*}; +use xcm::{ + latest::{QueryResponseInfo, Weight as XcmWeight}, + prelude::*, +}; use xcm_executor::traits::{Convert, ConvertOrigin}; use frame_support::{ @@ -779,8 +782,8 @@ pub mod pallet { origin_location, message, hash, - max_weight.ref_time(), - max_weight.ref_time(), + max_weight, //.ref_time(), + max_weight, //.ref_time(), ); let result = Ok(Some(outcome.weight_used().saturating_add(100_000_000)).into()); Self::deposit_event(Event::Attempted(outcome)); @@ -1341,7 +1344,7 @@ impl Pallet { let responder = responder.into(); let destination = T::UniversalLocation::get() .invert_target(&responder) - .map_err(|()| XcmError::MultiLocationNotInvertible)?; + .map_err(|()| XcmError::LocationNotInvertible)?; let query_id = Self::new_query(responder, timeout, Here); let response_info = QueryResponseInfo { destination, query_id, max_weight: 0 }; let report_error = Xcm(vec![ReportError(response_info)]); @@ -1380,7 +1383,7 @@ impl Pallet { let responder = responder.into(); let destination = T::UniversalLocation::get() .invert_target(&responder) - .map_err(|()| XcmError::MultiLocationNotInvertible)?; + .map_err(|()| XcmError::LocationNotInvertible)?; let notify: ::RuntimeCall = notify.into(); let max_weight = notify.get_dispatch_info().weight.ref_time(); let query_id = Self::new_notify_query(responder, notify, timeout, Here); @@ -1479,7 +1482,7 @@ impl xcm_executor::traits::Enact for LockTicket { None => { locks .try_push((self.amount, self.unlocker.clone().into())) - .map_err(|()| UnexpectedState)?; + .map_err(|(_balance, _location)| UnexpectedState)?; }, } LockedFungibles::::insert(&self.sovereign_account, locks); diff --git a/xcm/src/v2/traits.rs b/xcm/src/v2/traits.rs index 948278858889..77900e514c4b 100644 --- a/xcm/src/v2/traits.rs +++ b/xcm/src/v2/traits.rs @@ -120,8 +120,8 @@ impl TryFrom for Error { Unimplemented => Self::Unimplemented, UntrustedReserveLocation => Self::UntrustedReserveLocation, UntrustedTeleportLocation => Self::UntrustedTeleportLocation, - MultiLocationFull => Self::MultiLocationFull, - MultiLocationNotInvertible => Self::MultiLocationNotInvertible, + LocationFull => Self::MultiLocationFull, + LocationNotInvertible => Self::MultiLocationNotInvertible, BadOrigin => Self::BadOrigin, InvalidLocation => Self::InvalidLocation, AssetNotFound => Self::AssetNotFound, diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs index 34815add7fb2..9bf7905a86a3 100644 --- a/xcm/src/v3/junctions.rs +++ b/xcm/src/v3/junctions.rs @@ -221,6 +221,36 @@ impl Junctions { } } + /// Extract the network ID and the interior consensus location, treating this value as a + /// universal location. + /// + /// This will return an `Err` if the first item is not a `GlobalConsensus`, which would indicate + /// that this value is not a universal location. + pub fn split_global(self) -> Result<(NetworkId, Junctions), ()> { + match self.split_first() { + (location, Some(Junction::GlobalConsensus(network))) => Ok((network, location)), + _ => return Err(()), + } + } + + /// Treat `self` as a universal location and the context of `relative`, returning the universal + /// location of relative. + /// + /// This will return an error if `relative` has as many (or more) parents than there are + /// junctions in `self`, implying that relative refers into a different global consensus. + pub fn within_global(mut self, relative: MultiLocation) -> Result { + if self.len() <= relative.parents as usize { + return Err(()) + } + for _ in 0..relative.parents { + self.take_last(); + } + for j in relative.interior { + self.push(j).map_err(|_| ())?; + } + Ok(self) + } + /// Consumes `self` and returns how `viewer` would address it locally. pub fn relative_to(mut self, viewer: &Junctions) -> MultiLocation { let mut i = 0; diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 611987e80305..7369d4a9c20c 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -986,6 +986,18 @@ pub enum Instruction { /// /// Errors: If the existing state would not allow such a change. AliasOrigin(MultiLocation), + + /// A directive to indicate that the origin expects free execution of the message. + /// + /// At execution time, this instruction just does a check on the Origin register. + /// However, at the barrier stage messages starting with this instruction can be disregarded if + /// the origin is not acceptable for free execution or the `weight_limit` is `Limited` and + /// insufficient. + /// + /// Kind: *Indication* + /// + /// Errors: If the given origin is `Some` and not equal to the current Origin register. + UnpaidExecution { weight_limit: WeightLimit, check_origin: Option }, } impl Xcm { @@ -1060,6 +1072,8 @@ impl Instruction { SetTopic(topic) => SetTopic(topic), ClearTopic => ClearTopic, AliasOrigin(location) => AliasOrigin(location), + UnpaidExecution { weight_limit, check_origin } => + UnpaidExecution { weight_limit, check_origin }, } } } @@ -1126,6 +1140,8 @@ impl> GetWeight for Instruction { SetTopic(topic) => W::set_topic(topic), ClearTopic => W::clear_topic(), AliasOrigin(location) => W::alias_origin(location), + UnpaidExecution { weight_limit, check_origin } => + W::unpaid_execution(weight_limit, check_origin), } } } diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 6f78cb19ef67..028d8365c1e3 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -41,10 +41,10 @@ pub enum Error { UntrustedTeleportLocation, /// `MultiLocation` value too large to descend further. #[codec(index = 4)] - MultiLocationFull, + LocationFull, /// `MultiLocation` value ascend more parents than known ancestors of local location. #[codec(index = 5)] - MultiLocationNotInvertible, + LocationNotInvertible, /// The Origin Register does not contain a valid value for instruction. #[codec(index = 6)] BadOrigin, @@ -126,6 +126,12 @@ pub enum Error { /// The state was not in a condition where the operation was valid to make. #[codec(index = 32)] NoPermission, + /// The universal location of the local consensus is improper. + #[codec(index = 33)] + Unanchored, + /// An asset cannot be deposited, probably because (too much of) it already exists. + #[codec(index = 34)] + NotDepositable, // Errors that happen prior to instructions being executed. These fall outside of the XCM spec. /// XCM version not able to be handled. @@ -161,8 +167,8 @@ impl TryFrom for Error { Unimplemented => Self::Unimplemented, UntrustedReserveLocation => Self::UntrustedReserveLocation, UntrustedTeleportLocation => Self::UntrustedTeleportLocation, - MultiLocationFull => Self::MultiLocationFull, - MultiLocationNotInvertible => Self::MultiLocationNotInvertible, + MultiLocationFull => Self::LocationFull, + MultiLocationNotInvertible => Self::LocationNotInvertible, BadOrigin => Self::BadOrigin, InvalidLocation => Self::InvalidLocation, AssetNotFound => Self::AssetNotFound, diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 4bcd3c144cf7..7bb66917f1d9 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -74,7 +74,10 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionFro ); ensure!(T::contains(origin), ()); - let mut iter = instructions.iter_mut(); + // We will read up to 5 instructions. This allows up to 3 `ClearOrigin`s instructions. We + // allow for more than one since anything beyond the first is a no-op and it's conceivable + // that composition of operations might result in more than one being appended. + let mut iter = instructions.iter_mut().take(5); let i = iter.next().ok_or(())?; match i { ReceiveTeleportedAsset(..) | @@ -196,9 +199,10 @@ impl< } } -/// Allows execution from any origin that is contained in `T` (i.e. `T::Contains(origin)`) without -/// any payments. -/// Use only for executions from trusted origin groups. +/// Allows execution from any origin that is contained in `T` (i.e. `T::Contains(origin)`). +/// +/// Use only for executions from completely trusted origins, from which no unpermissioned messages +/// can be sent. pub struct AllowUnpaidExecutionFrom(PhantomData); impl> ShouldExecute for AllowUnpaidExecutionFrom { fn should_execute( @@ -217,6 +221,32 @@ impl> ShouldExecute for AllowUnpaidExecutionFrom { } } +/// Allows execution from any origin that is contained in `T` (i.e. `T::Contains(origin)`) if the +/// message begins with the instruction `UnpaidExecution`. +/// +/// Use only for executions from trusted origin groups. +pub struct AllowExplicitUnpaidExecutionFrom(PhantomData); +impl> ShouldExecute for AllowExplicitUnpaidExecutionFrom { + fn should_execute( + origin: &MultiLocation, + instructions: &mut [Instruction], + max_weight: Weight, + _weight_credit: &mut Weight, + ) -> Result<(), ()> { + log::trace!( + target: "xcm::barriers", + "AllowUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + origin, instructions, max_weight, _weight_credit, + ); + ensure!(T::contains(origin), ()); + match instructions.first() { + Some(UnpaidExecution { weight_limit: Limited(m), .. }) if *m >= max_weight => Ok(()), + Some(UnpaidExecution { weight_limit: Unlimited, .. }) => Ok(()), + _ => Err(()), + } + } +} + /// Allows a message only if it is from a system-level child parachain. pub struct IsChildSystemParachain(PhantomData); impl> Contains for IsChildSystemParachain { @@ -243,6 +273,7 @@ impl ShouldExecute for AllowKnownQueryResponses diff --git a/xcm/xcm-builder/src/currency_adapter.rs b/xcm/xcm-builder/src/currency_adapter.rs index 661e68cb2acb..09818248cddf 100644 --- a/xcm/xcm-builder/src/currency_adapter.rs +++ b/xcm/xcm-builder/src/currency_adapter.rs @@ -16,6 +16,7 @@ //! Adapters to work with `frame_support::traits::Currency` through XCM. +use super::MintLocation; use frame_support::traits::{ExistenceRequirement::AllowDeath, Get, WithdrawReasons}; use sp_runtime::traits::CheckedSub; use sp_std::{marker::PhantomData, result}; @@ -93,7 +94,41 @@ impl< Matcher: MatchesFungible, AccountIdConverter: Convert, AccountId: Clone, // can't get away without it since Currency is generic over it. - CheckedAccount: Get>, + CheckedAccount: Get>, + > CurrencyAdapter +{ + fn can_accrue_checked(_checked_account: AccountId, _amount: Currency::Balance) -> Result { + Ok(()) + } + fn can_reduce_checked(checked_account: AccountId, amount: Currency::Balance) -> Result { + let new_balance = Currency::free_balance(&checked_account) + .checked_sub(&amount) + .ok_or(XcmError::NotWithdrawable)?; + Currency::ensure_can_withdraw( + &checked_account, + amount, + WithdrawReasons::TRANSFER, + new_balance, + ) + .map_err(|_| XcmError::NotWithdrawable) + } + fn accrue_checked(checked_account: AccountId, amount: Currency::Balance) { + Currency::deposit_creating(&checked_account, amount); + } + fn reduce_checked(checked_account: AccountId, amount: Currency::Balance) { + let ok = + Currency::withdraw(&checked_account, amount, WithdrawReasons::TRANSFER, AllowDeath) + .is_ok(); + debug_assert!(ok, "`can_check_in` must have returned `true` immediately prior; qed"); + } +} + +impl< + Currency: frame_support::traits::Currency, + Matcher: MatchesFungible, + AccountIdConverter: Convert, + AccountId: Clone, // can't get away without it since Currency is generic over it. + CheckedAccount: Get>, > TransactAsset for CurrencyAdapter { @@ -102,45 +137,49 @@ impl< // Check we handle this asset. let amount: Currency::Balance = Matcher::matches_fungible(what).ok_or(Error::AssetNotFound)?; - if let Some(checked_account) = CheckedAccount::get() { - let new_balance = Currency::free_balance(&checked_account) - .checked_sub(&amount) - .ok_or(XcmError::NotWithdrawable)?; - Currency::ensure_can_withdraw( - &checked_account, - amount, - WithdrawReasons::TRANSFER, - new_balance, - ) - .map_err(|_| XcmError::NotWithdrawable)?; + match CheckedAccount::get() { + Some((checked_account, MintLocation::Local)) => + Self::can_reduce_checked(checked_account, amount), + Some((checked_account, MintLocation::NonLocal)) => + Self::can_accrue_checked(checked_account, amount), + None => Ok(()), } - Ok(()) } fn check_in(_origin: &MultiLocation, what: &MultiAsset, _context: &XcmContext) { log::trace!(target: "xcm::currency_adapter", "check_in origin: {:?}, what: {:?}", _origin, what); if let Some(amount) = Matcher::matches_fungible(what) { - if let Some(checked_account) = CheckedAccount::get() { - let ok = Currency::withdraw( - &checked_account, - amount, - WithdrawReasons::TRANSFER, - AllowDeath, - ) - .is_ok(); - debug_assert!( - ok, - "`can_check_in` must have returned `true` immediately prior; qed" - ); + match CheckedAccount::get() { + Some((checked_account, MintLocation::Local)) => + Self::reduce_checked(checked_account, amount), + Some((checked_account, MintLocation::NonLocal)) => + Self::accrue_checked(checked_account, amount), + None => (), } } } + fn can_check_out(_dest: &MultiLocation, what: &MultiAsset, _context: &XcmContext) -> Result { + log::trace!(target: "xcm::currency_adapter", "check_out dest: {:?}, what: {:?}", _dest, what); + let amount = Matcher::matches_fungible(what).ok_or(Error::AssetNotFound)?; + match CheckedAccount::get() { + Some((checked_account, MintLocation::Local)) => + Self::can_accrue_checked(checked_account, amount), + Some((checked_account, MintLocation::NonLocal)) => + Self::can_reduce_checked(checked_account, amount), + None => Ok(()), + } + } + fn check_out(_dest: &MultiLocation, what: &MultiAsset, _context: &XcmContext) { log::trace!(target: "xcm::currency_adapter", "check_out dest: {:?}, what: {:?}", _dest, what); if let Some(amount) = Matcher::matches_fungible(what) { - if let Some(checked_account) = CheckedAccount::get() { - Currency::deposit_creating(&checked_account, amount); + match CheckedAccount::get() { + Some((checked_account, MintLocation::Local)) => + Self::accrue_checked(checked_account, amount), + Some((checked_account, MintLocation::NonLocal)) => + Self::reduce_checked(checked_account, amount), + None => (), } } } diff --git a/xcm/xcm-builder/src/fungibles_adapter.rs b/xcm/xcm-builder/src/fungibles_adapter.rs index 3a96c417177e..32cf6f014a5f 100644 --- a/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/xcm/xcm-builder/src/fungibles_adapter.rs @@ -54,6 +54,63 @@ impl< } } +/// The location which is allowed to mint a particular asset. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum MintLocation { + /// This chain is allowed to mint the asset. When we track teleports of the asset we ensure that + /// no more of the asset returns back to the chain than has been sent out. + Local, + /// This chain is not allowed to mint the asset. When we track teleports of the asset we ensure + /// that no more of the asset is sent out from the chain than has been previously received. + NonLocal, +} + +pub trait AssetChecking { + fn asset_checking(asset: &AssetId) -> Option; +} + +pub struct NoChecking; +impl AssetChecking for NoChecking { + fn asset_checking(_: &AssetId) -> Option { + None + } +} + +pub struct LocalMint(sp_std::marker::PhantomData); +impl> AssetChecking for LocalMint { + fn asset_checking(asset: &AssetId) -> Option { + match T::contains(asset) { + true => Some(MintLocation::Local), + false => None, + } + } +} + +pub struct NonLocalMint(sp_std::marker::PhantomData); +impl> AssetChecking for NonLocalMint { + fn asset_checking(asset: &AssetId) -> Option { + match T::contains(asset) { + true => Some(MintLocation::NonLocal), + false => None, + } + } +} + +pub struct DualMint(sp_std::marker::PhantomData<(L, R)>); +impl, R: Contains> AssetChecking + for DualMint +{ + fn asset_checking(asset: &AssetId) -> Option { + if L::contains(asset) { + Some(MintLocation::Local) + } else if R::contains(asset) { + Some(MintLocation::NonLocal) + } else { + None + } + } +} + pub struct FungiblesMutateAdapter< Assets, Matcher, @@ -62,12 +119,48 @@ pub struct FungiblesMutateAdapter< CheckAsset, CheckingAccount, >(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>); + +impl< + Assets: fungibles::Mutate, + Matcher: MatchesFungibles, + AccountIdConverter: Convert, + AccountId: Clone, // can't get away without it since Currency is generic over it. + CheckAsset: AssetChecking, + CheckingAccount: Get, + > + FungiblesMutateAdapter +{ + fn can_accrue_checked(asset_id: Assets::AssetId, amount: Assets::Balance) -> XcmResult { + let checking_account = CheckingAccount::get(); + Assets::can_deposit(asset_id, &checking_account, amount, true) + .into_result() + .map_err(|_| XcmError::NotDepositable) + } + fn can_reduce_checked(asset_id: Assets::AssetId, amount: Assets::Balance) -> XcmResult { + let checking_account = CheckingAccount::get(); + Assets::can_withdraw(asset_id, &checking_account, amount) + .into_result() + .map_err(|_| XcmError::NotWithdrawable) + .map(|_| ()) + } + fn accrue_checked(asset_id: Assets::AssetId, amount: Assets::Balance) { + let checking_account = CheckingAccount::get(); + let ok = Assets::mint_into(asset_id, &checking_account, amount).is_ok(); + debug_assert!(ok, "`can_accrue_checked` must have returned `true` immediately prior; qed"); + } + fn reduce_checked(asset_id: Assets::AssetId, amount: Assets::Balance) { + let checking_account = CheckingAccount::get(); + let ok = Assets::burn_from(asset_id, &checking_account, amount).is_ok(); + debug_assert!(ok, "`can_reduce_checked` must have returned `true` immediately prior; qed"); + } +} + impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: Convert, AccountId: Clone, // can't get away without it since Currency is generic over it. - CheckAsset: Contains, + CheckAsset: AssetChecking, CheckingAccount: Get, > TransactAsset for FungiblesMutateAdapter< @@ -91,14 +184,13 @@ impl< ); // Check we handle this asset. let (asset_id, amount) = Matcher::matches_fungibles(what)?; - if CheckAsset::contains(&asset_id) { - // This is an asset whose teleports we track. - let checking_account = CheckingAccount::get(); - Assets::can_withdraw(asset_id, &checking_account, amount) - .into_result() - .map_err(|_| XcmError::NotWithdrawable)?; + match CheckAsset::asset_checking(&asset_id) { + // We track this asset's teleports to ensure no more come in than have gone out. + Some(MintLocation::Local) => Self::can_reduce_checked(asset_id, amount), + // We track this asset's teleports to ensure no more go out than have come in. + Some(MintLocation::NonLocal) => Self::can_accrue_checked(asset_id, amount), + _ => Ok(()), } - Ok(()) } fn check_in(_origin: &MultiLocation, what: &MultiAsset, _context: &XcmContext) { @@ -108,17 +200,37 @@ impl< _origin, what ); if let Ok((asset_id, amount)) = Matcher::matches_fungibles(what) { - if CheckAsset::contains(&asset_id) { - let checking_account = CheckingAccount::get(); - let ok = Assets::burn_from(asset_id, &checking_account, amount).is_ok(); - debug_assert!( - ok, - "`can_check_in` must have returned `true` immediately prior; qed" - ); + match CheckAsset::asset_checking(&asset_id) { + // We track this asset's teleports to ensure no more come in than have gone out. + Some(MintLocation::Local) => Self::reduce_checked(asset_id, amount), + // We track this asset's teleports to ensure no more go out than have come in. + Some(MintLocation::NonLocal) => Self::accrue_checked(asset_id, amount), + _ => (), } } } + fn can_check_out( + _origin: &MultiLocation, + what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { + log::trace!( + target: "xcm::fungibles_adapter", + "can_check_in origin: {:?}, what: {:?}", + _origin, what + ); + // Check we handle this asset. + let (asset_id, amount) = Matcher::matches_fungibles(what)?; + match CheckAsset::asset_checking(&asset_id) { + // We track this asset's teleports to ensure no more come in than have gone out. + Some(MintLocation::Local) => Self::can_accrue_checked(asset_id, amount), + // We track this asset's teleports to ensure no more go out than have come in. + Some(MintLocation::NonLocal) => Self::can_reduce_checked(asset_id, amount), + _ => Ok(()), + } + } + fn check_out(_dest: &MultiLocation, what: &MultiAsset, _context: &XcmContext) { log::trace!( target: "xcm::fungibles_adapter", @@ -126,10 +238,12 @@ impl< _dest, what ); if let Ok((asset_id, amount)) = Matcher::matches_fungibles(what) { - if CheckAsset::contains(&asset_id) { - let checking_account = CheckingAccount::get(); - let ok = Assets::mint_into(asset_id, &checking_account, amount).is_ok(); - debug_assert!(ok, "`mint_into` cannot generally fail; qed"); + match CheckAsset::asset_checking(&asset_id) { + // We track this asset's teleports to ensure no more come in than have gone out. + Some(MintLocation::Local) => Self::accrue_checked(asset_id, amount), + // We track this asset's teleports to ensure no more go out than have come in. + Some(MintLocation::NonLocal) => Self::reduce_checked(asset_id, amount), + _ => (), } } } @@ -181,7 +295,7 @@ impl< Matcher: MatchesFungibles, AccountIdConverter: Convert, AccountId: Clone, // can't get away without it since Currency is generic over it. - CheckAsset: Contains, + CheckAsset: AssetChecking, CheckingAccount: Get, > TransactAsset for FungiblesAdapter @@ -208,6 +322,17 @@ impl< >::check_in(origin, what, context) } + fn can_check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult { + FungiblesMutateAdapter::< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + >::can_check_out(dest, what, context) + } + fn check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) { FungiblesMutateAdapter::< Assets, diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index eb160fa12ecd..f48480616ac5 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -47,15 +47,19 @@ pub use asset_conversion::{ConvertedAbstractAssetId, ConvertedConcreteAssetId}; mod barriers; pub use barriers::{ - AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, - AllowUnpaidExecutionFrom, IsChildSystemParachain, TakeWeightCredit, WithComputedOrigin, + AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, + AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, IsChildSystemParachain, + TakeWeightCredit, WithComputedOrigin, }; mod currency_adapter; pub use currency_adapter::CurrencyAdapter; mod fungibles_adapter; -pub use fungibles_adapter::{FungiblesAdapter, FungiblesMutateAdapter, FungiblesTransferAdapter}; +pub use fungibles_adapter::{ + AssetChecking, DualMint, FungiblesAdapter, FungiblesMutateAdapter, FungiblesTransferAdapter, + LocalMint, MintLocation, NoChecking, NonLocalMint, +}; mod nonfungibles_adapter; pub use nonfungibles_adapter::{ diff --git a/xcm/xcm-builder/src/nonfungibles_adapter.rs b/xcm/xcm-builder/src/nonfungibles_adapter.rs index 7c03ca47e755..2735a03ab6f3 100644 --- a/xcm/xcm-builder/src/nonfungibles_adapter.rs +++ b/xcm/xcm-builder/src/nonfungibles_adapter.rs @@ -16,9 +16,10 @@ //! Adapters to work with `frame_support::traits::tokens::fungibles` through XCM. +use crate::{AssetChecking, MintLocation}; use frame_support::{ ensure, - traits::{tokens::nonfungibles, Contains, Get}, + traits::{tokens::nonfungibles, Get}, }; use sp_std::{marker::PhantomData, prelude::*, result}; use xcm::latest::prelude::*; @@ -63,12 +64,55 @@ pub struct NonFungiblesMutateAdapter< CheckAsset, CheckingAccount, >(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>); + +impl< + Assets: nonfungibles::Mutate, + Matcher: MatchesNonFungibles, + AccountIdConverter: Convert, + AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. + CheckAsset: AssetChecking, + CheckingAccount: Get>, + > + NonFungiblesMutateAdapter< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + > +{ + fn can_accrue_checked(class: Assets::CollectionId, instance: Assets::ItemId) -> XcmResult { + ensure!(Assets::owner(&class, &instance).is_none(), XcmError::NotDepositable); + Ok(()) + } + fn can_reduce_checked(class: Assets::CollectionId, instance: Assets::ItemId) -> XcmResult { + if let Some(checking_account) = CheckingAccount::get() { + // This is an asset whose teleports we track. + let owner = Assets::owner(&class, &instance); + ensure!(owner == Some(checking_account), XcmError::NotWithdrawable); + ensure!(Assets::can_transfer(&class, &instance), XcmError::NotWithdrawable); + } + Ok(()) + } + fn accrue_checked(class: Assets::CollectionId, instance: Assets::ItemId) { + if let Some(checking_account) = CheckingAccount::get() { + let ok = Assets::mint_into(&class, &instance, &checking_account).is_ok(); + debug_assert!(ok, "`mint_into` cannot generally fail; qed"); + } + } + fn reduce_checked(class: Assets::CollectionId, instance: Assets::ItemId) { + let ok = Assets::burn(&class, &instance, None).is_ok(); + debug_assert!(ok, "`can_check_in` must have returned `true` immediately prior; qed"); + } +} + impl< Assets: nonfungibles::Mutate, Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. - CheckAsset: Contains, + CheckAsset: AssetChecking, CheckingAccount: Get>, > TransactAsset for NonFungiblesMutateAdapter< @@ -88,15 +132,13 @@ impl< ); // Check we handle this asset. let (class, instance) = Matcher::matches_nonfungibles(what)?; - if CheckAsset::contains(&class) { - if let Some(checking_account) = CheckingAccount::get() { - // This is an asset whose teleports we track. - let owner = Assets::owner(&class, &instance); - ensure!(owner == Some(checking_account), XcmError::NotWithdrawable); - ensure!(Assets::can_transfer(&class, &instance), XcmError::NotWithdrawable); - } + match CheckAsset::asset_checking(&class) { + // We track this asset's teleports to ensure no more come in than have gone out. + Some(MintLocation::Local) => Self::can_reduce_checked(class, instance), + // We track this asset's teleports to ensure no more go out than have come in. + Some(MintLocation::NonLocal) => Self::can_accrue_checked(class, instance), + _ => Ok(()), } - Ok(()) } fn check_in(_origin: &MultiLocation, what: &MultiAsset, context: &XcmContext) { @@ -106,16 +148,33 @@ impl< _origin, what, context, ); if let Ok((class, instance)) = Matcher::matches_nonfungibles(what) { - if CheckAsset::contains(&class) { - let ok = Assets::burn(&class, &instance, None).is_ok(); - debug_assert!( - ok, - "`can_check_in` must have returned `true` immediately prior; qed" - ); + match CheckAsset::asset_checking(&class) { + // We track this asset's teleports to ensure no more come in than have gone out. + Some(MintLocation::Local) => Self::reduce_checked(class, instance), + // We track this asset's teleports to ensure no more go out than have come in. + Some(MintLocation::NonLocal) => Self::accrue_checked(class, instance), + _ => (), } } } + fn can_check_out(_dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult { + log::trace!( + target: "xcm::fungibles_adapter", + "can_check_out dest: {:?}, what: {:?}, context: {:?}", + _dest, what, context, + ); + // Check we handle this asset. + let (class, instance) = Matcher::matches_nonfungibles(what)?; + match CheckAsset::asset_checking(&class) { + // We track this asset's teleports to ensure no more come in than have gone out. + Some(MintLocation::Local) => Self::can_accrue_checked(class, instance), + // We track this asset's teleports to ensure no more go out than have come in. + Some(MintLocation::NonLocal) => Self::can_reduce_checked(class, instance), + _ => Ok(()), + } + } + fn check_out(_dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) { log::trace!( target: "xcm::fungibles_adapter", @@ -123,11 +182,12 @@ impl< _dest, what, context, ); if let Ok((class, instance)) = Matcher::matches_nonfungibles(what) { - if CheckAsset::contains(&class) { - if let Some(checking_account) = CheckingAccount::get() { - let ok = Assets::mint_into(&class, &instance, &checking_account).is_ok(); - debug_assert!(ok, "`mint_into` cannot generally fail; qed"); - } + match CheckAsset::asset_checking(&class) { + // We track this asset's teleports to ensure no more come in than have gone out. + Some(MintLocation::Local) => Self::accrue_checked(class, instance), + // We track this asset's teleports to ensure no more go out than have come in. + Some(MintLocation::NonLocal) => Self::reduce_checked(class, instance), + _ => (), } } } @@ -179,7 +239,7 @@ impl< Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. - CheckAsset: Contains, + CheckAsset: AssetChecking, CheckingAccount: Get>, > TransactAsset for NonFungiblesAdapter @@ -206,6 +266,17 @@ impl< >::check_in(origin, what, context) } + fn can_check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult { + NonFungiblesMutateAdapter::< + Assets, + Matcher, + AccountIdConverter, + AccountId, + CheckAsset, + CheckingAccount, + >::can_check_out(dest, what, context) + } + fn check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) { NonFungiblesMutateAdapter::< Assets, diff --git a/xcm/xcm-builder/src/tests/barriers.rs b/xcm/xcm-builder/src/tests/barriers.rs index b3af3b6c4d1d..b3cfaa48f0f5 100644 --- a/xcm/xcm-builder/src/tests/barriers.rs +++ b/xcm/xcm-builder/src/tests/barriers.rs @@ -107,6 +107,56 @@ fn allow_unpaid_should_work() { assert_eq!(r, Ok(())); } +#[test] +fn allow_explicit_unpaid_should_work() { + let mut bad_message1 = + Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); + + let mut bad_message2 = Xcm::<()>(vec![ + UnpaidExecution { weight_limit: Limited(10), check_origin: Some(Parent.into()) }, + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]); + + let mut good_message = Xcm::<()>(vec![ + UnpaidExecution { weight_limit: Limited(20), check_origin: Some(Parent.into()) }, + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]); + + AllowExplicitUnpaidFrom::set(vec![Parent.into()]); + + let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( + &Parachain(1).into(), + good_message.inner_mut(), + 20, + &mut 0, + ); + assert_eq!(r, Err(())); + + let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( + &Parent.into(), + bad_message1.inner_mut(), + 20, + &mut 0, + ); + assert_eq!(r, Err(())); + + let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( + &Parent.into(), + bad_message2.inner_mut(), + 20, + &mut 0, + ); + assert_eq!(r, Err(())); + + let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( + &Parent.into(), + good_message.inner_mut(), + 20, + &mut 0, + ); + assert_eq!(r, Ok(())); +} + #[test] fn allow_paid_should_work() { AllowPaidFrom::set(vec![Parent.into()]); diff --git a/xcm/xcm-builder/src/tests/bridging/mod.rs b/xcm/xcm-builder/src/tests/bridging/mod.rs index f145fc2d4d0c..aac51f228b0d 100644 --- a/xcm/xcm-builder/src/tests/bridging/mod.rs +++ b/xcm/xcm-builder/src/tests/bridging/mod.rs @@ -89,19 +89,21 @@ struct UnpaidExecutingRouter( fn price( n: NetworkId, c: u32, + s: &InteriorMultiLocation, d: &InteriorMultiLocation, m: &Xcm<()>, ) -> Result { - Ok(validate_export::(n, c, d.clone(), m.clone())?.1) + Ok(validate_export::(n, c, s.clone(), d.clone(), m.clone())?.1) } fn deliver( n: NetworkId, c: u32, + s: InteriorMultiLocation, d: InteriorMultiLocation, m: Xcm<()>, ) -> Result { - export_xcm::(n, c, d, m).map(|(hash, _)| hash) + export_xcm::(n, c, s, d, m).map(|(hash, _)| hash) } impl, Remote: Get, RemoteExporter: ExportXcm> SendXcm diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index af8241c0b252..46590b08f679 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -16,8 +16,8 @@ use crate::{barriers::AllowSubscriptionsFrom, test_utils::*}; pub use crate::{ - AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, - FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit, + AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom, + AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit, }; use frame_support::traits::ContainsPair; pub use frame_support::{ @@ -112,10 +112,24 @@ impl GetDispatchInfo for TestCall { thread_local! { pub static SENT_XCM: RefCell, XcmHash)>> = RefCell::new(Vec::new()); - pub static EXPORTED_XCM: RefCell, XcmHash)>> = RefCell::new(Vec::new()); + pub static EXPORTED_XCM: RefCell< + Vec<(NetworkId, u32, InteriorMultiLocation, InteriorMultiLocation, Xcm<()>, XcmHash)> + > = RefCell::new(Vec::new()); pub static EXPORTER_OVERRIDE: RefCell) -> Result, - fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result, + fn( + NetworkId, + u32, + &InteriorMultiLocation, + &InteriorMultiLocation, + &Xcm<()>, + ) -> Result, + fn( + NetworkId, + u32, + InteriorMultiLocation, + InteriorMultiLocation, + Xcm<()>, + ) -> Result, )>> = RefCell::new(None); pub static SEND_PRICE: RefCell = RefCell::new(MultiAssets::new()); } @@ -125,12 +139,25 @@ pub fn sent_xcm() -> Vec<(MultiLocation, opaque::Xcm, XcmHash)> { pub fn set_send_price(p: impl Into) { SEND_PRICE.with(|l| l.replace(p.into().into())); } -pub fn exported_xcm() -> Vec<(NetworkId, u32, InteriorMultiLocation, opaque::Xcm, XcmHash)> { +pub fn exported_xcm( +) -> Vec<(NetworkId, u32, InteriorMultiLocation, InteriorMultiLocation, opaque::Xcm, XcmHash)> { EXPORTED_XCM.with(|q| (*q.borrow()).clone()) } pub fn set_exporter_override( - price: fn(NetworkId, u32, &InteriorMultiLocation, &Xcm<()>) -> Result, - deliver: fn(NetworkId, u32, InteriorMultiLocation, Xcm<()>) -> Result, + price: fn( + NetworkId, + u32, + &InteriorMultiLocation, + &InteriorMultiLocation, + &Xcm<()>, + ) -> Result, + deliver: fn( + NetworkId, + u32, + InteriorMultiLocation, + InteriorMultiLocation, + Xcm<()>, + ) -> Result, ) { EXPORTER_OVERRIDE.with(|x| x.replace(Some((price, deliver)))); } @@ -158,25 +185,28 @@ impl SendXcm for TestMessageSender { } pub struct TestMessageExporter; impl ExportXcm for TestMessageExporter { - type Ticket = (NetworkId, u32, InteriorMultiLocation, Xcm<()>, XcmHash); + type Ticket = (NetworkId, u32, InteriorMultiLocation, InteriorMultiLocation, Xcm<()>, XcmHash); fn validate( network: NetworkId, channel: u32, + uni_src: &mut Option, dest: &mut Option, msg: &mut Option>, - ) -> SendResult<(NetworkId, u32, InteriorMultiLocation, Xcm<()>, XcmHash)> { - let (d, m) = (dest.take().unwrap(), msg.take().unwrap()); + ) -> SendResult<(NetworkId, u32, InteriorMultiLocation, InteriorMultiLocation, Xcm<()>, XcmHash)> + { + let (s, d, m) = (uni_src.take().unwrap(), dest.take().unwrap(), msg.take().unwrap()); let r: Result = EXPORTER_OVERRIDE.with(|e| { if let Some((ref f, _)) = &*e.borrow() { - f(network, channel, &d, &m) + f(network, channel, &s, &d, &m) } else { Ok(MultiAssets::new()) } }); let h = fake_message_hash(&m); match r { - Ok(price) => Ok(((network, channel, d, m, h), price)), + Ok(price) => Ok(((network, channel, s, d, m, h), price)), Err(e) => { + *uni_src = Some(s); *dest = Some(d); *msg = Some(m); Err(e) @@ -184,14 +214,14 @@ impl ExportXcm for TestMessageExporter { } } fn deliver( - tuple: (NetworkId, u32, InteriorMultiLocation, Xcm<()>, XcmHash), + tuple: (NetworkId, u32, InteriorMultiLocation, InteriorMultiLocation, Xcm<()>, XcmHash), ) -> Result { EXPORTER_OVERRIDE.with(|e| { if let Some((_, ref f)) = &*e.borrow() { - let (network, channel, dest, msg, _hash) = tuple; - f(network, channel, dest, msg) + let (network, channel, uni_src, dest, msg, _hash) = tuple; + f(network, channel, uni_src, dest, msg) } else { - let hash = tuple.4; + let hash = tuple.5; EXPORTED_XCM.with(|q| q.borrow_mut().push(tuple)); Ok(hash) } @@ -382,6 +412,7 @@ parameter_types! { } parameter_types! { // Nothing is allowed to be paid/unpaid by default. + pub static AllowExplicitUnpaidFrom: Vec = vec![]; pub static AllowUnpaidFrom: Vec = vec![]; pub static AllowPaidFrom: Vec = vec![]; pub static AllowSubsFrom: Vec = vec![]; @@ -394,6 +425,7 @@ pub type TestBarrier = ( TakeWeightCredit, AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom>, + AllowExplicitUnpaidExecutionFrom>, AllowUnpaidExecutionFrom>, AllowSubscriptionsFrom>, ); diff --git a/xcm/xcm-builder/src/tests/origins.rs b/xcm/xcm-builder/src/tests/origins.rs index 9b75c4f98650..6ae3397492fe 100644 --- a/xcm/xcm-builder/src/tests/origins.rs +++ b/xcm/xcm-builder/src/tests/origins.rs @@ -71,5 +71,35 @@ fn export_message_should_work() { let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); assert_eq!(r, Outcome::Complete(10)); - assert_eq!(exported_xcm(), vec![(Polkadot, 403611790, Here, expected_message, expected_hash)]); + let uni_src = (ByGenesis([0; 32]), Parachain(42), Parachain(1)).into(); + assert_eq!( + exported_xcm(), + vec![(Polkadot, 403611790, uni_src, Here, expected_message, expected_hash)] + ); +} + +#[test] +fn unpaid_execution_should_work() { + // Bridge chain (assumed to be Relay) lets Parachain #1 have message execution for free. + AllowUnpaidFrom::set(vec![X1(Parachain(1)).into()]); + // Bridge chain (assumed to be Relay) lets Parachain #2 have message execution for free if it + // asks. + AllowExplicitUnpaidFrom::set(vec![X1(Parachain(2)).into()]); + // Asking for unpaid execution of up to 9 weight on the assumption it is origin of #2. + let message = Xcm(vec![UnpaidExecution { + weight_limit: Limited(9), + check_origin: Some(Parachain(2).into()), + }]); + let hash = fake_message_hash(&message); + let r = XcmExecutor::::execute_xcm(Parachain(1), message.clone(), hash, 50); + assert_eq!(r, Outcome::Incomplete(10, XcmError::BadOrigin)); + let r = XcmExecutor::::execute_xcm(Parachain(2), message.clone(), hash, 50); + assert_eq!(r, Outcome::Error(XcmError::Barrier)); + + let message = Xcm(vec![UnpaidExecution { + weight_limit: Limited(10), + check_origin: Some(Parachain(2).into()), + }]); + let r = XcmExecutor::::execute_xcm(Parachain(2), message.clone(), hash, 50); + assert_eq!(r, Outcome::Complete(10)); } diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index 5db871135db8..f16b683a12c7 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -26,12 +26,12 @@ use SendError::*; fn ensure_is_remote( universal_local: impl Into, dest: impl Into, -) -> Result<(NetworkId, InteriorMultiLocation, NetworkId, InteriorMultiLocation), MultiLocation> { +) -> Result<(NetworkId, InteriorMultiLocation), MultiLocation> { let dest = dest.into(); let universal_local = universal_local.into(); - let (local_net, local_loc) = match universal_local.clone().split_first() { - (location, Some(GlobalConsensus(network))) => (network, location), - _ => return Err(dest), + let local_net = match universal_local.global_consensus() { + Ok(x) => x, + Err(_) => return Err(dest), }; let universal_destination: InteriorMultiLocation = universal_local .into_location() @@ -42,15 +42,12 @@ fn ensure_is_remote( (d, Some(GlobalConsensus(n))) if n != local_net => (d, n), _ => return Err(dest), }; - Ok((remote_net, remote_dest, local_net, local_loc)) + Ok((remote_net, remote_dest)) } /// Implementation of `SendXcm` which uses the given `ExportXcm` implementation in order to forward /// the message over a bridge. /// -/// The actual message forwarded over the bridge is prepended with `UniversalOrigin` and -/// `DescendOrigin` in order to ensure that the message is executed with this Origin. -/// /// No effort is made to charge for any bridge fees, so this can only be used when it is known /// that the message sending cannot be abused in any way. /// @@ -68,22 +65,17 @@ impl> SendXcm xcm: &mut Option>, ) -> SendResult { let d = dest.take().ok_or(MissingArgument)?; - let devolved = match ensure_is_remote(UniversalLocation::get(), d) { + let universal_source = UniversalLocation::get(); + let devolved = match ensure_is_remote(universal_source, d) { Ok(x) => x, Err(d) => { *dest = Some(d); return Err(NotApplicable) }, }; - let (network, destination, local_network, local_location) = devolved; - - let inner = xcm.take().ok_or(MissingArgument)?; - let mut message: Xcm<()> = vec![UniversalOrigin(GlobalConsensus(local_network))].into(); - if local_location != Here { - message.inner_mut().push(DescendOrigin(local_location)); - } - message.inner_mut().extend(inner.into_iter()); - validate_export::(network, 0, destination, message) + let (network, destination) = devolved; + let xcm = xcm.take().ok_or(SendError::MissingArgument)?; + validate_export::(network, 0, universal_source, destination, xcm) } fn deliver(ticket: Exporter::Ticket) -> Result { @@ -137,9 +129,6 @@ impl)>>> ExporterFor /// Implementation of `SendXcm` which wraps the message inside an `ExportMessage` instruction /// and sends it to a destination known to be able to handle it. /// -/// The actual message send to the bridge for forwarding is prepended with `UniversalOrigin` -/// and `DescendOrigin` in order to ensure that the message is executed with our Origin. -/// /// No effort is made to make payment to the bridge for its services, so the bridge location /// must have been configured with a barrier rule allowing unpaid execution for this message /// coming from our origin. @@ -160,31 +149,17 @@ impl SendResult { let d = dest.as_ref().ok_or(MissingArgument)?.clone(); let devolved = ensure_is_remote(UniversalLocation::get(), d).map_err(|_| NotApplicable)?; - let (remote_network, remote_location, local_network, local_location) = devolved; - - // Prepend the desired message with instructions which effectively rewrite the origin. - // - // This only works because the remote chain empowers the bridge - // to speak for the local network. - let mut exported: Xcm<()> = vec![UniversalOrigin(GlobalConsensus(local_network))].into(); - if local_location != Here { - exported.inner_mut().push(DescendOrigin(local_location)); - } - exported.inner_mut().extend(xcm.take().ok_or(MissingArgument)?.into_iter()); - + let (remote_network, remote_location) = devolved; + let xcm = xcm.take().ok_or(MissingArgument)?; let (bridge, maybe_payment) = - Bridges::exporter_for(&remote_network, &remote_location, &exported) - .ok_or(NotApplicable)?; + Bridges::exporter_for(&remote_network, &remote_location, &xcm).ok_or(NotApplicable)?; ensure!(maybe_payment.is_none(), Unroutable); // We then send a normal message to the bridge asking it to export the prepended // message to the remote chain. This will only work if the bridge will do the message // export for free. Common-good chains will typically be afforded this. - let message = Xcm(vec![ExportMessage { - network: remote_network, - destination: remote_location, - xcm: exported, - }]); + let message = + Xcm(vec![ExportMessage { network: remote_network, destination: remote_location, xcm }]); let (v, mut cost) = validate_send::(bridge, message)?; if let Some(payment) = maybe_payment { cost.push(payment); @@ -200,9 +175,6 @@ impl( @@ -219,26 +191,16 @@ impl SendResult { let d = dest.as_ref().ok_or(MissingArgument)?.clone(); let devolved = ensure_is_remote(UniversalLocation::get(), d).map_err(|_| NotApplicable)?; - let (remote_network, remote_location, local_network, local_location) = devolved; - - // Prepend the desired message with instructions which effectively rewrite the origin. - // - // This only works because the remote chain empowers the bridge - // to speak for the local network. - let mut exported: Xcm<()> = vec![UniversalOrigin(GlobalConsensus(local_network))].into(); - if local_location != Here { - exported.inner_mut().push(DescendOrigin(local_location)); - } - exported.inner_mut().extend(xcm.take().ok_or(MissingArgument)?.into_iter()); + let (remote_network, remote_location) = devolved; + let xcm = xcm.take().ok_or(MissingArgument)?; let (bridge, maybe_payment) = - Bridges::exporter_for(&remote_network, &remote_location, &exported) - .ok_or(NotApplicable)?; + Bridges::exporter_for(&remote_network, &remote_location, &xcm).ok_or(NotApplicable)?; let local_from_bridge = UniversalLocation::get().invert_target(&bridge).map_err(|_| Unroutable)?; let export_instruction = - ExportMessage { network: remote_network, destination: remote_location, xcm: exported }; + ExportMessage { network: remote_network, destination: remote_location, xcm }; let message = Xcm(if let Some(ref payment) = maybe_payment { let fees = payment @@ -338,6 +300,7 @@ impl, Price: Get> fn validate( network: NetworkId, _channel: u32, + universal_source: &mut Option, destination: &mut Option, message: &mut Option>, ) -> Result<((Vec, XcmHash), MultiAssets), SendError> { @@ -352,7 +315,19 @@ impl, Price: Get> return Err(SendError::NotApplicable) }, }; - let message = VersionedXcm::from(message.take().ok_or(SendError::MissingArgument)?); + let (local_net, local_sub) = universal_source + .take() + .ok_or(SendError::MissingArgument)? + .split_global() + .map_err(|()| SendError::Unroutable)?; + let mut inner: Xcm<()> = vec![UniversalOrigin(GlobalConsensus(local_net))].into(); + if local_sub != Here { + inner.inner_mut().push(DescendOrigin(local_sub)); + } + inner + .inner_mut() + .extend(message.take().ok_or(SendError::MissingArgument)?.into_iter()); + let message = VersionedXcm::from(inner); let hash = message.using_encoded(sp_io::hashing::blake2_256); let blob = BridgeMessage { universal_dest, message }.encode(); Ok(((blob, hash), Price::get())) @@ -372,11 +347,11 @@ mod tests { fn ensure_is_remote_works() { // A Kusama parachain is remote from the Polkadot Relay. let x = ensure_is_remote(Polkadot, (Parent, Kusama, Parachain(1000))); - assert_eq!(x, Ok((Kusama, Parachain(1000).into(), Polkadot, Here))); + assert_eq!(x, Ok((Kusama, Parachain(1000).into()))); // Polkadot Relay is remote from a Kusama parachain. let x = ensure_is_remote((Kusama, Parachain(1000)), (Parent, Parent, Polkadot)); - assert_eq!(x, Ok((Polkadot, Here, Kusama, Parachain(1000).into()))); + assert_eq!(x, Ok((Polkadot, Here))); // Our own parachain is local. let x = ensure_is_remote(Polkadot, Parachain(1000)); diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 01fd18fc0b92..410aa19d6315 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -32,8 +32,8 @@ use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, - IsChildSystemParachain, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, + IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, }; pub type AccountId = AccountId32; @@ -128,7 +128,7 @@ parameter_types! { pub const KsmLocation: MultiLocation = MultiLocation::here(); pub const KusamaNetwork: NetworkId = NetworkId::Kusama; pub UniversalLocation: InteriorMultiLocation = Here; - pub CheckAccount: AccountId = XcmPallet::check_account(); + pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); } pub type SovereignAccountOf = diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 1a24b9e71e86..df7d9061d5b9 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -332,8 +332,9 @@ impl XcmExecutor { "Trapping assets in holding register: {:?}, context: {:?} (original_origin: {:?})", self.holding, self.context, self.original_origin, ); + let effective_origin = self.context.origin.as_ref().unwrap_or(&self.original_origin); let trap_weight = - Config::AssetTrap::drop_assets(&self.original_origin, self.holding, &self.context); + Config::AssetTrap::drop_assets(effective_origin, self.holding, &self.context); weight_used.saturating_accrue(trap_weight); }; @@ -477,9 +478,7 @@ impl XcmExecutor { Config::AssetTransactor::transfer_asset(asset, origin, &dest, &self.context)?; } let reanchor_context = Config::UniversalLocation::get(); - assets - .reanchor(&dest, reanchor_context) - .map_err(|()| XcmError::MultiLocationFull)?; + assets.reanchor(&dest, reanchor_context).map_err(|()| XcmError::LocationFull)?; let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; message.extend(xcm.0.into_iter()); self.send(dest, Xcm(message), FeeReason::TransferReserveAsset)?; @@ -558,7 +557,7 @@ impl XcmExecutor { .as_mut() .ok_or(XcmError::BadOrigin)? .append_with(who) - .map_err(|_| XcmError::MultiLocationFull), + .map_err(|_| XcmError::LocationFull), ClearOrigin => { self.context.origin = None; Ok(()) @@ -610,6 +609,13 @@ impl XcmExecutor { InitiateTeleport { assets, dest, xcm } => { // We must do this first in order to resolve wildcards. let assets = self.holding.saturating_take(assets); + for asset in assets.assets_iter() { + // We should check that the asset can actually be teleported out (for this to + // be in error, there would need to be an accounting violation by ourselves, + // so it's unlikely, but we don't want to allow that kind of bug to leak into + // a trusted chain. + Config::AssetTransactor::can_check_out(&dest, &asset, &self.context)?; + } for asset in assets.assets_iter() { Config::AssetTransactor::check_out(&dest, &asset, &self.context); } @@ -772,13 +778,29 @@ impl XcmExecutor { Ok(()) }, ExportMessage { network, destination, xcm } => { + // The actual message send to the bridge for forwarding is prepended with `UniversalOrigin` + // and `DescendOrigin` in order to ensure that the message is executed with this Origin. + // + // Prepend the desired message with instructions which effectively rewrite the origin. + // + // This only works because the remote chain empowers the bridge + // to speak for the local network. + let origin = self.context.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let universal_source = Config::UniversalLocation::get() + .within_global(origin) + .map_err(|()| XcmError::Unanchored)?; let hash = (self.origin_ref(), &destination).using_encoded(blake2_128); let channel = u32::decode(&mut hash.as_ref()).unwrap_or(0); // Hash identifies the lane on the exporter which we use. We use the pairwise // combination of the origin and destination to ensure origin/destination pairs will // generally have their own lanes. - let (ticket, fee) = - validate_export::(network, channel, destination, xcm)?; + let (ticket, fee) = validate_export::( + network, + channel, + universal_source, + destination, + xcm, + )?; self.take_fee(fee, FeeReason::Export(network))?; Config::MessageExporter::deliver(ticket)?; Ok(()) @@ -851,6 +873,13 @@ impl XcmExecutor { Ok(()) }, AliasOrigin(_) => Err(XcmError::NoPermission), + UnpaidExecution { check_origin, .. } => { + ensure!( + check_origin.is_none() || self.context.origin == check_origin, + XcmError::BadOrigin + ); + Ok(()) + }, HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented), HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), HrmpChannelClosing { .. } => Err(XcmError::Unimplemented), diff --git a/xcm/xcm-executor/src/traits/export.rs b/xcm/xcm-executor/src/traits/export.rs index 4b4169ddc16d..6a846fb0b75a 100644 --- a/xcm/xcm-executor/src/traits/export.rs +++ b/xcm/xcm-executor/src/traits/export.rs @@ -19,9 +19,9 @@ use xcm::latest::prelude::*; pub trait ExportXcm { type Ticket; - /// Check whether the given `_message` is deliverable to the given `_destination` and if so - /// determine the cost which will be paid by this chain to do so, returning a `Validated` token - /// which can be used to enact delivery. + /// Check whether the given `message` is deliverable to the given `destination` spoofing + /// its source as `universal_source` and if so determine the cost which will be paid by this + /// chain to do so, returning a `Validated` token which can be used to enact delivery. /// /// The `destination` and `message` must be `Some` (or else an error will be returned) and they /// may only be consumed if the `Err` is not `NotApplicable`. @@ -32,6 +32,7 @@ pub trait ExportXcm { fn validate( network: NetworkId, channel: u32, + universal_source: &mut Option, destination: &mut Option, message: &mut Option>, ) -> SendResult; @@ -51,6 +52,7 @@ impl ExportXcm for Tuple { fn validate( network: NetworkId, channel: u32, + universal_source: &mut Option, destination: &mut Option, message: &mut Option>, ) -> SendResult { @@ -59,7 +61,7 @@ impl ExportXcm for Tuple { if maybe_cost.is_some() { None } else { - match Tuple::validate(network, channel, destination, message) { + match Tuple::validate(network, channel, universal_source, destination, message) { Err(SendError::NotApplicable) => None, Err(e) => { return Err(e) }, Ok((v, c)) => { @@ -91,10 +93,11 @@ impl ExportXcm for Tuple { pub fn validate_export( network: NetworkId, channel: u32, + universal_source: InteriorMultiLocation, dest: InteriorMultiLocation, msg: Xcm<()>, ) -> SendResult { - T::validate(network, channel, &mut Some(dest), &mut Some(msg)) + T::validate(network, channel, &mut Some(universal_source), &mut Some(dest), &mut Some(msg)) } /// Convenience function for using a `SendXcm` implementation. Just interprets the `dest` and wraps @@ -108,10 +111,17 @@ pub fn validate_export( pub fn export_xcm( network: NetworkId, channel: u32, + universal_source: InteriorMultiLocation, dest: InteriorMultiLocation, msg: Xcm<()>, ) -> Result<(XcmHash, MultiAssets), SendError> { - let (ticket, price) = T::validate(network, channel, &mut Some(dest), &mut Some(msg.clone()))?; + let (ticket, price) = T::validate( + network, + channel, + &mut Some(universal_source), + &mut Some(dest), + &mut Some(msg.clone()), + )?; let hash = T::deliver(ticket)?; Ok((hash, price)) } diff --git a/xcm/xcm-executor/src/traits/transact_asset.rs b/xcm/xcm-executor/src/traits/transact_asset.rs index 13cc9b6a4a41..9f4b9b5ad392 100644 --- a/xcm/xcm-executor/src/traits/transact_asset.rs +++ b/xcm/xcm-executor/src/traits/transact_asset.rs @@ -26,7 +26,7 @@ use xcm::latest::{Error as XcmError, MultiAsset, MultiLocation, Result as XcmRes /// Can be amalgamated as a tuple of items that implement this trait. In such executions, if any of the transactors /// returns `Ok(())`, then it will short circuit. Else, execution is passed to the next transactor. pub trait TransactAsset { - /// Ensure that `check_in` will result in `Ok`. + /// Ensure that `check_in` will do as expected. /// /// When composed as a tuple, all type-items are called and at least one must result in `Ok`. fn can_check_in( @@ -52,6 +52,17 @@ pub trait TransactAsset { /// value for `_what` which can cause side-effects for more than one of the type-items. fn check_in(_origin: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {} + /// Ensure that `check_out` will do as expected. + /// + /// When composed as a tuple, all type-items are called and at least one must result in `Ok`. + fn can_check_out( + _dest: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { + Err(XcmError::Unimplemented) + } + /// An asset has been teleported out to the given destination. This should do whatever housekeeping is needed. /// /// Implementation note: In general this will do one of two things: On chains where the asset is native, @@ -152,6 +163,23 @@ impl TransactAsset for Tuple { )* ); } + fn can_check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) -> XcmResult { + for_tuples!( #( + match Tuple::can_check_out(dest, what, context) { + Err(XcmError::AssetNotFound) | Err(XcmError::Unimplemented) => (), + r => return r, + } + )* ); + log::trace!( + target: "xcm::TransactAsset::can_check_out", + "asset not found: what: {:?}, dest: {:?}, context: {:?}", + what, + dest, + context, + ); + Err(XcmError::AssetNotFound) + } + fn check_out(dest: &MultiLocation, what: &MultiAsset, context: &XcmContext) { for_tuples!( #( Tuple::check_out(dest, what, context); @@ -238,6 +266,14 @@ mod tests { Err(XcmError::AssetNotFound) } + fn can_check_out( + _dest: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { + Err(XcmError::AssetNotFound) + } + fn deposit_asset( _what: &MultiAsset, _who: &MultiLocation, @@ -274,6 +310,14 @@ mod tests { Err(XcmError::Overflow) } + fn can_check_out( + _dest: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { + Err(XcmError::Overflow) + } + fn deposit_asset( _what: &MultiAsset, _who: &MultiLocation, @@ -310,6 +354,14 @@ mod tests { Ok(()) } + fn can_check_out( + _dest: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { + Ok(()) + } + fn deposit_asset( _what: &MultiAsset, _who: &MultiLocation, diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index abe9e0612689..6101b78bd9df 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -39,8 +39,9 @@ use xcm::{latest::prelude::*, VersionedXcm}; use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, - IsConcrete, NativeAsset, NonFungiblesAdapter, ParentIsPreset, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + IsConcrete, NativeAsset, NoChecking, NonFungiblesAdapter, ParentIsPreset, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, }; use xcm_executor::{ traits::{Convert, JustTry}, @@ -200,7 +201,7 @@ pub type LocalAssetTransactor = ( ConvertedConcreteId, SovereignAccountOf, AccountId, - Nothing, + NoChecking, (), >, ); diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index a13cdabb3ea4..f743b84ab280 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -30,7 +30,7 @@ use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, - FixedWeightBounds, IsConcrete, NonFungiblesAdapter, SignedAccountId32AsNative, + FixedWeightBounds, IsConcrete, NoChecking, NonFungiblesAdapter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -135,7 +135,7 @@ pub type LocalAssetTransactor = ( ConvertedConcreteId, JustTry>, LocationToAccountId, AccountId, - Nothing, + NoChecking, (), >, ); From 37e49df34a1ac71ababe304d0eb073ed1a831f0f Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 12 Oct 2022 01:03:32 +0800 Subject: [PATCH 127/231] Update Substrate --- Cargo.lock | 362 ++++++++++++++++++++++++++--------------------------- 1 file changed, 181 insertions(+), 181 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 947aa9c44ad4..a3f145d93de0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "async-trait", @@ -473,7 +473,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -493,7 +493,7 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "beefy-primitives", "sp-api", @@ -503,7 +503,7 @@ dependencies = [ [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "scale-info", @@ -1990,7 +1990,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", ] @@ -2007,7 +2007,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -2030,7 +2030,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "Inflector", "array-bytes", @@ -2081,7 +2081,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2092,7 +2092,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2108,7 +2108,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -2137,7 +2137,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "bitflags", "frame-metadata", @@ -2169,7 +2169,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "Inflector", "cfg-expr", @@ -2183,7 +2183,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2195,7 +2195,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "proc-macro2", "quote", @@ -2205,7 +2205,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2228,7 +2228,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -2239,7 +2239,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "log", @@ -2257,7 +2257,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -2272,7 +2272,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "sp-api", @@ -2281,7 +2281,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "parity-scale-codec", @@ -2452,7 +2452,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "chrono", "frame-election-provider-support", @@ -4767,7 +4767,7 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -4781,7 +4781,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -4797,7 +4797,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -4812,7 +4812,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -4836,7 +4836,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4856,7 +4856,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-election-provider-support", "frame-support", @@ -4875,7 +4875,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -4890,7 +4890,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "beefy-primitives", "frame-support", @@ -4906,7 +4906,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "beefy-merkle-tree", @@ -4929,7 +4929,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -4947,7 +4947,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -4966,7 +4966,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -4983,7 +4983,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5000,7 +5000,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5018,7 +5018,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5042,7 +5042,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5055,7 +5055,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5073,7 +5073,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5094,7 +5094,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5109,7 +5109,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5132,7 +5132,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5148,7 +5148,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5168,7 +5168,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5185,7 +5185,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5202,7 +5202,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5220,7 +5220,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -5235,7 +5235,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5251,7 +5251,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -5268,7 +5268,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5288,7 +5288,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "sp-api", @@ -5298,7 +5298,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -5315,7 +5315,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5338,7 +5338,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5355,7 +5355,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5370,7 +5370,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5388,7 +5388,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5403,7 +5403,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5421,7 +5421,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5437,7 +5437,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -5458,7 +5458,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5474,7 +5474,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -5488,7 +5488,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5511,7 +5511,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5522,7 +5522,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "log", "sp-arithmetic", @@ -5531,7 +5531,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -5545,7 +5545,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5563,7 +5563,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5582,7 +5582,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-support", "frame-system", @@ -5598,7 +5598,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -5613,7 +5613,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5624,7 +5624,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5641,7 +5641,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#1f720c11b90d45bba0c4ddad60d3b9a27ca85441" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5656,7 +5656,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5672,7 +5672,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -5687,7 +5687,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-benchmarking", "frame-support", @@ -8218,7 +8218,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "env_logger", "jsonrpsee", @@ -8566,7 +8566,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "log", "sp-core", @@ -8577,7 +8577,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "futures", @@ -8604,7 +8604,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "futures-timer", @@ -8627,7 +8627,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8643,7 +8643,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "impl-trait-for-tuples", "memmap2", @@ -8660,7 +8660,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8671,7 +8671,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "chrono", @@ -8711,7 +8711,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "fnv", "futures", @@ -8739,7 +8739,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "hash-db", "kvdb", @@ -8764,7 +8764,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "futures", @@ -8788,7 +8788,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "fork-tree", @@ -8830,7 +8830,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "jsonrpsee", @@ -8852,7 +8852,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8865,7 +8865,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "futures", @@ -8889,7 +8889,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "lazy_static", "lru 0.7.8", @@ -8916,7 +8916,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "environmental", "parity-scale-codec", @@ -8932,7 +8932,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "log", "parity-scale-codec", @@ -8947,7 +8947,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "cfg-if 1.0.0", "libc", @@ -8967,7 +8967,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "ahash", "array-bytes", @@ -9008,7 +9008,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "finality-grandpa", "futures", @@ -9029,7 +9029,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "ansi_term", "futures", @@ -9046,7 +9046,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "async-trait", @@ -9061,7 +9061,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "async-trait", @@ -9108,7 +9108,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "cid", "futures", @@ -9128,7 +9128,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "bitflags", @@ -9154,7 +9154,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "ahash", "futures", @@ -9172,7 +9172,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "futures", @@ -9193,7 +9193,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "fork-tree", @@ -9221,7 +9221,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "futures", @@ -9240,7 +9240,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "bytes", @@ -9270,7 +9270,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "libp2p", @@ -9283,7 +9283,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9292,7 +9292,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "hash-db", @@ -9322,7 +9322,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "jsonrpsee", @@ -9345,7 +9345,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "jsonrpsee", @@ -9358,7 +9358,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "hex", @@ -9377,7 +9377,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "directories", @@ -9448,7 +9448,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "log", "parity-scale-codec", @@ -9462,7 +9462,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9481,7 +9481,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "libc", @@ -9500,7 +9500,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "chrono", "futures", @@ -9518,7 +9518,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "ansi_term", "atty", @@ -9549,7 +9549,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9560,7 +9560,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "futures-timer", @@ -9586,7 +9586,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "log", @@ -9599,7 +9599,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "futures-timer", @@ -10087,7 +10087,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "hash-db", "log", @@ -10105,7 +10105,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "blake2", "proc-macro-crate", @@ -10117,7 +10117,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "scale-info", @@ -10130,7 +10130,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "integer-sqrt", "num-traits", @@ -10145,7 +10145,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "scale-info", @@ -10158,7 +10158,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "parity-scale-codec", @@ -10170,7 +10170,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "sp-api", @@ -10182,7 +10182,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "log", @@ -10200,7 +10200,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "futures", @@ -10219,7 +10219,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "merlin", @@ -10242,7 +10242,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "scale-info", @@ -10256,7 +10256,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "scale-info", @@ -10269,7 +10269,7 @@ dependencies = [ [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "base58", @@ -10315,7 +10315,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "blake2", "byteorder", @@ -10329,7 +10329,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "proc-macro2", "quote", @@ -10340,7 +10340,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10349,7 +10349,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "proc-macro2", "quote", @@ -10359,7 +10359,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "environmental", "parity-scale-codec", @@ -10370,7 +10370,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "finality-grandpa", "log", @@ -10388,7 +10388,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10402,7 +10402,7 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "bytes", "futures", @@ -10428,7 +10428,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "lazy_static", "sp-core", @@ -10439,7 +10439,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "futures", @@ -10456,7 +10456,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "thiserror", "zstd", @@ -10465,7 +10465,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "log", "parity-scale-codec", @@ -10481,7 +10481,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "scale-info", @@ -10495,7 +10495,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "sp-api", "sp-core", @@ -10505,7 +10505,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "backtrace", "lazy_static", @@ -10515,7 +10515,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "rustc-hash", "serde", @@ -10525,7 +10525,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "either", "hash256-std-hasher", @@ -10548,7 +10548,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10566,7 +10566,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "Inflector", "proc-macro-crate", @@ -10578,7 +10578,7 @@ dependencies = [ [[package]] name = "sp-sandbox" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "log", "parity-scale-codec", @@ -10592,7 +10592,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "scale-info", @@ -10606,7 +10606,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "scale-info", @@ -10617,7 +10617,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "hash-db", "log", @@ -10639,12 +10639,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10657,7 +10657,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "log", "sp-core", @@ -10670,7 +10670,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "futures-timer", @@ -10686,7 +10686,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "sp-std", @@ -10698,7 +10698,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "sp-api", "sp-runtime", @@ -10707,7 +10707,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "async-trait", "log", @@ -10723,7 +10723,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "ahash", "hash-db", @@ -10746,7 +10746,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10763,7 +10763,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10774,7 +10774,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "impl-trait-for-tuples", "log", @@ -10787,7 +10787,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -11002,7 +11002,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "platforms", ] @@ -11010,7 +11010,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -11031,7 +11031,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures-util", "hyper", @@ -11044,7 +11044,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "jsonrpsee", "log", @@ -11065,7 +11065,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "array-bytes", "async-trait", @@ -11091,7 +11091,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "futures", "substrate-test-utils-derive", @@ -11101,7 +11101,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11112,7 +11112,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "ansi_term", "build-helper", @@ -11813,7 +11813,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#488fc24d98cfe643402b86990ae0aff27ba927b3" +source = "git+https://github.com/paritytech/substrate?branch=master#1bf2e6db6ccc0f9d872cddf9e3254227d100f2bf" dependencies = [ "clap", "frame-try-runtime", @@ -11883,7 +11883,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "digest 0.10.5", "rand 0.8.5", "static_assertions", From fa54983dece5b8a358fefb1ec163e56d633ab6a9 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 14 Oct 2022 00:38:34 +0200 Subject: [PATCH 128/231] Re-export `pub` stuff from universal_exports.rs + removed unecessary clone (#6145) * Re-export `pub` stuff from universal_exports.rs * Removed unnecessary clone --- xcm/src/v3/traits.rs | 2 +- xcm/xcm-builder/src/lib.rs | 3 ++- xcm/xcm-executor/src/traits/export.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 028d8365c1e3..5d657b3e65d5 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -531,7 +531,7 @@ pub fn send_xcm( dest: MultiLocation, msg: Xcm<()>, ) -> result::Result<(XcmHash, MultiAssets), SendError> { - let (ticket, price) = T::validate(&mut Some(dest), &mut Some(msg.clone()))?; + let (ticket, price) = T::validate(&mut Some(dest), &mut Some(msg))?; let hash = T::deliver(ticket)?; Ok((hash, price)) } diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index f48480616ac5..1cb7fba9f5cc 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -79,6 +79,7 @@ pub use filter_asset_location::{Case, NativeAsset}; mod universal_exports; pub use universal_exports::{ - ExporterFor, LocalUnpaidExporter, NetworkExportTable, SovereignPaidRemoteExporter, + BridgeBlobDispatcher, BridgeMessage, DispatchBlob, DispatchBlobError, ExporterFor, HaulBlob, + HaulBlobExporter, LocalUnpaidExporter, NetworkExportTable, SovereignPaidRemoteExporter, UnpaidRemoteExporter, }; diff --git a/xcm/xcm-executor/src/traits/export.rs b/xcm/xcm-executor/src/traits/export.rs index 6a846fb0b75a..498cea4bce56 100644 --- a/xcm/xcm-executor/src/traits/export.rs +++ b/xcm/xcm-executor/src/traits/export.rs @@ -120,7 +120,7 @@ pub fn export_xcm( channel, &mut Some(universal_source), &mut Some(dest), - &mut Some(msg.clone()), + &mut Some(msg), )?; let hash = T::deliver(ticket)?; Ok((hash, price)) From 41fb1f1503902bccfdc564f1a61c2e10c86627a5 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 10 Nov 2022 17:21:48 +0800 Subject: [PATCH 129/231] Use 2D weights in XCM v3 (#6134) * Depend upon sp-core instead of sp-runtime * Make sp-io a dev-dependency * Use 2D weights in XCM v3 * cargo fmt * Add XCM pallet migration to runtimes * Use from_parts * cargo fmt * Fixes * cargo fmt * Remove XCMWeight import * Fixes * Fixes * Fixes * Fixes * Use translate in migration * Increase max upward message size in tests * Fix doc test * Remove most uses of from_ref_time * cargo fmt * Fixes * Fixes * Add extrinsic benchmarking to XCM pallet * cargo fmt * Fixes * Use old syntax * cargo fmt * Fixes * Remove hardcoded weights * Add XCM pallet to benchmarks * Use successful origin * Fix weird type parameter compilation issue * Fixes * ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime rococo-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm * Use benchmarked XCM pallet weights * Fixes * Fixes * Use override instead of skip * Fixes * Fixes * Fixes * Fixes * ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm * Fixes * ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_xcm Co-authored-by: command-bot <> --- Cargo.lock | 5 +- node/service/src/chain_spec.rs | 3 +- runtime/common/src/impls.rs | 2 +- runtime/common/src/integration_tests.rs | 2 +- runtime/common/src/paras_registrar.rs | 4 +- runtime/kusama/src/lib.rs | 3 + runtime/kusama/src/weights/mod.rs | 1 + runtime/kusama/src/weights/pallet_xcm.rs | 111 ++++++++++ runtime/kusama/src/weights/xcm/mod.rs | 198 ++++++++---------- runtime/kusama/src/xcm_config.rs | 4 +- .../parachains/src/configuration/migration.rs | 4 +- runtime/parachains/src/configuration/tests.rs | 4 +- runtime/parachains/src/mock.rs | 4 +- runtime/parachains/src/paras/mod.rs | 2 +- runtime/parachains/src/ump.rs | 8 +- runtime/parachains/src/ump/benchmarking.rs | 9 +- runtime/parachains/src/ump/tests.rs | 30 +-- runtime/polkadot/src/lib.rs | 4 + runtime/polkadot/src/weights/mod.rs | 1 + runtime/polkadot/src/weights/pallet_xcm.rs | 115 ++++++++++ runtime/polkadot/src/xcm_config.rs | 4 +- runtime/rococo/src/lib.rs | 3 + runtime/rococo/src/weights/mod.rs | 1 + runtime/rococo/src/weights/pallet_xcm.rs | 114 ++++++++++ runtime/rococo/src/weights/xcm/mod.rs | 198 ++++++++---------- runtime/rococo/src/xcm_config.rs | 4 +- runtime/test-runtime/src/lib.rs | 3 +- runtime/test-runtime/src/xcm_config.rs | 5 +- runtime/westend/src/lib.rs | 3 + runtime/westend/src/weights/mod.rs | 1 + runtime/westend/src/weights/pallet_xcm.rs | 112 ++++++++++ runtime/westend/src/weights/xcm/mod.rs | 195 ++++++++--------- runtime/westend/src/xcm_config.rs | 1 + xcm/Cargo.toml | 14 +- xcm/pallet-xcm-benchmarks/Cargo.toml | 1 - .../src/fungible/mock.rs | 4 +- .../src/generic/benchmarking.rs | 16 +- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 4 +- xcm/pallet-xcm-benchmarks/src/mock.rs | 10 +- xcm/pallet-xcm/Cargo.toml | 5 +- xcm/pallet-xcm/src/benchmarking.rs | 82 ++++++++ xcm/pallet-xcm/src/lib.rs | 165 ++++++++++----- xcm/pallet-xcm/src/migration.rs | 61 ++++++ xcm/pallet-xcm/src/mock.rs | 17 +- xcm/pallet-xcm/src/tests.rs | 170 ++++++++------- xcm/src/v2/junction.rs | 2 +- xcm/src/v2/mod.rs | 127 +++++++---- xcm/src/v3/mod.rs | 86 ++++++-- xcm/src/v3/traits.rs | 15 +- xcm/xcm-builder/src/barriers.rs | 11 +- xcm/xcm-builder/src/test_utils.rs | 6 +- xcm/xcm-builder/src/tests/assets.rs | 156 ++++++++++---- xcm/xcm-builder/src/tests/barriers.rs | 87 +++++--- xcm/xcm-builder/src/tests/basic.rs | 16 +- xcm/xcm-builder/src/tests/bridging/mod.rs | 16 +- xcm/xcm-builder/src/tests/expecting.rs | 90 ++++++-- xcm/xcm-builder/src/tests/locking.rs | 62 ++++-- xcm/xcm-builder/src/tests/mock.rs | 12 +- xcm/xcm-builder/src/tests/origins.rs | 65 ++++-- xcm/xcm-builder/src/tests/querying.rs | 32 ++- xcm/xcm-builder/src/tests/transacting.rs | 74 +++---- .../src/tests/version_subscriptions.rs | 46 ++-- xcm/xcm-builder/src/tests/weight.rs | 34 +-- xcm/xcm-builder/src/weight.rs | 53 +++-- xcm/xcm-builder/tests/mock/mod.rs | 4 +- xcm/xcm-builder/tests/scenarios.rs | 11 +- xcm/xcm-executor/Cargo.toml | 2 + xcm/xcm-executor/integration-tests/src/lib.rs | 11 +- xcm/xcm-executor/src/lib.rs | 64 +++--- xcm/xcm-executor/src/traits/drop_assets.rs | 1 - xcm/xcm-executor/src/traits/on_response.rs | 5 +- xcm/xcm-simulator/example/Cargo.toml | 1 - xcm/xcm-simulator/example/src/lib.rs | 14 +- xcm/xcm-simulator/example/src/parachain.rs | 23 +- xcm/xcm-simulator/example/src/relay_chain.rs | 4 +- xcm/xcm-simulator/fuzzer/src/parachain.rs | 19 +- xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 5 +- xcm/xcm-simulator/src/lib.rs | 2 +- 78 files changed, 1933 insertions(+), 930 deletions(-) create mode 100644 runtime/kusama/src/weights/pallet_xcm.rs create mode 100644 runtime/polkadot/src/weights/pallet_xcm.rs create mode 100644 runtime/rococo/src/weights/pallet_xcm.rs create mode 100644 runtime/westend/src/weights/pallet_xcm.rs create mode 100644 xcm/pallet-xcm/src/benchmarking.rs create mode 100644 xcm/pallet-xcm/src/migration.rs diff --git a/Cargo.lock b/Cargo.lock index 364a55122f94..c0332db706f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5586,6 +5586,7 @@ dependencies = [ name = "pallet-xcm" version = "0.9.31" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "log", @@ -12592,8 +12593,9 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", + "sp-core", "sp-io", - "sp-runtime", + "sp-weights", "xcm-procedural", ] @@ -12636,6 +12638,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-weights", "xcm", ] diff --git a/node/service/src/chain_spec.rs b/node/service/src/chain_spec.rs index e2c0a7bfdf94..4537a43c192c 100644 --- a/node/service/src/chain_spec.rs +++ b/node/service/src/chain_spec.rs @@ -190,8 +190,7 @@ fn default_parachains_host_configuration( max_upward_queue_count: 8, max_upward_queue_size: 1024 * 1024, max_downward_message_size: 1024 * 1024, - ump_service_total_weight: Weight::from_ref_time(100_000_000_000) - .set_proof_size(MAX_POV_SIZE as u64), + ump_service_total_weight: Weight::from_parts(100_000_000_000, MAX_POV_SIZE as u64), max_upward_message_size: 50 * 1024, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 0, diff --git a/runtime/common/src/impls.rs b/runtime/common/src/impls.rs index 939b753092f5..51911f893e5e 100644 --- a/runtime/common/src/impls.rs +++ b/runtime/common/src/impls.rs @@ -97,7 +97,7 @@ mod tests { weight.base_extrinsic = Weight::from_ref_time(100); }) .for_class(DispatchClass::non_mandatory(), |weight| { - weight.max_total = Some(Weight::from_ref_time(1024).set_proof_size(u64::MAX)); + weight.max_total = Some(Weight::from_parts(1024, u64::MAX)); }) .build_or_panic(); pub BlockLength: limits::BlockLength = limits::BlockLength::max(2 * 1024); diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index eb9c4496e59a..2a97eec7209f 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -105,7 +105,7 @@ parameter_types! { pub const BlockHashCount: u32 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max( - Weight::from_ref_time(4 * 1024 * 1024).set_proof_size(u64::MAX), + Weight::from_parts(4 * 1024 * 1024, u64::MAX), ); } diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index bfcc91e3ba71..5dab30cedf85 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -696,9 +696,7 @@ mod tests { parameter_types! { pub const BlockHashCount: u32 = 250; pub BlockWeights: limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max( - Weight::from_ref_time(1024).set_proof_size(u64::MAX), - ); + frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX)); pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio(4 * 1024 * 1024, NORMAL_RATIO); } diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 3fd7bc7efd25..eb76f3380e43 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1479,6 +1479,8 @@ pub type Executive = frame_executive::Executive< // "Properly migrate weights to v2" parachains_configuration::migration::v3::MigrateToV3, pallet_election_provider_multi_phase::migrations::v1::MigrateToV1, + // "Use 2D weights in XCM v3" + pallet_xcm::migration::v1::MigrateToV1, ), >; /// The payload being signed in the transactions. @@ -1545,6 +1547,7 @@ mod benches { [pallet_vesting, Vesting] [pallet_whitelist, Whitelist] // XCM + [pallet_xcm, XcmPallet] [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::] [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::] ); diff --git a/runtime/kusama/src/weights/mod.rs b/runtime/kusama/src/weights/mod.rs index 2f9e2d35c211..3f5fa96f6196 100644 --- a/runtime/kusama/src/weights/mod.rs +++ b/runtime/kusama/src/weights/mod.rs @@ -49,6 +49,7 @@ pub mod pallet_treasury; pub mod pallet_utility; pub mod pallet_vesting; pub mod pallet_whitelist; +pub mod pallet_xcm; pub mod runtime_common_auctions; pub mod runtime_common_claims; pub mod runtime_common_crowdloan; diff --git a/runtime/kusama/src/weights/pallet_xcm.rs b/runtime/kusama/src/weights/pallet_xcm.rs new file mode 100644 index 000000000000..a14b50ec9212 --- /dev/null +++ b/runtime/kusama/src/weights/pallet_xcm.rs @@ -0,0 +1,111 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=kusama-dev +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl pallet_xcm::WeightInfo for WeightInfo { + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + fn send() -> Weight { + // Minimum execution time: 32_807 nanoseconds. + Weight::from_ref_time(33_383_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + fn teleport_assets() -> Weight { + // Minimum execution time: 28_036 nanoseconds. + Weight::from_ref_time(28_386_000 as u64) + } + fn reserve_transfer_assets() -> Weight { + // Minimum execution time: 26_239 nanoseconds. + Weight::from_ref_time(27_146_000 as u64) + } + fn execute() -> Weight { + // Minimum execution time: 14_327 nanoseconds. + Weight::from_ref_time(14_693_000 as u64) + } + // Storage: XcmPallet SupportedVersion (r:0 w:1) + fn force_xcm_version() -> Weight { + // Minimum execution time: 13_854 nanoseconds. + Weight::from_ref_time(14_658_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet SafeXcmVersion (r:0 w:1) + fn force_default_xcm_version() -> Weight { + // Minimum execution time: 3_786 nanoseconds. + Weight::from_ref_time(3_986_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet VersionNotifiers (r:1 w:1) + // Storage: XcmPallet QueryCounter (r:1 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: XcmPallet Queries (r:0 w:1) + fn force_subscribe_version_notify() -> Weight { + // Minimum execution time: 37_959 nanoseconds. + Weight::from_ref_time(38_689_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: XcmPallet VersionNotifiers (r:1 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: XcmPallet Queries (r:0 w:1) + fn force_unsubscribe_version_notify() -> Weight { + // Minimum execution time: 41_213 nanoseconds. + Weight::from_ref_time(41_668_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } +} diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index 64c19a79edfd..ffda76ce83de 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -4,10 +4,7 @@ mod pallet_xcm_benchmarks_generic; use crate::Runtime; use frame_support::weights::Weight; use sp_std::prelude::*; -use xcm::{ - latest::{prelude::*, Weight as XCMWeight}, - DoubleEncoded, -}; +use xcm::{latest::prelude::*, DoubleEncoded}; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; @@ -31,15 +28,15 @@ impl From<&MultiAsset> for AssetTypes { } trait WeighMultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight; + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight; } // Kusama only knows about one asset, the balances pallet. const MAX_ASSETS: u32 = 1; impl WeighMultiAssets for MultiAssetFilter { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { - let weight = match self { + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + match self { Self::Definite(assets) => assets .inner() .into_iter() @@ -52,166 +49,157 @@ impl WeighMultiAssets for MultiAssetFilter { Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight, Self::Wild(AllCounted(count)) => balances_weight.saturating_mul(*count as u64), Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS as u64), - }; - - weight.ref_time() + } } } impl WeighMultiAssets for MultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { - let weight = self - .inner() + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + self.inner() .into_iter() .map(|m| >::from(m)) .map(|t| match t { AssetTypes::Balances => balances_weight, AssetTypes::Unknown => Weight::MAX, }) - .fold(Weight::zero(), |acc, x| acc.saturating_add(x)); - - weight.ref_time() + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)) } } pub struct KusamaXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for KusamaXcmWeight { - fn withdraw_asset(assets: &MultiAssets) -> XCMWeight { + fn withdraw_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::withdraw_asset()) } - fn reserve_asset_deposited(assets: &MultiAssets) -> XCMWeight { + fn reserve_asset_deposited(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::reserve_asset_deposited()) } - fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight { + fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, _response: &Response, - _max_weight: &u64, + _max_weight: &Weight, _querier: &Option, - ) -> XCMWeight { - XcmGeneric::::query_response().ref_time() + ) -> Weight { + XcmGeneric::::query_response() } - fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight { + fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_asset()) } fn transfer_reserve_asset( assets: &MultiAssets, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( _origin_type: &OriginKind, - _require_weight_at_most: &u64, + _require_weight_at_most: &Weight, _call: &DoubleEncoded, - ) -> XCMWeight { - XcmGeneric::::transact().ref_time() + ) -> Weight { + XcmGeneric::::transact() } fn hrmp_new_channel_open_request( _sender: &u32, _max_message_size: &u32, _max_capacity: &u32, - ) -> XCMWeight { + ) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight { + fn hrmp_channel_accepted(_recipient: &u32) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight { + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn clear_origin() -> XCMWeight { - XcmGeneric::::clear_origin().ref_time() + fn clear_origin() -> Weight { + XcmGeneric::::clear_origin() } - fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight { - XcmGeneric::::descend_origin().ref_time() + fn descend_origin(_who: &InteriorMultiLocation) -> Weight { + XcmGeneric::::descend_origin() } - fn report_error(_query_response_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::report_error().ref_time() + fn report_error(_query_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_error() } - fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> XCMWeight { + fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset( - _give: &MultiAssetFilter, - _receive: &MultiAssets, - _maximal: &bool, - ) -> XCMWeight { + fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { // Kusama does not currently support exchange asset operations - Weight::MAX.ref_time() + Weight::MAX } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, _reserve: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmGeneric::::initiate_reserve_withdraw()) } fn initiate_teleport( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } - fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> XCMWeight { - XcmGeneric::::report_holding().ref_time() + fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight { + XcmGeneric::::report_holding() } - fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight { - XcmGeneric::::buy_execution().ref_time() + fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { + XcmGeneric::::buy_execution() } - fn refund_surplus() -> XCMWeight { - XcmGeneric::::refund_surplus().ref_time() + fn refund_surplus() -> Weight { + XcmGeneric::::refund_surplus() } - fn set_error_handler(_xcm: &Xcm) -> XCMWeight { - XcmGeneric::::set_error_handler().ref_time() + fn set_error_handler(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_error_handler() } - fn set_appendix(_xcm: &Xcm) -> XCMWeight { - XcmGeneric::::set_appendix().ref_time() + fn set_appendix(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_appendix() } - fn clear_error() -> XCMWeight { - XcmGeneric::::clear_error().ref_time() + fn clear_error() -> Weight { + XcmGeneric::::clear_error() } - fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight { - XcmGeneric::::claim_asset().ref_time() + fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight { + XcmGeneric::::claim_asset() } - fn trap(_code: &u64) -> XCMWeight { - XcmGeneric::::trap().ref_time() + fn trap(_code: &u64) -> Weight { + XcmGeneric::::trap() } - fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight { - XcmGeneric::::subscribe_version().ref_time() + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight { + XcmGeneric::::subscribe_version() } - fn unsubscribe_version() -> XCMWeight { - XcmGeneric::::unsubscribe_version().ref_time() + fn unsubscribe_version() -> Weight { + XcmGeneric::::unsubscribe_version() } - fn burn_asset(assets: &MultiAssets) -> XCMWeight { + fn burn_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmGeneric::::burn_asset()) } - fn expect_asset(assets: &MultiAssets) -> XCMWeight { + fn expect_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmGeneric::::expect_asset()) } - fn expect_origin(_origin: &Option) -> XCMWeight { - XcmGeneric::::expect_origin().ref_time() + fn expect_origin(_origin: &Option) -> Weight { + XcmGeneric::::expect_origin() } - fn expect_error(_error: &Option<(u32, XcmError)>) -> XCMWeight { - XcmGeneric::::expect_error().ref_time() + fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight { + XcmGeneric::::expect_error() } - fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::query_pallet().ref_time() + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::query_pallet() } fn expect_pallet( _index: &u32, @@ -219,52 +207,52 @@ impl XcmWeightInfo for KusamaXcmWeight { _module_name: &Vec, _crate_major: &u32, _min_crate_minor: &u32, - ) -> XCMWeight { - XcmGeneric::::expect_pallet().ref_time() + ) -> Weight { + XcmGeneric::::expect_pallet() } - fn report_transact_status(_response_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::report_transact_status().ref_time() + fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_transact_status() } - fn clear_transact_status() -> XCMWeight { - XcmGeneric::::clear_transact_status().ref_time() + fn clear_transact_status() -> Weight { + XcmGeneric::::clear_transact_status() } - fn universal_origin(_: &Junction) -> XCMWeight { + fn universal_origin(_: &Junction) -> Weight { // Kusama does not currently support universal origin operations - Weight::MAX.ref_time() + Weight::MAX } - fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight { - Weight::MAX.ref_time() // todo fix + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { + Weight::MAX // todo fix } - fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { // Kusama does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { // Kusama does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { // Kusama does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { // Kusama does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn set_fees_mode(_: &bool) -> XCMWeight { - XcmGeneric::::set_fees_mode().ref_time() + fn set_fees_mode(_: &bool) -> Weight { + XcmGeneric::::set_fees_mode() } - fn set_topic(_topic: &[u8; 32]) -> XCMWeight { - XcmGeneric::::set_topic().ref_time() + fn set_topic(_topic: &[u8; 32]) -> Weight { + XcmGeneric::::set_topic() } - fn clear_topic() -> XCMWeight { - XcmGeneric::::clear_topic().ref_time() + fn clear_topic() -> Weight { + XcmGeneric::::clear_topic() } - fn alias_origin(_: &MultiLocation) -> XCMWeight { + fn alias_origin(_: &MultiLocation) -> Weight { // XCM Executor does not currently support alias origin operations - Weight::MAX.ref_time() + Weight::MAX } - fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { - XcmGeneric::::unpaid_execution().ref_time() + fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { + XcmGeneric::::unpaid_execution() } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index b3b15a3443ce..7d69c1aad487 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -23,6 +23,7 @@ use super::{ use frame_support::{ match_types, parameter_types, traits::{Everything, Nothing}, + weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; @@ -90,7 +91,7 @@ type LocalOriginConverter = ( parameter_types! { /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: u64 = 1_000_000_000; + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); /// Maximum number of instructions in a single XCM fragment. A sanity check against weight /// calculations getting too crazy. pub const MaxInstructions: u32 = 100; @@ -216,4 +217,5 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = crate::weights::pallet_xcm::WeightInfo; } diff --git a/runtime/parachains/src/configuration/migration.rs b/runtime/parachains/src/configuration/migration.rs index d87c98f6ae78..b5be14cebeec 100644 --- a/runtime/parachains/src/configuration/migration.rs +++ b/runtime/parachains/src/configuration/migration.rs @@ -208,8 +208,8 @@ pvf_checking_enabled : pre.pvf_checking_enabled, pvf_voting_ttl : pre.pvf_voting_ttl, minimum_validation_upgrade_delay : pre.minimum_validation_upgrade_delay, -ump_service_total_weight: Weight::from_ref_time(pre.ump_service_total_weight.0).set_proof_size(MAX_POV_SIZE as u64), -ump_max_individual_weight: Weight::from_ref_time(pre.ump_max_individual_weight.0).set_proof_size(MAX_POV_SIZE as u64), +ump_service_total_weight: Weight::from_parts(pre.ump_service_total_weight.0, MAX_POV_SIZE as u64), +ump_max_individual_weight: Weight::from_parts(pre.ump_max_individual_weight.0, MAX_POV_SIZE as u64), } }; diff --git a/runtime/parachains/src/configuration/tests.rs b/runtime/parachains/src/configuration/tests.rs index 6f2faf6cb204..a4363c3f28fa 100644 --- a/runtime/parachains/src/configuration/tests.rs +++ b/runtime/parachains/src/configuration/tests.rs @@ -319,7 +319,7 @@ fn setting_pending_config_members() { max_upward_queue_count: 1337, max_upward_queue_size: 228, max_downward_message_size: 2048, - ump_service_total_weight: Weight::from_ref_time(20000), + ump_service_total_weight: Weight::from_parts(20000, 20000), max_upward_message_size: 448, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 22, @@ -332,7 +332,7 @@ fn setting_pending_config_members() { hrmp_max_parachain_outbound_channels: 10, hrmp_max_parathread_outbound_channels: 20, hrmp_max_message_num_per_candidate: 20, - ump_max_individual_weight: Weight::from_ref_time(909), + ump_max_individual_weight: Weight::from_parts(909, 909), pvf_checking_enabled: true, pvf_voting_ttl: 3, minimum_validation_upgrade_delay: 20, diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 3e6ed79a77c2..7cadb2429bb3 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -83,7 +83,7 @@ parameter_types! { pub const BlockHashCount: u32 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max( - Weight::from_ref_time(4 * 1024 * 1024).set_proof_size(u64::MAX), + Weight::from_parts(4 * 1024 * 1024, u64::MAX), ); } @@ -394,7 +394,7 @@ impl UmpSink for TestUmpSink { max_weight: Weight, ) -> Result { let weight = match u32::decode(&mut &actual_msg[..]) { - Ok(w) => Weight::from_ref_time(w as u64), + Ok(w) => Weight::from_parts(w as u64, w as u64), Err(_) => return Ok(Weight::zero()), // same as the real `UmpSink` }; if weight.any_gt(max_weight) { diff --git a/runtime/parachains/src/paras/mod.rs b/runtime/parachains/src/paras/mod.rs index 061aed6aba44..0269d010d9e1 100644 --- a/runtime/parachains/src/paras/mod.rs +++ b/runtime/parachains/src/paras/mod.rs @@ -517,7 +517,7 @@ impl WeightInfo for TestWeightInfo { } fn include_pvf_check_statement() -> Weight { // This special value is to distinguish from the finalizing variants above in tests. - Weight::MAX - Weight::from_ref_time(1) + Weight::MAX - Weight::from_parts(1, 1) } } diff --git a/runtime/parachains/src/ump.rs b/runtime/parachains/src/ump.rs index 63e6e2c4692b..2bd4056bdd45 100644 --- a/runtime/parachains/src/ump.rs +++ b/runtime/parachains/src/ump.rs @@ -133,13 +133,11 @@ impl, C: Config> UmpSink }, Ok((Ok(xcm_message), weight_used)) => { let xcm_junction = Junction::Parachain(origin.into()); - let outcome = - XcmExecutor::execute_xcm(xcm_junction, xcm_message, id, max_weight.ref_time()); + let outcome = XcmExecutor::execute_xcm(xcm_junction, xcm_message, id, max_weight); match outcome { - Outcome::Error(XcmError::WeightLimitReached(required)) => - Err((id, Weight::from_ref_time(required))), + Outcome::Error(XcmError::WeightLimitReached(required)) => Err((id, required)), outcome => { - let outcome_weight = Weight::from_ref_time(outcome.weight_used()); + let outcome_weight = outcome.weight_used(); Pallet::::deposit_event(Event::ExecutedUpward(id, outcome)); Ok(weight_used.saturating_add(outcome_weight)) }, diff --git a/runtime/parachains/src/ump/benchmarking.rs b/runtime/parachains/src/ump/benchmarking.rs index 206829599f9b..e326ddeaf8d7 100644 --- a/runtime/parachains/src/ump/benchmarking.rs +++ b/runtime/parachains/src/ump/benchmarking.rs @@ -43,7 +43,7 @@ fn create_message_min_size(size: u32) -> Vec { // Create a message with an empty remark call to determine the encoding overhead let msg_size_empty_transact = VersionedXcm::::from(Xcm::(vec![Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: Weight::MAX.ref_time(), + require_weight_at_most: Weight::MAX, call: frame_system::Call::::remark_with_event { remark: vec![] }.encode().into(), }])) .encode() @@ -55,7 +55,7 @@ fn create_message_min_size(size: u32) -> Vec { remark.resize(size, 0u8); let msg = VersionedXcm::::from(Xcm::(vec![Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: Weight::MAX.ref_time(), + require_weight_at_most: Weight::MAX, call: frame_system::Call::::remark_with_event { remark }.encode().into(), }])) .encode(); @@ -70,7 +70,7 @@ fn create_message_overweight() -> Vec { let call = frame_system::Call::::set_code { code: vec![] }; VersionedXcm::::from(Xcm::(vec![Transact { origin_kind: OriginKind::Superuser, - require_weight_at_most: max_block_weight.ref_time(), + require_weight_at_most: max_block_weight, call: call.encode().into(), }])) .encode() @@ -107,7 +107,6 @@ frame_benchmarking::benchmarks! { service_overweight { let host_conf = configuration::ActiveConfig::::get(); - let weight = host_conf.ump_max_individual_weight + host_conf.ump_max_individual_weight + Weight::from_ref_time(1000000); let para = ParaId::from(1978); // The message's weight does not really matter here, as we add service_overweight's // max_weight parameter to the extrinsic's weight in the weight calculation. @@ -117,7 +116,7 @@ frame_benchmarking::benchmarks! { let msg = create_message_overweight::(); // This just makes sure that 0 is not a valid index and we can use it later on. - let _ = Ump::::service_overweight(RawOrigin::Root.into(), 0, Weight::from_ref_time(1000).set_proof_size(u64::MAX)); + let _ = Ump::::service_overweight(RawOrigin::Root.into(), 0, Weight::from_parts(1000, 1000)); // Start with the block number 1. This is needed because should an event be // emitted during the genesis block they will be implicitly wiped. frame_system::Pallet::::set_block_number(1u32.into()); diff --git a/runtime/parachains/src/ump/tests.rs b/runtime/parachains/src/ump/tests.rs index 23c5159eab0f..1ae5dd59718d 100644 --- a/runtime/parachains/src/ump/tests.rs +++ b/runtime/parachains/src/ump/tests.rs @@ -34,12 +34,12 @@ pub(super) struct GenesisConfigBuilder { impl Default for GenesisConfigBuilder { fn default() -> Self { Self { - max_upward_message_size: 16, + max_upward_message_size: 32, max_upward_message_num_per_candidate: 2, max_upward_queue_count: 4, max_upward_queue_size: 64, - ump_service_total_weight: Weight::from_ref_time(1000).set_proof_size(1000), - ump_max_individual_weight: Weight::from_ref_time(100).set_proof_size(100), + ump_service_total_weight: Weight::from_parts(1000, 1000), + ump_max_individual_weight: Weight::from_parts(100, 100), } } } @@ -156,7 +156,7 @@ fn dispatch_resume_after_exceeding_dispatch_stage_weight() { new_test_ext( GenesisConfigBuilder { - ump_service_total_weight: Weight::from_ref_time(500).set_proof_size(500), + ump_service_total_weight: Weight::from_parts(500, 500), ..Default::default() } .build(), @@ -203,8 +203,8 @@ fn dispatch_keeps_message_after_weight_exhausted() { new_test_ext( GenesisConfigBuilder { - ump_service_total_weight: Weight::from_ref_time(500).set_proof_size(500), - ump_max_individual_weight: Weight::from_ref_time(300).set_proof_size(300), + ump_service_total_weight: Weight::from_parts(500, 500), + ump_max_individual_weight: Weight::from_parts(300, 300), ..Default::default() } .build(), @@ -243,7 +243,7 @@ fn dispatch_correctly_handle_remove_of_latest() { new_test_ext( GenesisConfigBuilder { - ump_service_total_weight: Weight::from_ref_time(900).set_proof_size(900), + ump_service_total_weight: Weight::from_parts(900, 900), ..Default::default() } .build(), @@ -296,7 +296,7 @@ fn service_overweight_unknown() { // the next test. new_test_ext(GenesisConfigBuilder::default().build()).execute_with(|| { assert_noop!( - Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(1000)), + Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_parts(1000, 1000)), Error::::UnknownMessageIndex ); }); @@ -312,8 +312,8 @@ fn overweight_queue_works() { new_test_ext( GenesisConfigBuilder { - ump_service_total_weight: Weight::from_ref_time(900).set_proof_size(900), - ump_max_individual_weight: Weight::from_ref_time(300).set_proof_size(300), + ump_service_total_weight: Weight::from_parts(900, 900), + ump_max_individual_weight: Weight::from_parts(300, 300), ..Default::default() } .build(), @@ -338,7 +338,7 @@ fn overweight_queue_works() { para_a, upward_message_id(&a_msg_3[..]), 0, - Weight::from_ref_time(500), + Weight::from_parts(500, 500), ) .into(), ); @@ -346,18 +346,18 @@ fn overweight_queue_works() { // Now verify that if we wanted to service this overweight message with less than enough // weight it will fail. assert_noop!( - Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(499)), + Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_parts(499, 499)), Error::::WeightOverLimit ); // ... and if we try to service it with just enough weight it will succeed as well. - assert_ok!(Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(500))); - assert_last_event(Event::OverweightServiced(0, Weight::from_ref_time(500)).into()); + assert_ok!(Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_parts(500, 500))); + assert_last_event(Event::OverweightServiced(0, Weight::from_parts(500, 500)).into()); // ... and if we try to service a message with index that doesn't exist it will error // out. assert_noop!( - Ump::service_overweight(RuntimeOrigin::root(), 1, Weight::from_ref_time(1000)), + Ump::service_overweight(RuntimeOrigin::root(), 1, Weight::from_parts(1000, 1000)), Error::::UnknownMessageIndex ); }); diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index b13dd7561dfe..2bcc3fff2a98 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1572,6 +1572,8 @@ pub type Executive = frame_executive::Executive< // "Properly migrate weights to v2" parachains_configuration::migration::v3::MigrateToV3, pallet_election_provider_multi_phase::migrations::v1::MigrateToV1, + // "Use 2D weights in XCM v3" + pallet_xcm::migration::v1::MigrateToV1, ), >; @@ -1631,6 +1633,8 @@ mod benches { [pallet_treasury, Treasury] [pallet_utility, Utility] [pallet_vesting, Vesting] + // XCM + [pallet_xcm, XcmPallet] ); } diff --git a/runtime/polkadot/src/weights/mod.rs b/runtime/polkadot/src/weights/mod.rs index cef1ce83bd11..606dc93a92bc 100644 --- a/runtime/polkadot/src/weights/mod.rs +++ b/runtime/polkadot/src/weights/mod.rs @@ -43,6 +43,7 @@ pub mod pallet_tips; pub mod pallet_treasury; pub mod pallet_utility; pub mod pallet_vesting; +pub mod pallet_xcm; pub mod runtime_common_auctions; pub mod runtime_common_claims; pub mod runtime_common_crowdloan; diff --git a/runtime/polkadot/src/weights/pallet_xcm.rs b/runtime/polkadot/src/weights/pallet_xcm.rs new file mode 100644 index 000000000000..b96f19029f04 --- /dev/null +++ b/runtime/polkadot/src/weights/pallet_xcm.rs @@ -0,0 +1,115 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=polkadot-dev +// --header=./file_header.txt +// --output=./runtime/polkadot/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl pallet_xcm::WeightInfo for WeightInfo { + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + fn send() -> Weight { + // Minimum execution time: 32_774 nanoseconds. + Weight::from_ref_time(33_997_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + fn teleport_assets() -> Weight { + // Minimum execution time: 28_642 nanoseconds. + Weight::from_ref_time(28_983_000 as u64) + } + fn reserve_transfer_assets() -> Weight { + // Minimum execution time: 27_163 nanoseconds. + Weight::from_ref_time(28_021_000 as u64) + } + // Storage: Benchmark Override (r:0 w:0) + fn execute() -> Weight { + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_ref_time(18_446_744_073_709_551_000 as u64) + } + // Storage: XcmPallet SupportedVersion (r:0 w:1) + fn force_xcm_version() -> Weight { + // Minimum execution time: 13_985 nanoseconds. + Weight::from_ref_time(14_726_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet SafeXcmVersion (r:0 w:1) + fn force_default_xcm_version() -> Weight { + // Minimum execution time: 3_783 nanoseconds. + Weight::from_ref_time(3_948_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet VersionNotifiers (r:1 w:1) + // Storage: XcmPallet QueryCounter (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: XcmPallet Queries (r:0 w:1) + fn force_subscribe_version_notify() -> Weight { + // Minimum execution time: 37_360 nanoseconds. + Weight::from_ref_time(37_845_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: XcmPallet VersionNotifiers (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: XcmPallet Queries (r:0 w:1) + fn force_unsubscribe_version_notify() -> Weight { + // Minimum execution time: 40_002 nanoseconds. + Weight::from_ref_time(40_985_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } +} diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 9e1eeaa67f41..fcdc0c6427f0 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -23,6 +23,7 @@ use super::{ use frame_support::{ match_types, parameter_types, traits::{Everything, Nothing}, + weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; @@ -90,7 +91,7 @@ type LocalOriginConverter = ( parameter_types! { /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: u64 = 1_000_000_000; + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); /// Maximum number of instructions in a single XCM fragment. A sanity check against weight /// calculations getting too crazy. pub const MaxInstructions: u32 = 100; @@ -204,4 +205,5 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = crate::weights::pallet_xcm::WeightInfo; } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 747dd3eb1fec..a7da89a4a4b3 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1461,6 +1461,8 @@ pub type Executive = frame_executive::Executive< pallet_multisig::migrations::v1::MigrateToV1, // "Properly migrate weights to v2" parachains_configuration::migration::v3::MigrateToV3, + // "Use 2D weights in XCM v3" + pallet_xcm::migration::v1::MigrateToV1, ), >; /// The payload being signed in transactions. @@ -1514,6 +1516,7 @@ mod benches { [pallet_utility, Utility] [pallet_vesting, Vesting] // XCM + [pallet_xcm, XcmPallet] [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::] [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::] ); diff --git a/runtime/rococo/src/weights/mod.rs b/runtime/rococo/src/weights/mod.rs index 712783bc3e6c..f8b67a1041c1 100644 --- a/runtime/rococo/src/weights/mod.rs +++ b/runtime/rococo/src/weights/mod.rs @@ -38,6 +38,7 @@ pub mod pallet_tips; pub mod pallet_treasury; pub mod pallet_utility; pub mod pallet_vesting; +pub mod pallet_xcm; pub mod runtime_common_auctions; pub mod runtime_common_claims; pub mod runtime_common_crowdloan; diff --git a/runtime/rococo/src/weights/pallet_xcm.rs b/runtime/rococo/src/weights/pallet_xcm.rs new file mode 100644 index 000000000000..e6759a46becc --- /dev/null +++ b/runtime/rococo/src/weights/pallet_xcm.rs @@ -0,0 +1,114 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=rococo-dev +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl pallet_xcm::WeightInfo for WeightInfo { + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + fn send() -> Weight { + // Minimum execution time: 33_793 nanoseconds. + Weight::from_ref_time(34_487_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + fn teleport_assets() -> Weight { + // Minimum execution time: 27_892 nanoseconds. + Weight::from_ref_time(28_743_000 as u64) + } + fn reserve_transfer_assets() -> Weight { + // Minimum execution time: 27_514 nanoseconds. + Weight::from_ref_time(28_068_000 as u64) + } + fn execute() -> Weight { + // Minimum execution time: 14_485 nanoseconds. + Weight::from_ref_time(14_860_000 as u64) + } + // Storage: XcmPallet SupportedVersion (r:0 w:1) + fn force_xcm_version() -> Weight { + // Minimum execution time: 14_669 nanoseconds. + Weight::from_ref_time(15_412_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet SafeXcmVersion (r:0 w:1) + fn force_default_xcm_version() -> Weight { + // Minimum execution time: 4_542 nanoseconds. + Weight::from_ref_time(4_710_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet VersionNotifiers (r:1 w:1) + // Storage: XcmPallet QueryCounter (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: XcmPallet Queries (r:0 w:1) + fn force_subscribe_version_notify() -> Weight { + // Minimum execution time: 38_404 nanoseconds. + Weight::from_ref_time(39_169_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: XcmPallet VersionNotifiers (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: XcmPallet Queries (r:0 w:1) + fn force_unsubscribe_version_notify() -> Weight { + // Minimum execution time: 41_677 nanoseconds. + Weight::from_ref_time(42_484_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } +} diff --git a/runtime/rococo/src/weights/xcm/mod.rs b/runtime/rococo/src/weights/xcm/mod.rs index e0221357d24a..9fb5941b80fe 100644 --- a/runtime/rococo/src/weights/xcm/mod.rs +++ b/runtime/rococo/src/weights/xcm/mod.rs @@ -4,10 +4,7 @@ mod pallet_xcm_benchmarks_generic; use crate::Runtime; use frame_support::weights::Weight; use sp_std::prelude::*; -use xcm::{ - latest::{prelude::*, Weight as XCMWeight}, - DoubleEncoded, -}; +use xcm::{latest::prelude::*, DoubleEncoded}; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; @@ -31,15 +28,15 @@ impl From<&MultiAsset> for AssetTypes { } trait WeighMultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight; + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight; } // Rococo only knows about one asset, the balances pallet. const MAX_ASSETS: u32 = 1; impl WeighMultiAssets for MultiAssetFilter { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { - let weight = match self { + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + match self { Self::Definite(assets) => assets .inner() .into_iter() @@ -52,166 +49,157 @@ impl WeighMultiAssets for MultiAssetFilter { Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight, Self::Wild(AllCounted(count)) => balances_weight.saturating_mul(*count as u64), Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS as u64), - }; - - weight.ref_time() + } } } impl WeighMultiAssets for MultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { - let weight = self - .inner() + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + self.inner() .into_iter() .map(|m| >::from(m)) .map(|t| match t { AssetTypes::Balances => balances_weight, AssetTypes::Unknown => Weight::MAX, }) - .fold(Weight::zero(), |acc, x| acc.saturating_add(x)); - - weight.ref_time() + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)) } } pub struct RococoXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for RococoXcmWeight { - fn withdraw_asset(assets: &MultiAssets) -> XCMWeight { + fn withdraw_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::withdraw_asset()) } - fn reserve_asset_deposited(assets: &MultiAssets) -> XCMWeight { + fn reserve_asset_deposited(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::reserve_asset_deposited()) } - fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight { + fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, _response: &Response, - _max_weight: &u64, + _max_weight: &Weight, _querier: &Option, - ) -> XCMWeight { - XcmGeneric::::query_response().ref_time() + ) -> Weight { + XcmGeneric::::query_response() } - fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight { + fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_asset()) } fn transfer_reserve_asset( assets: &MultiAssets, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( _origin_type: &OriginKind, - _require_weight_at_most: &u64, + _require_weight_at_most: &Weight, _call: &DoubleEncoded, - ) -> XCMWeight { - XcmGeneric::::transact().ref_time() + ) -> Weight { + XcmGeneric::::transact() } fn hrmp_new_channel_open_request( _sender: &u32, _max_message_size: &u32, _max_capacity: &u32, - ) -> XCMWeight { + ) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight { + fn hrmp_channel_accepted(_recipient: &u32) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight { + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn clear_origin() -> XCMWeight { - XcmGeneric::::clear_origin().ref_time() + fn clear_origin() -> Weight { + XcmGeneric::::clear_origin() } - fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight { - XcmGeneric::::descend_origin().ref_time() + fn descend_origin(_who: &InteriorMultiLocation) -> Weight { + XcmGeneric::::descend_origin() } - fn report_error(_query_response_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::report_error().ref_time() + fn report_error(_query_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_error() } - fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> XCMWeight { + fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset( - _give: &MultiAssetFilter, - _receive: &MultiAssets, - _maximal: &bool, - ) -> XCMWeight { + fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { // Rococo does not currently support exchange asset operations - Weight::MAX.ref_time() + Weight::MAX } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, _reserve: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmGeneric::::initiate_reserve_withdraw()) } fn initiate_teleport( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } - fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> XCMWeight { - XcmGeneric::::report_holding().ref_time() + fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight { + XcmGeneric::::report_holding() } - fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight { - XcmGeneric::::buy_execution().ref_time() + fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { + XcmGeneric::::buy_execution() } - fn refund_surplus() -> XCMWeight { - XcmGeneric::::refund_surplus().ref_time() + fn refund_surplus() -> Weight { + XcmGeneric::::refund_surplus() } - fn set_error_handler(_xcm: &Xcm) -> XCMWeight { - XcmGeneric::::set_error_handler().ref_time() + fn set_error_handler(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_error_handler() } - fn set_appendix(_xcm: &Xcm) -> XCMWeight { - XcmGeneric::::set_appendix().ref_time() + fn set_appendix(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_appendix() } - fn clear_error() -> XCMWeight { - XcmGeneric::::clear_error().ref_time() + fn clear_error() -> Weight { + XcmGeneric::::clear_error() } - fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight { - XcmGeneric::::claim_asset().ref_time() + fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight { + XcmGeneric::::claim_asset() } - fn trap(_code: &u64) -> XCMWeight { - XcmGeneric::::trap().ref_time() + fn trap(_code: &u64) -> Weight { + XcmGeneric::::trap() } - fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight { - XcmGeneric::::subscribe_version().ref_time() + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight { + XcmGeneric::::subscribe_version() } - fn unsubscribe_version() -> XCMWeight { - XcmGeneric::::unsubscribe_version().ref_time() + fn unsubscribe_version() -> Weight { + XcmGeneric::::unsubscribe_version() } - fn burn_asset(assets: &MultiAssets) -> XCMWeight { + fn burn_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmGeneric::::burn_asset()) } - fn expect_asset(assets: &MultiAssets) -> XCMWeight { + fn expect_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmGeneric::::expect_asset()) } - fn expect_origin(_origin: &Option) -> XCMWeight { - XcmGeneric::::expect_origin().ref_time() + fn expect_origin(_origin: &Option) -> Weight { + XcmGeneric::::expect_origin() } - fn expect_error(_error: &Option<(u32, XcmError)>) -> XCMWeight { - XcmGeneric::::expect_error().ref_time() + fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight { + XcmGeneric::::expect_error() } - fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::query_pallet().ref_time() + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::query_pallet() } fn expect_pallet( _index: &u32, @@ -219,52 +207,52 @@ impl XcmWeightInfo for RococoXcmWeight { _module_name: &Vec, _crate_major: &u32, _min_crate_minor: &u32, - ) -> XCMWeight { - XcmGeneric::::expect_pallet().ref_time() + ) -> Weight { + XcmGeneric::::expect_pallet() } - fn report_transact_status(_response_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::report_transact_status().ref_time() + fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_transact_status() } - fn clear_transact_status() -> XCMWeight { - XcmGeneric::::clear_transact_status().ref_time() + fn clear_transact_status() -> Weight { + XcmGeneric::::clear_transact_status() } - fn universal_origin(_: &Junction) -> XCMWeight { + fn universal_origin(_: &Junction) -> Weight { // Kusama does not currently support universal origin operations - Weight::MAX.ref_time() + Weight::MAX } - fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight { - Weight::MAX.ref_time() // todo fix + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { + Weight::MAX // todo fix } - fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { // Kusama does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { // Kusama does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { // Kusama does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { // Kusama does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn set_fees_mode(_: &bool) -> XCMWeight { - XcmGeneric::::set_fees_mode().ref_time() + fn set_fees_mode(_: &bool) -> Weight { + XcmGeneric::::set_fees_mode() } - fn set_topic(_topic: &[u8; 32]) -> XCMWeight { - XcmGeneric::::set_topic().ref_time() + fn set_topic(_topic: &[u8; 32]) -> Weight { + XcmGeneric::::set_topic() } - fn clear_topic() -> XCMWeight { - XcmGeneric::::clear_topic().ref_time() + fn clear_topic() -> Weight { + XcmGeneric::::clear_topic() } - fn alias_origin(_: &MultiLocation) -> XCMWeight { + fn alias_origin(_: &MultiLocation) -> Weight { // XCM Executor does not currently support alias origin operations - Weight::MAX.ref_time() + Weight::MAX } - fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { - XcmGeneric::::unpaid_execution().ref_time() + fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { + XcmGeneric::::unpaid_execution() } } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 503af148e8ce..2b35d4e9a11f 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -23,6 +23,7 @@ use super::{ use frame_support::{ match_types, parameter_types, traits::{Everything, Nothing}, + weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; @@ -77,7 +78,7 @@ type LocalOriginConverter = ( parameter_types! { /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: u64 = 1_000_000_000; + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); } /// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our /// individual routers. @@ -210,4 +211,5 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = LocationConverter; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = crate::weights::pallet_xcm::WeightInfo; } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index dcbc83892154..972a18528a06 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -533,7 +533,7 @@ impl parachains_ump::Config for Runtime { } parameter_types! { - pub const BaseXcmWeight: xcm::latest::Weight = 1_000; + pub const BaseXcmWeight: xcm::latest::Weight = Weight::from_parts(1_000, 1_000); pub const AnyNetwork: Option = None; pub const MaxInstructions: u32 = 100; pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; @@ -564,6 +564,7 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = (); type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; } impl parachains_hrmp::Config for Runtime { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index d3ad71f2724e..992b116e98ea 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -17,8 +17,9 @@ use frame_support::{ parameter_types, traits::{Everything, Nothing}, + weights::Weight, }; -use xcm::latest::{prelude::*, Weight as XCMWeight}; +use xcm::latest::prelude::*; use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32}; use xcm_executor::{ traits::{TransactAsset, WeightTrader}, @@ -74,7 +75,7 @@ impl WeightTrader for DummyWeightTrader { DummyWeightTrader } - fn buy_weight(&mut self, _weight: XCMWeight, _payment: Assets) -> Result { + fn buy_weight(&mut self, _weight: Weight, _payment: Assets) -> Result { Ok(Assets::default()) } } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 82469316b760..54a1c5de1f43 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1223,6 +1223,8 @@ pub type Executive = frame_executive::Executive< // "Properly migrate weights to v2" parachains_configuration::migration::v3::MigrateToV3, pallet_election_provider_multi_phase::migrations::v1::MigrateToV1, + // "Use 2D weights in XCM v3" + pallet_xcm::migration::v1::MigrateToV1, ), >; /// The payload being signed in transactions. @@ -1273,6 +1275,7 @@ mod benches { [pallet_utility, Utility] [pallet_vesting, Vesting] // XCM + [pallet_xcm, XcmPallet] // NOTE: Make sure you point to the individual modules below. [pallet_xcm_benchmarks::fungible, XcmBalances] [pallet_xcm_benchmarks::generic, XcmGeneric] diff --git a/runtime/westend/src/weights/mod.rs b/runtime/westend/src/weights/mod.rs index 216b3dcdf4ec..5ca093c618d5 100644 --- a/runtime/westend/src/weights/mod.rs +++ b/runtime/westend/src/weights/mod.rs @@ -34,6 +34,7 @@ pub mod pallet_staking; pub mod pallet_timestamp; pub mod pallet_utility; pub mod pallet_vesting; +pub mod pallet_xcm; pub mod runtime_common_auctions; pub mod runtime_common_crowdloan; pub mod runtime_common_paras_registrar; diff --git a/runtime/westend/src/weights/pallet_xcm.rs b/runtime/westend/src/weights/pallet_xcm.rs new file mode 100644 index 000000000000..5ff074c99432 --- /dev/null +++ b/runtime/westend/src/weights/pallet_xcm.rs @@ -0,0 +1,112 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-11-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=westend-dev +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl pallet_xcm::WeightInfo for WeightInfo { + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + fn send() -> Weight { + // Minimum execution time: 33_543 nanoseconds. + Weight::from_ref_time(33_958_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + fn teleport_assets() -> Weight { + // Minimum execution time: 27_780 nanoseconds. + Weight::from_ref_time(28_311_000 as u64) + } + fn reserve_transfer_assets() -> Weight { + // Minimum execution time: 26_135 nanoseconds. + Weight::from_ref_time(26_932_000 as u64) + } + // Storage: Benchmark Override (r:0 w:0) + fn execute() -> Weight { + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_ref_time(18_446_744_073_709_551_000 as u64) + } + // Storage: XcmPallet SupportedVersion (r:0 w:1) + fn force_xcm_version() -> Weight { + // Minimum execution time: 14_738 nanoseconds. + Weight::from_ref_time(15_217_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet SafeXcmVersion (r:0 w:1) + fn force_default_xcm_version() -> Weight { + // Minimum execution time: 4_327 nanoseconds. + Weight::from_ref_time(4_527_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet VersionNotifiers (r:1 w:1) + // Storage: XcmPallet QueryCounter (r:1 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: XcmPallet Queries (r:0 w:1) + fn force_subscribe_version_notify() -> Weight { + // Minimum execution time: 38_724 nanoseconds. + Weight::from_ref_time(39_594_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: XcmPallet VersionNotifiers (r:1 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: XcmPallet Queries (r:0 w:1) + fn force_unsubscribe_version_notify() -> Weight { + // Minimum execution time: 40_663 nanoseconds. + Weight::from_ref_time(42_347_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } +} diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 4913ea15ae92..26df93378959 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -5,7 +5,7 @@ use crate::Runtime; use frame_support::weights::Weight; use sp_std::prelude::*; use xcm::{ - latest::{prelude::*, QueryResponseInfo, Weight as XCMWeight}, + latest::{prelude::*, QueryResponseInfo}, DoubleEncoded, }; @@ -31,15 +31,15 @@ impl From<&MultiAsset> for AssetTypes { } trait WeighMultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight; + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight; } // Westend only knows about one asset, the balances pallet. const MAX_ASSETS: u32 = 1; impl WeighMultiAssets for MultiAssetFilter { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { - let weight = match self { + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + match self { Self::Definite(assets) => assets .inner() .into_iter() @@ -52,166 +52,157 @@ impl WeighMultiAssets for MultiAssetFilter { Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight, Self::Wild(AllCounted(count)) => balances_weight.saturating_mul(*count as u64), Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS as u64), - }; - - weight.ref_time() + } } } impl WeighMultiAssets for MultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { - let weight = self - .inner() + fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + self.inner() .into_iter() .map(|m| >::from(m)) .map(|t| match t { AssetTypes::Balances => balances_weight, AssetTypes::Unknown => Weight::MAX, }) - .fold(Weight::zero(), |acc, x| acc.saturating_add(x)); - - weight.ref_time() + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)) } } pub struct WestendXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for WestendXcmWeight { - fn withdraw_asset(assets: &MultiAssets) -> XCMWeight { + fn withdraw_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::withdraw_asset()) } - fn reserve_asset_deposited(assets: &MultiAssets) -> XCMWeight { + fn reserve_asset_deposited(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::reserve_asset_deposited()) } - fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight { + fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, _response: &Response, - _max_weight: &u64, + _max_weight: &Weight, _querier: &Option, - ) -> XCMWeight { - XcmGeneric::::query_response().ref_time() + ) -> Weight { + XcmGeneric::::query_response() } - fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight { + fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_asset()) } fn transfer_reserve_asset( assets: &MultiAssets, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( _origin_kind: &OriginKind, - _require_weight_at_most: &u64, + _require_weight_at_most: &Weight, _call: &DoubleEncoded, - ) -> XCMWeight { - XcmGeneric::::transact().ref_time() + ) -> Weight { + XcmGeneric::::transact() } fn hrmp_new_channel_open_request( _sender: &u32, _max_message_size: &u32, _max_capacity: &u32, - ) -> XCMWeight { + ) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight { + fn hrmp_channel_accepted(_recipient: &u32) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight { + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX.ref_time() + Weight::MAX } - fn clear_origin() -> XCMWeight { - XcmGeneric::::clear_origin().ref_time() + fn clear_origin() -> Weight { + XcmGeneric::::clear_origin() } - fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight { - XcmGeneric::::descend_origin().ref_time() + fn descend_origin(_who: &InteriorMultiLocation) -> Weight { + XcmGeneric::::descend_origin() } - fn report_error(_query_repsonse_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::report_error().ref_time() + fn report_error(_query_repsonse_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_error() } - fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> XCMWeight { + fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset( - _give: &MultiAssetFilter, - _receive: &MultiAssets, - _maximal: &bool, - ) -> XCMWeight { + fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { // Westend does not currently support exchange asset operations - Weight::MAX.ref_time() + Weight::MAX } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, _reserve: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmGeneric::::initiate_reserve_withdraw()) } fn initiate_teleport( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> XCMWeight { + ) -> Weight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } - fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> XCMWeight { - XcmGeneric::::report_holding().ref_time() + fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight { + XcmGeneric::::report_holding() } - fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight { - XcmGeneric::::buy_execution().ref_time() + fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { + XcmGeneric::::buy_execution() } - fn refund_surplus() -> XCMWeight { - XcmGeneric::::refund_surplus().ref_time() + fn refund_surplus() -> Weight { + XcmGeneric::::refund_surplus() } - fn set_error_handler(_xcm: &Xcm) -> XCMWeight { - XcmGeneric::::set_error_handler().ref_time() + fn set_error_handler(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_error_handler() } - fn set_appendix(_xcm: &Xcm) -> XCMWeight { - XcmGeneric::::set_appendix().ref_time() + fn set_appendix(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_appendix() } - fn clear_error() -> XCMWeight { - XcmGeneric::::clear_error().ref_time() + fn clear_error() -> Weight { + XcmGeneric::::clear_error() } - fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight { - XcmGeneric::::claim_asset().ref_time() + fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight { + XcmGeneric::::claim_asset() } - fn trap(_code: &u64) -> XCMWeight { - XcmGeneric::::trap().ref_time() + fn trap(_code: &u64) -> Weight { + XcmGeneric::::trap() } - fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight { - XcmGeneric::::subscribe_version().ref_time() + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight { + XcmGeneric::::subscribe_version() } - fn unsubscribe_version() -> XCMWeight { - XcmGeneric::::unsubscribe_version().ref_time() + fn unsubscribe_version() -> Weight { + XcmGeneric::::unsubscribe_version() } - fn burn_asset(assets: &MultiAssets) -> XCMWeight { + fn burn_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmGeneric::::burn_asset()) } - fn expect_asset(assets: &MultiAssets) -> XCMWeight { + fn expect_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmGeneric::::expect_asset()) } - fn expect_origin(_origin: &Option) -> XCMWeight { - XcmGeneric::::expect_origin().ref_time() + fn expect_origin(_origin: &Option) -> Weight { + XcmGeneric::::expect_origin() } - fn expect_error(_error: &Option<(u32, XcmError)>) -> XCMWeight { - XcmGeneric::::expect_error().ref_time() + fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight { + XcmGeneric::::expect_error() } - fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::query_pallet().ref_time() + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::query_pallet() } fn expect_pallet( _index: &u32, @@ -219,53 +210,53 @@ impl XcmWeightInfo for WestendXcmWeight { _module_name: &Vec, _crate_major: &u32, _min_crate_minor: &u32, - ) -> XCMWeight { - XcmGeneric::::expect_pallet().ref_time() + ) -> Weight { + XcmGeneric::::expect_pallet() } - fn report_transact_status(_response_info: &QueryResponseInfo) -> XCMWeight { - XcmGeneric::::report_transact_status().ref_time() + fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_transact_status() } - fn clear_transact_status() -> XCMWeight { - XcmGeneric::::clear_transact_status().ref_time() + fn clear_transact_status() -> Weight { + XcmGeneric::::clear_transact_status() } - fn universal_origin(_: &Junction) -> XCMWeight { + fn universal_origin(_: &Junction) -> Weight { // Westend does not currently support universal origin operations - Weight::MAX.ref_time() + Weight::MAX } - fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight { + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { // Westend does not currently support export message operations - Weight::MAX.ref_time() + Weight::MAX } - fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { // Westend does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { // Westend does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { // Westend does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { // Westend does not currently support asset locking operations - Weight::MAX.ref_time() + Weight::MAX } - fn set_fees_mode(_: &bool) -> XCMWeight { - XcmGeneric::::set_fees_mode().ref_time() + fn set_fees_mode(_: &bool) -> Weight { + XcmGeneric::::set_fees_mode() } - fn set_topic(_topic: &[u8; 32]) -> XCMWeight { - XcmGeneric::::set_topic().ref_time() + fn set_topic(_topic: &[u8; 32]) -> Weight { + XcmGeneric::::set_topic() } - fn clear_topic() -> XCMWeight { - XcmGeneric::::clear_topic().ref_time() + fn clear_topic() -> Weight { + XcmGeneric::::clear_topic() } - fn alias_origin(_: &MultiLocation) -> XCMWeight { + fn alias_origin(_: &MultiLocation) -> Weight { // XCM Executor does not currently support alias origin operations - Weight::MAX.ref_time() + Weight::MAX } - fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { - XcmGeneric::::unpaid_execution().ref_time() + fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { + XcmGeneric::::unpaid_execution() } } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 94098bbfc406..2ad4ede3e247 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -157,4 +157,5 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = LocationConverter; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = crate::weights::pallet_xcm::WeightInfo; } diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index 92013128f728..eec315d11eb8 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -11,21 +11,21 @@ impl-trait-for-tuples = "0.2.2" log = { version = "0.4.17", default-features = false } parity-scale-codec = { version = "3.1.5", default-features = false, features = [ "derive", "max-encoded-len" ] } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-weights = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } serde = { version = "1.0.136", optional = true, features = ["derive"] } xcm-procedural = { path = "procedural" } +[dev-dependencies] +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } + [features] default = ["std"] wasm-api = [] -runtime-benchmarks = [ - "sp-runtime/runtime-benchmarks", -] std = [ "parity-scale-codec/std", "scale-info/std", "serde", - "sp-io/std", - "sp-runtime/std", + "sp-core/std", + "sp-weights/std", ] diff --git a/xcm/pallet-xcm-benchmarks/Cargo.toml b/xcm/pallet-xcm-benchmarks/Cargo.toml index 92c7d53c15cd..928f51c2eeea 100644 --- a/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -47,7 +47,6 @@ std = [ "xcm-executor/std" ] runtime-benchmarks = [ - "xcm/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index b1004818e685..6f36c2c883f7 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -51,9 +51,7 @@ frame_support::construct_runtime!( parameter_types! { pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max( - Weight::from_ref_time(1024).set_proof_size(u64::MAX), - ); + frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX)); } impl frame_system::Config for Test { type BaseCallFilter = Everything; diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index cc83ab65c2e3..e9914f2e7c0d 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -21,7 +21,7 @@ use frame_benchmarking::{benchmarks, BenchmarkError}; use frame_support::dispatch::GetDispatchInfo; use sp_std::vec; use xcm::{ - latest::{prelude::*, MaybeErrorCode}, + latest::{prelude::*, MaybeErrorCode, Weight}, DoubleEncoded, }; use xcm_executor::{ExecutorError, FeesMode}; @@ -37,7 +37,7 @@ benchmarks! { response_info: QueryResponseInfo { destination: T::valid_destination()?, query_id: Default::default(), - max_weight: u64::MAX, + max_weight: Weight::MAX, }, // Worst case is looking through all holdings for every asset explicitly. assets: Definite(holding), @@ -76,7 +76,7 @@ benchmarks! { query_response { let mut executor = new_executor::(Default::default()); let (query_id, response) = T::worst_case_response(); - let max_weight = u64::MAX; + let max_weight = Weight::MAX; let querier: Option = Some(Here.into()); let instruction = Instruction::QueryResponse { query_id, response, max_weight, querier }; let xcm = Xcm(vec![instruction]); @@ -99,7 +99,7 @@ benchmarks! { let instruction = Instruction::Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: noop_call.get_dispatch_info().weight.ref_time(), + require_weight_at_most: noop_call.get_dispatch_info().weight, call: double_encoded_noop_call, }; let xcm = Xcm(vec![instruction]); @@ -117,16 +117,16 @@ benchmarks! { let holding = T::worst_case_holding(0).into(); let mut executor = new_executor::(Default::default()); executor.set_holding(holding); - executor.set_total_surplus(1337); - executor.set_total_refunded(0); + executor.set_total_surplus(Weight::from_parts(1337, 1337)); + executor.set_total_refunded(Weight::zero()); let instruction = Instruction::>::RefundSurplus; let xcm = Xcm(vec![instruction]); } : { let result = executor.bench_process(xcm)?; } verify { - assert_eq!(executor.total_surplus(), &1337); - assert_eq!(executor.total_refunded(), &1337); + assert_eq!(executor.total_surplus(), &Weight::from_parts(1337, 1337)); + assert_eq!(executor.total_refunded(), &Weight::from_parts(1337, 1337)); } set_error_handler { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index f9bc34844139..595bf3aea65b 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -55,9 +55,7 @@ frame_support::construct_runtime!( parameter_types! { pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max( - Weight::from_ref_time(1024).set_proof_size(u64::MAX), - ); + frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX)); } impl frame_system::Config for Test { diff --git a/xcm/pallet-xcm-benchmarks/src/mock.rs b/xcm/pallet-xcm-benchmarks/src/mock.rs index 61f8ea4e0926..e8cff81c635d 100644 --- a/xcm/pallet-xcm-benchmarks/src/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/mock.rs @@ -16,7 +16,7 @@ use crate::*; use frame_support::{parameter_types, traits::ContainsPair}; -use xcm::latest::Weight as XCMWeight; +use xcm::latest::Weight; // An xcm sender/receiver akin to > /dev/null pub struct DevNull; @@ -39,10 +39,10 @@ impl xcm_executor::traits::OnResponse for DevNull { _: u64, _: Option<&MultiLocation>, _: Response, - _: XCMWeight, + _: Weight, _: &XcmContext, - ) -> XCMWeight { - 0 + ) -> Weight { + Weight::zero() } } @@ -63,7 +63,7 @@ impl xcm_executor::traits::Convert for AccountIdConverter { parameter_types! { pub UniversalLocation: InteriorMultiLocation = Junction::Parachain(101).into(); - pub UnitWeightCost: u64 = 10; + pub UnitWeightCost: Weight = Weight::from_parts(10, 10); pub WeightPrice: (AssetId, u128) = (Concrete(Here.into()), 1_000_000); } diff --git a/xcm/pallet-xcm/Cargo.toml b/xcm/pallet-xcm/Cargo.toml index e356784e6166..f59fda13cbc2 100644 --- a/xcm/pallet-xcm/Cargo.toml +++ b/xcm/pallet-xcm/Cargo.toml @@ -10,6 +10,7 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive" serde = { version = "1.0.137", optional = true, features = ["derive"] } log = { version = "0.4.17", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -36,12 +37,14 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", + "frame-benchmarking?/std", "frame-support/std", "frame-system/std", "xcm/std", "xcm-executor/std", ] runtime-benchmarks = [ - "frame-system/runtime-benchmarks" + "frame-benchmarking/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs new file mode 100644 index 000000000000..6c5ddabca40a --- /dev/null +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -0,0 +1,82 @@ +// Copyright 2022 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 . + +use super::*; +use frame_benchmarking::{benchmarks, BenchmarkError, BenchmarkResult}; +use frame_support::weights::Weight; +use frame_system::RawOrigin; +use sp_std::prelude::*; +use xcm::latest::prelude::*; + +type RuntimeOrigin = ::RuntimeOrigin; + +benchmarks! { + send { + let send_origin = T::SendXcmOrigin::successful_origin(); + let msg = Xcm(vec![ClearOrigin]); + let versioned_dest: VersionedMultiLocation = Parachain(2000).into(); + let versioned_msg = VersionedXcm::from(msg); + }: _>(send_origin, Box::new(versioned_dest), Box::new(versioned_msg)) + + teleport_assets { + let recipient = [0u8; 32]; + let versioned_dest: VersionedMultiLocation = Parachain(2000).into(); + let versioned_beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: recipient.into() }.into(); + let versioned_assets: VersionedMultiAssets = (Here, 10).into(); + }: _(RawOrigin::Root, Box::new(versioned_dest), Box::new(versioned_beneficiary), Box::new(versioned_assets), 0) + + reserve_transfer_assets { + let recipient = [0u8; 32]; + let versioned_dest: VersionedMultiLocation = Parachain(2000).into(); + let versioned_beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: recipient.into() }.into(); + let versioned_assets: VersionedMultiAssets = (Here, 10).into(); + }: _(RawOrigin::Root, Box::new(versioned_dest), Box::new(versioned_beneficiary), Box::new(versioned_assets), 0) + + execute { + let execute_origin = T::ExecuteXcmOrigin::successful_origin(); + let origin_location = T::ExecuteXcmOrigin::try_origin(execute_origin.clone()) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?; + let msg = Xcm(vec![ClearOrigin]); + if !T::XcmExecuteFilter::contains(&(origin_location, msg.clone())) { + return Err(BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX))) + } + let versioned_msg = VersionedXcm::from(msg); + }: _>(execute_origin, Box::new(versioned_msg), Weight::zero()) + + force_xcm_version { + let loc = Parachain(2000).into_location(); + let xcm_version = 2; + }: _(RawOrigin::Root, Box::new(loc), xcm_version) + + force_default_xcm_version {}: _(RawOrigin::Root, Some(2)) + + force_subscribe_version_notify { + let versioned_loc: VersionedMultiLocation = Parachain(2000).into(); + }: _(RawOrigin::Root, Box::new(versioned_loc)) + + force_unsubscribe_version_notify { + let versioned_loc: VersionedMultiLocation = Parachain(2000).into(); + let _ = Pallet::::request_version_notify(Parachain(2000)); + }: _(RawOrigin::Root, Box::new(versioned_loc)) + + impl_benchmark_test_suite!( + Pallet, + crate::mock::new_test_ext_with_balances(Vec::new()), + crate::mock::Test + ); +} diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 2913ff55dee9..f2da48273f86 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -18,11 +18,15 @@ #![cfg_attr(not(feature = "std"), no_std)] +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; #[cfg(test)] mod mock; #[cfg(test)] mod tests; +pub mod migration; + use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; use frame_support::traits::{ Contains, ContainsPair, Currency, Defensive, EnsureOrigin, Get, LockableCurrency, OriginTrait, @@ -35,10 +39,7 @@ use sp_runtime::{ RuntimeDebug, }; use sp_std::{boxed::Box, marker::PhantomData, prelude::*, result::Result, vec}; -use xcm::{ - latest::{QueryResponseInfo, Weight as XcmWeight}, - prelude::*, -}; +use xcm::{latest::QueryResponseInfo, prelude::*}; use xcm_executor::traits::{Convert, ConvertOrigin}; use frame_support::{ @@ -56,6 +57,53 @@ use xcm_executor::{ Assets, }; +pub trait WeightInfo { + fn send() -> Weight; + fn teleport_assets() -> Weight; + fn reserve_transfer_assets() -> Weight; + fn execute() -> Weight; + fn force_xcm_version() -> Weight; + fn force_default_xcm_version() -> Weight; + fn force_subscribe_version_notify() -> Weight; + fn force_unsubscribe_version_notify() -> Weight; +} + +/// fallback implementation +pub struct TestWeightInfo; +impl WeightInfo for TestWeightInfo { + fn send() -> Weight { + Weight::MAX + } + + fn teleport_assets() -> Weight { + Weight::MAX + } + + fn reserve_transfer_assets() -> Weight { + Weight::MAX + } + + fn execute() -> Weight { + Weight::MAX + } + + fn force_xcm_version() -> Weight { + Weight::MAX + } + + fn force_default_xcm_version() -> Weight { + Weight::MAX + } + + fn force_subscribe_version_notify() -> Weight { + Weight::MAX + } + + fn force_unsubscribe_version_notify() -> Weight { + Weight::MAX + } +} + #[frame_support::pallet] pub mod pallet { use super::*; @@ -75,6 +123,7 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] + #[pallet::storage_version(migration::STORAGE_VERSION)] #[pallet::without_storage_info] pub struct Pallet(_); @@ -157,6 +206,9 @@ pub mod pallet { /// The maximum number of local XCM locks that a single account may have. type MaxLockers: Get; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; } #[pallet::event] @@ -460,7 +512,7 @@ pub mod pallet { XcmVersion, Blake2_128Concat, VersionedMultiLocation, - (QueryId, u64, XcmVersion), + (QueryId, Weight, XcmVersion), OptionQuery, >; @@ -652,7 +704,16 @@ pub mod pallet { #[pallet::call] impl Pallet { - #[pallet::weight(100_000_000)] + #[pallet::weight({ + let maybe_msg: Result, ()> = (*message.clone()).try_into(); + match maybe_msg { + Ok(msg) => { + T::Weigher::weight(&mut msg.into()) + .map_or(Weight::MAX, |w| T::WeightInfo::send().saturating_add(w)) + } + _ => Weight::MAX, + } + })] pub fn send( origin: OriginFor, dest: Box, @@ -699,8 +760,8 @@ pub mod pallet { xcm: Xcm(vec![]), }, ]); - T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w))) - }, + T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| T::WeightInfo::teleport_assets().saturating_add(w)) + } _ => Weight::MAX, } })] @@ -731,14 +792,16 @@ pub mod pallet { /// - `fee_asset_item`: The index into `assets` of the item which should be used to pay /// fees. #[pallet::weight({ - match ((*assets.clone()).try_into(), (*dest.clone()).try_into()) { + let maybe_assets: Result = (*assets.clone()).try_into(); + let maybe_dest: Result = (*dest.clone()).try_into(); + match (maybe_assets, maybe_dest) { (Ok(assets), Ok(dest)) => { use sp_std::vec; let mut message = Xcm(vec![ TransferReserveAsset { assets, dest, xcm: Xcm(vec![]) } ]); - T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w))) - }, + T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| T::WeightInfo::reserve_transfer_assets().saturating_add(w)) + } _ => Weight::MAX, } })] @@ -770,11 +833,11 @@ pub mod pallet { /// /// NOTE: A successful return to this does *not* imply that the `msg` was executed successfully /// to completion; only that *some* of it was executed. - #[pallet::weight(Weight::from_ref_time(max_weight.saturating_add(100_000_000u64)))] + #[pallet::weight(max_weight.saturating_add(T::WeightInfo::execute()))] pub fn execute( origin: OriginFor, message: Box::RuntimeCall>>, - max_weight: XcmWeight, + max_weight: Weight, ) -> DispatchResultWithPostInfo { let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let hash = message.using_encoded(sp_io::hashing::blake2_256); @@ -786,10 +849,11 @@ pub mod pallet { origin_location, message, hash, - max_weight, //.ref_time(), - max_weight, //.ref_time(), + max_weight, + max_weight, ); - let result = Ok(Some(outcome.weight_used().saturating_add(100_000_000)).into()); + let result = + Ok(Some(outcome.weight_used().saturating_add(T::WeightInfo::execute())).into()); Self::deposit_event(Event::Attempted(outcome)); result } @@ -800,7 +864,7 @@ pub mod pallet { /// - `origin`: Must be Root. /// - `location`: The destination that is being described. /// - `xcm_version`: The latest version of XCM that `location` supports. - #[pallet::weight(100_000_000u64)] + #[pallet::weight(T::WeightInfo::force_xcm_version())] pub fn force_xcm_version( origin: OriginFor, location: Box, @@ -822,7 +886,7 @@ pub mod pallet { /// /// - `origin`: Must be Root. /// - `maybe_xcm_version`: The default XCM encoding version, or `None` to disable. - #[pallet::weight(100_000_000u64)] + #[pallet::weight(T::WeightInfo::force_default_xcm_version())] pub fn force_default_xcm_version( origin: OriginFor, maybe_xcm_version: Option, @@ -836,7 +900,7 @@ pub mod pallet { /// /// - `origin`: Must be Root. /// - `location`: The location to which we should subscribe for XCM version notifications. - #[pallet::weight(100_000_000u64)] + #[pallet::weight(T::WeightInfo::force_subscribe_version_notify())] pub fn force_subscribe_version_notify( origin: OriginFor, location: Box, @@ -859,7 +923,7 @@ pub mod pallet { /// - `origin`: Must be Root. /// - `location`: The location to which we are currently subscribed for XCM version /// notifications which we no longer desire. - #[pallet::weight(100_000_000u64)] + #[pallet::weight(T::WeightInfo::force_unsubscribe_version_notify())] pub fn force_unsubscribe_version_notify( origin: OriginFor, location: Box, @@ -895,14 +959,16 @@ pub mod pallet { /// fees. /// - `weight_limit`: The remote-side weight limit, if any, for the XCM fee purchase. #[pallet::weight({ - match ((*assets.clone()).try_into(), (*dest.clone()).try_into()) { + let maybe_assets: Result = (*assets.clone()).try_into(); + let maybe_dest: Result = (*dest.clone()).try_into(); + match (maybe_assets, maybe_dest) { (Ok(assets), Ok(dest)) => { use sp_std::vec; let mut message = Xcm(vec![ TransferReserveAsset { assets, dest, xcm: Xcm(vec![]) } ]); - T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w))) - }, + T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| T::WeightInfo::reserve_transfer_assets().saturating_add(w)) + } _ => Weight::MAX, } })] @@ -951,8 +1017,8 @@ pub mod pallet { WithdrawAsset(assets), InitiateTeleport { assets: Wild(All), dest, xcm: Xcm(vec![]) }, ]); - T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w))) - }, + T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| T::WeightInfo::teleport_assets().saturating_add(w)) + } _ => Weight::MAX, } })] @@ -1015,7 +1081,7 @@ impl Pallet { let mut remote_message = Xcm(vec![ ReserveAssetDeposited(assets.clone()), ClearOrigin, - BuyExecution { fees, weight_limit: Limited(0) }, + BuyExecution { fees, weight_limit: Limited(Weight::zero()) }, DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, ]); // use local weight for remote message and hope for the best. @@ -1073,7 +1139,7 @@ impl Pallet { let mut remote_message = Xcm(vec![ ReceiveTeleportedAsset(assets.clone()), ClearOrigin, - BuyExecution { fees, weight_limit: Limited(0) }, + BuyExecution { fees, weight_limit: Limited(Weight::zero()) }, DepositAsset { assets: Wild(AllCounted(max_assets)), beneficiary }, ]); // use local weight for remote message and hope for the best. @@ -1252,7 +1318,7 @@ impl Pallet { r }); // TODO #3735: Correct weight. - let instruction = SubscribeVersion { query_id, max_response_weight: 0 }; + let instruction = SubscribeVersion { query_id, max_response_weight: Weight::zero() }; let (_hash, cost) = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; Self::deposit_event(Event::VersionNotifyRequested(dest, cost)); VersionNotifiers::::insert(XCM_VERSION, &versioned_dest, query_id); @@ -1350,7 +1416,7 @@ impl Pallet { .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: 0 }; + 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) @@ -1389,7 +1455,7 @@ impl Pallet { .invert_target(&responder) .map_err(|()| XcmError::LocationNotInvertible)?; let notify: ::RuntimeCall = notify.into(); - let max_weight = notify.get_dispatch_info().weight.ref_time(); + let max_weight = notify.get_dispatch_info().weight; let query_id = Self::new_notify_query(responder, notify, timeout, Here); let response_info = QueryResponseInfo { destination, query_id, max_weight }; let report_error = Xcm(vec![ReportError(response_info)]); @@ -1684,7 +1750,7 @@ impl VersionChangeNotifier for Pallet { fn start( dest: &MultiLocation, query_id: QueryId, - max_weight: u64, + max_weight: Weight, _context: &XcmContext, ) -> XcmResult { let versioned_dest = LatestVersionedMultiLocation(dest); @@ -1717,16 +1783,16 @@ impl VersionChangeNotifier for Pallet { } impl DropAssets for Pallet { - fn drop_assets(origin: &MultiLocation, assets: Assets, _context: &XcmContext) -> u64 { + fn drop_assets(origin: &MultiLocation, assets: Assets, _context: &XcmContext) -> Weight { if assets.is_empty() { - return 0 + return Weight::zero() } let versioned = VersionedMultiAssets::from(MultiAssets::from(assets)); let hash = BlakeTwo256::hash_of(&(&origin, &versioned)); AssetTraps::::mutate(hash, |n| *n += 1); Self::deposit_event(Event::AssetsTrapped(hash, origin.clone(), versioned)); // TODO #3735: Put the real weight in there. - 0 + Weight::zero() } } @@ -1783,9 +1849,9 @@ impl OnResponse for Pallet { query_id: QueryId, querier: Option<&MultiLocation>, response: Response, - max_weight: u64, + max_weight: Weight, _context: &XcmContext, - ) -> u64 { + ) -> Weight { match (response, Queries::::get(query_id)) { ( Response::Version(v), @@ -1799,7 +1865,7 @@ impl OnResponse for Pallet { query_id, Some(o), )); - return 0 + return Weight::zero() }, _ => { Self::deposit_event(Event::InvalidResponder( @@ -1808,7 +1874,7 @@ impl OnResponse for Pallet { None, )); // TODO #3735: Correct weight for this. - return 0 + return Weight::zero() }, }; // TODO #3735: Check max_weight is correct. @@ -1828,7 +1894,7 @@ impl OnResponse for Pallet { v, ); Self::deposit_event(Event::SupportedVersionChanged(origin, v)); - 0 + Weight::zero() }, ( response, @@ -1842,7 +1908,7 @@ impl OnResponse for Pallet { origin.clone(), query_id, )); - return 0 + return Weight::zero() }, }; if querier.map_or(true, |q| q != &match_querier) { @@ -1852,7 +1918,7 @@ impl OnResponse for Pallet { match_querier, querier.cloned(), )); - return 0 + return Weight::zero() } } let responder = match MultiLocation::try_from(responder) { @@ -1862,7 +1928,7 @@ impl OnResponse for Pallet { origin.clone(), query_id, )); - return 0 + return Weight::zero() }, }; if origin != &responder { @@ -1871,7 +1937,7 @@ impl OnResponse for Pallet { query_id, Some(responder), )); - return 0 + return Weight::zero() } return match maybe_notify { Some((pallet_index, call_index)) => { @@ -1884,16 +1950,16 @@ impl OnResponse for Pallet { }) { Queries::::remove(query_id); let weight = call.get_dispatch_info().weight; - if weight.ref_time() > max_weight { + if weight.any_gt(max_weight) { let e = Event::NotifyOverweight( query_id, pallet_index, call_index, weight, - Weight::from_ref_time(max_weight), + max_weight, ); Self::deposit_event(e); - return 0 + return Weight::zero() } let dispatch_origin = Origin::Response(origin.clone()).into(); match call.dispatch(dispatch_origin) { @@ -1915,11 +1981,10 @@ impl OnResponse for Pallet { }, } .unwrap_or(weight) - .ref_time() } else { let e = Event::NotifyDecodeFailed(query_id, pallet_index, call_index); Self::deposit_event(e); - 0 + Weight::zero() } }, None => { @@ -1928,13 +1993,13 @@ impl OnResponse for Pallet { let at = frame_system::Pallet::::current_block_number(); let response = response.into(); Queries::::insert(query_id, QueryStatus::Ready { response, at }); - 0 + Weight::zero() }, } }, _ => { Self::deposit_event(Event::UnexpectedResponse(origin.clone(), query_id)); - return 0 + return Weight::zero() }, } } diff --git a/xcm/pallet-xcm/src/migration.rs b/xcm/pallet-xcm/src/migration.rs new file mode 100644 index 000000000000..9b96306f0d68 --- /dev/null +++ b/xcm/pallet-xcm/src/migration.rs @@ -0,0 +1,61 @@ +// Copyright 2022 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 . + +use crate::{Config, Pallet, Store}; +use frame_support::{ + pallet_prelude::*, + traits::{OnRuntimeUpgrade, StorageVersion}, + weights::Weight, +}; + +pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + +const DEFAULT_PROOF_SIZE: u64 = 64 * 1024; + +pub mod v1 { + use super::*; + + pub struct MigrateToV1(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for MigrateToV1 { + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + ensure!(StorageVersion::get::>() == 0, "must upgrade linearly"); + + Ok(sp_std::vec::Vec::new()) + } + + fn on_runtime_upgrade() -> Weight { + if StorageVersion::get::>() == 0 { + let mut weight = T::DbWeight::get().reads(1); + + let translate = |pre: (u64, u64, u32)| -> Option<(u64, Weight, u32)> { + weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); + Some((pre.0, Weight::from_parts(pre.1, DEFAULT_PROOF_SIZE), pre.2)) + }; + + as Store>::VersionNotifyTargets::translate_values(translate); + + log::info!("v1 applied successfully"); + STORAGE_VERSION.put::>(); + + weight.saturating_add(T::DbWeight::get().writes(1)) + } else { + log::warn!("skipping v1, should be removed"); + T::DbWeight::get().reads(1) + } + } + } +} diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 6f11f5f6fcc3..9c0d34194ab0 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -18,6 +18,7 @@ use codec::Encode; use frame_support::{ construct_runtime, parameter_types, traits::{Everything, Nothing}, + weights::Weight, }; use polkadot_parachain::primitives::Id as ParaId; use polkadot_runtime_parachains::origin; @@ -34,7 +35,7 @@ use xcm_builder::{ }; use xcm_executor::XcmExecutor; -use crate as pallet_xcm; +use crate::{self as pallet_xcm, TestWeightInfo}; pub type AccountId = AccountId32; pub type Balance = u128; @@ -77,7 +78,7 @@ pub mod pallet_test_notifier { #[pallet::call] impl Pallet { - #[pallet::weight(1_000_000)] + #[pallet::weight(Weight::from_parts(1_000_000, 1_000_000))] pub fn prepare_new_query(origin: OriginFor, querier: MultiLocation) -> DispatchResult { let who = ensure_signed(origin)?; let id = who @@ -92,7 +93,7 @@ pub mod pallet_test_notifier { Ok(()) } - #[pallet::weight(1_000_000)] + #[pallet::weight(Weight::from_parts(1_000_000, 1_000_000))] pub fn prepare_new_notify_query( origin: OriginFor, querier: MultiLocation, @@ -113,7 +114,7 @@ pub mod pallet_test_notifier { Ok(()) } - #[pallet::weight(1_000_000)] + #[pallet::weight(Weight::from_parts(1_000_000, 1_000_000))] pub fn notification_received( origin: OriginFor, query_id: QueryId, @@ -262,7 +263,7 @@ type LocalOriginConverter = ( ); parameter_types! { - pub const BaseXcmWeight: u64 = 1_000; + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000, 1_000); pub CurrencyPerSecond: (AssetId, u128) = (Concrete(RelayLocation::get()), 1); pub TrustedAssets: (MultiAssetFilter, MultiLocation) = (All.into(), Here.into()); pub const MaxInstructions: u32 = 100; @@ -328,6 +329,7 @@ impl pallet_xcm::Config for Test { type Currency = Balances; type CurrencyMatcher = IsConcrete; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = TestWeightInfo; } impl origin::Config for Test {} @@ -351,7 +353,10 @@ pub(crate) fn buy_execution(fees: impl Into) -> Instruction { BuyExecution { fees: fees.into(), weight_limit: Unlimited } } -pub(crate) fn buy_limited_execution(fees: impl Into, weight: u64) -> Instruction { +pub(crate) fn buy_limited_execution( + fees: impl Into, + weight: Weight, +) -> Instruction { use xcm::latest::prelude::*; BuyExecution { fees: fees.into(), weight_limit: Limited(weight) } } diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index 3d5216573adb..2700124976f1 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -65,8 +65,8 @@ fn report_outcome_notify_works() { SetAppendix(Xcm(vec![ReportError(QueryResponseInfo { destination: Parent.into(), query_id: 0, - max_weight: 1_000_000 - }),])), + max_weight: Weight::from_parts(1_000_000, 1_000_000), + })])), TransferAsset { assets: (Here, SEND_AMOUNT).into(), beneficiary: sender.clone() }, ]) ); @@ -82,13 +82,17 @@ fn report_outcome_notify_works() { let message = Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), - max_weight: 1_000_000, + max_weight: Weight::from_parts(1_000_000, 1_000_000), querier: Some(querier), }]); let hash = fake_message_hash(&message); - let r = - XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, 1_000_000_000); - assert_eq!(r, Outcome::Complete(1_000)); + let r = XcmExecutor::::execute_xcm( + Parachain(PARA_ID), + message, + hash, + Weight::from_parts(1_000_000_000, 1_000_000_000), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(1_000, 1_000))); assert_eq!( last_events(2), vec![ @@ -123,8 +127,8 @@ fn report_outcome_works() { SetAppendix(Xcm(vec![ReportError(QueryResponseInfo { destination: Parent.into(), query_id: 0, - max_weight: 0 - }),])), + max_weight: Weight::zero(), + })])), TransferAsset { assets: (Here, SEND_AMOUNT).into(), beneficiary: sender.clone() }, ]) ); @@ -140,13 +144,17 @@ fn report_outcome_works() { let message = Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), - max_weight: 0, + max_weight: Weight::zero(), querier: Some(querier), }]); let hash = fake_message_hash(&message); - let r = - XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, 1_000_000_000); - assert_eq!(r, Outcome::Complete(1_000)); + let r = XcmExecutor::::execute_xcm( + Parachain(PARA_ID), + message, + hash, + Weight::from_parts(1_000_000_000, 1_000_000_000), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(1_000, 1_000))); assert_eq!( last_event(), RuntimeEvent::XcmPallet(crate::Event::ResponseReady( @@ -184,7 +192,7 @@ fn custom_querier_works() { let message = Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), - max_weight: 0, + max_weight: Weight::zero(), querier: None, }]); let hash = fake_message_hash(&message); @@ -192,10 +200,10 @@ fn custom_querier_works() { AccountId32 { network: None, id: ALICE.into() }, message, hash, - 1_000_000_000, - 1_000, + Weight::from_parts(1_000_000_000, 1_000_000_000), + Weight::from_parts(1_000, 1_000), ); - assert_eq!(r, Outcome::Complete(1_000)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(1_000, 1_000))); assert_eq!( last_event(), RuntimeEvent::XcmPallet(crate::Event::InvalidQuerier( @@ -210,7 +218,7 @@ fn custom_querier_works() { let message = Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), - max_weight: 0, + max_weight: Weight::zero(), querier: Some(MultiLocation::here()), }]); let hash = fake_message_hash(&message); @@ -218,10 +226,10 @@ fn custom_querier_works() { AccountId32 { network: None, id: ALICE.into() }, message, hash, - 1_000_000_000, - 1_000, + Weight::from_parts(1_000_000_000, 1_000_000_000), + Weight::from_parts(1_000, 1_000), ); - assert_eq!(r, Outcome::Complete(1_000)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(1_000, 1_000))); assert_eq!( last_event(), RuntimeEvent::XcmPallet(crate::Event::InvalidQuerier( @@ -236,7 +244,7 @@ fn custom_querier_works() { let message = Xcm(vec![QueryResponse { query_id: 0, response: Response::ExecutionResult(None), - max_weight: 0, + max_weight: Weight::zero(), querier: Some(querier), }]); let hash = fake_message_hash(&message); @@ -244,9 +252,9 @@ fn custom_querier_works() { AccountId32 { network: None, id: ALICE.into() }, message, hash, - 1_000_000_000, + Weight::from_parts(1_000_000_000, 1_000_000_000), ); - assert_eq!(r, Outcome::Complete(1_000)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(1_000, 1_000))); assert_eq!( last_event(), RuntimeEvent::XcmPallet(crate::Event::ResponseReady( @@ -341,7 +349,7 @@ fn teleport_assets_works() { (ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE), ]; new_test_ext_with_balances(balances).execute_with(|| { - let weight = 2 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 2; assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::teleport_assets( @@ -359,7 +367,7 @@ fn teleport_assets_works() { Xcm(vec![ ReceiveTeleportedAsset((Here, SEND_AMOUNT).into()), ClearOrigin, - buy_limited_execution((Here, SEND_AMOUNT), 4000), + buy_limited_execution((Here, SEND_AMOUNT), Weight::from_parts(4000, 4000)), DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] @@ -378,13 +386,13 @@ fn teleport_assets_works() { /// Asserts that the sender's balance is decreased as a result of execution of /// local effects. #[test] -fn limmited_teleport_assets_works() { +fn limited_teleport_assets_works() { let balances = vec![ (ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE), ]; new_test_ext_with_balances(balances).execute_with(|| { - let weight = 2 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 2; assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::limited_teleport_assets( @@ -393,7 +401,7 @@ fn limmited_teleport_assets_works() { Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), 0, - WeightLimit::Limited(5000), + WeightLimit::Limited(Weight::from_parts(5000, 5000)), )); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE - SEND_AMOUNT); assert_eq!( @@ -403,7 +411,7 @@ fn limmited_teleport_assets_works() { Xcm(vec![ ReceiveTeleportedAsset((Here, SEND_AMOUNT).into()), ClearOrigin, - buy_limited_execution((Here, SEND_AMOUNT), 5000), + buy_limited_execution((Here, SEND_AMOUNT), Weight::from_parts(5000, 5000)), DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] @@ -422,13 +430,13 @@ fn limmited_teleport_assets_works() { /// Asserts that the sender's balance is decreased as a result of execution of /// local effects. #[test] -fn unlimmited_teleport_assets_works() { +fn unlimited_teleport_assets_works() { let balances = vec![ (ALICE, INITIAL_BALANCE), (ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE), ]; new_test_ext_with_balances(balances).execute_with(|| { - let weight = 2 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 2; assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::limited_teleport_assets( @@ -492,7 +500,7 @@ fn reserve_transfer_assets_works() { Xcm(vec![ ReserveAssetDeposited((Parent, SEND_AMOUNT).into()), ClearOrigin, - buy_limited_execution((Parent, SEND_AMOUNT), 4000), + buy_limited_execution((Parent, SEND_AMOUNT), Weight::from_parts(4000, 4000)), DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] @@ -526,7 +534,7 @@ fn limited_reserve_transfer_assets_works() { Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), 0, - WeightLimit::Limited(5000), + WeightLimit::Limited(Weight::from_parts(5000, 5000)), )); // Alice spent amount assert_eq!(Balances::free_balance(ALICE), INITIAL_BALANCE - SEND_AMOUNT); @@ -540,7 +548,7 @@ fn limited_reserve_transfer_assets_works() { Xcm(vec![ ReserveAssetDeposited((Parent, SEND_AMOUNT).into()), ClearOrigin, - buy_limited_execution((Parent, SEND_AMOUNT), 5000), + buy_limited_execution((Parent, SEND_AMOUNT), Weight::from_parts(5000, 5000)), DepositAsset { assets: AllCounted(1).into(), beneficiary: dest }, ]), )] @@ -611,7 +619,7 @@ fn execute_withdraw_to_deposit_works() { (ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE), ]; new_test_ext_with_balances(balances).execute_with(|| { - let weight = 3 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 3; let dest: MultiLocation = Junction::AccountId32 { network: None, id: BOB.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::execute( @@ -637,7 +645,7 @@ fn execute_withdraw_to_deposit_works() { fn trapped_assets_can_be_claimed() { let balances = vec![(ALICE, INITIAL_BALANCE), (BOB, INITIAL_BALANCE)]; new_test_ext_with_balances(balances).execute_with(|| { - let weight = 6 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 6; let dest: MultiLocation = Junction::AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::execute( @@ -664,7 +672,7 @@ fn trapped_assets_can_be_claimed() { vec![ RuntimeEvent::XcmPallet(crate::Event::AssetsTrapped(hash.clone(), source, vma)), RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete( - 5 * BaseXcmWeight::get() + BaseXcmWeight::get() * 5 ))) ] ); @@ -674,7 +682,7 @@ fn trapped_assets_can_be_claimed() { let expected = vec![(hash, 1u32)]; assert_eq!(trapped, expected); - let weight = 3 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 3; assert_ok!(XcmPallet::execute( RuntimeOrigin::signed(ALICE), Box::new(VersionedXcm::from(Xcm(vec![ @@ -689,7 +697,7 @@ fn trapped_assets_can_be_claimed() { assert_eq!(Balances::total_balance(&BOB), INITIAL_BALANCE + SEND_AMOUNT); assert_eq!(AssetTraps::::iter().collect::>(), vec![]); - let weight = 3 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 3; assert_ok!(XcmPallet::execute( RuntimeOrigin::signed(ALICE), Box::new(VersionedXcm::from(Xcm(vec![ @@ -742,7 +750,7 @@ fn basic_subscription_works() { take_sent_xcm(), vec![( remote.clone(), - Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: 0 }]), + Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: Weight::zero() }]), ),] ); @@ -751,7 +759,7 @@ fn basic_subscription_works() { // Remote supports XCM v2 QueryResponse { query_id: 0, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(1), querier: None, }, @@ -760,7 +768,7 @@ fn basic_subscription_works() { &remote, message.inner_mut(), weight, - &mut 0 + &mut Weight::zero(), )); }); } @@ -785,11 +793,17 @@ fn subscriptions_increment_id() { vec![ ( remote.clone(), - Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: 0 }]), + Xcm(vec![SubscribeVersion { + query_id: 0, + max_response_weight: Weight::zero() + }]), ), ( remote2.clone(), - Xcm(vec![SubscribeVersion { query_id: 1, max_response_weight: 0 }]), + Xcm(vec![SubscribeVersion { + query_id: 1, + max_response_weight: Weight::zero() + }]), ), ] ); @@ -839,7 +853,10 @@ fn unsubscribe_works() { vec![ ( remote.clone(), - Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: 0 }]), + Xcm(vec![SubscribeVersion { + query_id: 0, + max_response_weight: Weight::zero() + }]), ), (remote.clone(), Xcm(vec![UnsubscribeVersion]),), ] @@ -855,14 +872,15 @@ fn subscription_side_works() { let remote: MultiLocation = Parachain(1000).into(); let weight = BaseXcmWeight::get(); - let message = Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: 0 }]); + let message = + Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: Weight::zero() }]); let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm(remote.clone(), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); let instr = QueryResponse { query_id: 0, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(1), querier: None, }; @@ -881,7 +899,7 @@ fn subscription_side_works() { XcmPallet::on_initialize(2); let instr = QueryResponse { query_id: 0, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(2), querier: None, }; @@ -896,9 +914,9 @@ fn subscription_side_upgrades_work_with_notify() { // An entry from a previous runtime with v2 XCM. let v2_location = VersionedMultiLocation::V2(xcm::v2::Junction::Parachain(1001).into()); - VersionNotifyTargets::::insert(1, v2_location, (70, 0, 2)); + VersionNotifyTargets::::insert(1, v2_location, (70, Weight::zero(), 2)); let v3_location = Parachain(1003).into_versioned(); - VersionNotifyTargets::::insert(3, v3_location, (72, 0, 2)); + VersionNotifyTargets::::insert(3, v3_location, (72, Weight::zero(), 2)); // New version. AdvertisedXcmVersion::set(3); @@ -909,13 +927,13 @@ fn subscription_side_upgrades_work_with_notify() { let instr1 = QueryResponse { query_id: 70, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(3), querier: None, }; let instr3 = QueryResponse { query_id: 72, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(3), querier: None, }; @@ -933,12 +951,12 @@ fn subscription_side_upgrades_work_with_notify() { ); let mut contents = VersionNotifyTargets::::iter().collect::>(); - contents.sort_by_key(|k| k.2); + contents.sort_by_key(|k| k.2 .0); assert_eq!( contents, vec![ - (XCM_VERSION, Parachain(1001).into_versioned(), (70, 0, 3)), - (XCM_VERSION, Parachain(1003).into_versioned(), (72, 0, 3)), + (XCM_VERSION, Parachain(1001).into_versioned(), (70, Weight::zero(), 3)), + (XCM_VERSION, Parachain(1003).into_versioned(), (72, Weight::zero(), 3)), ] ); }); @@ -949,21 +967,21 @@ fn subscription_side_upgrades_work_without_notify() { new_test_ext_with_balances(vec![]).execute_with(|| { // An entry from a previous runtime with v2 XCM. let v2_location = VersionedMultiLocation::V2(xcm::v2::Junction::Parachain(1001).into()); - VersionNotifyTargets::::insert(1, v2_location, (70, 0, 2)); + VersionNotifyTargets::::insert(1, v2_location, (70, Weight::zero(), 2)); let v3_location = Parachain(1003).into_versioned(); - VersionNotifyTargets::::insert(3, v3_location, (72, 0, 2)); + VersionNotifyTargets::::insert(3, v3_location, (72, Weight::zero(), 2)); // A runtime upgrade which alters the version does send notifications. XcmPallet::on_runtime_upgrade(); XcmPallet::on_initialize(1); let mut contents = VersionNotifyTargets::::iter().collect::>(); - contents.sort_by_key(|k| k.2); + contents.sort_by_key(|k| k.2 .0); assert_eq!( contents, vec![ - (XCM_VERSION, Parachain(1001).into_versioned(), (70, 0, 3)), - (XCM_VERSION, Parachain(1003).into_versioned(), (72, 0, 3)), + (XCM_VERSION, Parachain(1001).into_versioned(), (70, Weight::zero(), 3)), + (XCM_VERSION, Parachain(1003).into_versioned(), (72, Weight::zero(), 3)), ] ); }); @@ -986,7 +1004,7 @@ fn subscriber_side_subscription_works() { // Remote supports XCM v2 QueryResponse { query_id: 0, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(1), querier: None, }, @@ -1004,7 +1022,7 @@ fn subscriber_side_subscription_works() { // Remote upgraded to XCM v2 QueryResponse { query_id: 0, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(2), querier: None, }, @@ -1056,7 +1074,7 @@ fn auto_subscription_works() { take_sent_xcm(), vec![( remote_v3.clone(), - Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: 0 }]), + Xcm(vec![SubscribeVersion { query_id: 0, max_response_weight: Weight::zero() }]), )] ); @@ -1067,7 +1085,7 @@ fn auto_subscription_works() { // Remote supports XCM v3 QueryResponse { query_id: 0, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(3), querier: None, }, @@ -1092,7 +1110,7 @@ fn auto_subscription_works() { take_sent_xcm(), vec![( remote_v2.clone(), - Xcm(vec![SubscribeVersion { query_id: 1, max_response_weight: 0 }]), + Xcm(vec![SubscribeVersion { query_id: 1, max_response_weight: Weight::zero() }]), )] ); @@ -1103,7 +1121,7 @@ fn auto_subscription_works() { // Remote supports XCM v2 QueryResponse { query_id: 1, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(2), querier: None, }, @@ -1128,11 +1146,11 @@ fn subscription_side_upgrades_work_with_multistage_notify() { // An entry from a previous runtime with v0 XCM. let v2_location = VersionedMultiLocation::V2(xcm::v2::Junction::Parachain(1001).into()); - VersionNotifyTargets::::insert(1, v2_location, (70, 0, 1)); + VersionNotifyTargets::::insert(1, v2_location, (70, Weight::zero(), 1)); let v2_location = VersionedMultiLocation::V2(xcm::v2::Junction::Parachain(1002).into()); - VersionNotifyTargets::::insert(2, v2_location, (71, 0, 1)); + VersionNotifyTargets::::insert(2, v2_location, (71, Weight::zero(), 1)); let v3_location = Parachain(1003).into_versioned(); - VersionNotifyTargets::::insert(3, v3_location, (72, 0, 1)); + VersionNotifyTargets::::insert(3, v3_location, (72, Weight::zero(), 1)); // New version. AdvertisedXcmVersion::set(3); @@ -1150,19 +1168,19 @@ fn subscription_side_upgrades_work_with_multistage_notify() { let instr1 = QueryResponse { query_id: 70, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(3), querier: None, }; let instr2 = QueryResponse { query_id: 71, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(3), querier: None, }; let instr3 = QueryResponse { query_id: 72, - max_weight: 0, + max_weight: Weight::zero(), response: Response::Version(3), querier: None, }; @@ -1181,13 +1199,13 @@ fn subscription_side_upgrades_work_with_multistage_notify() { ); let mut contents = VersionNotifyTargets::::iter().collect::>(); - contents.sort_by_key(|k| k.2); + contents.sort_by_key(|k| k.2 .0); assert_eq!( contents, vec![ - (XCM_VERSION, Parachain(1001).into_versioned(), (70, 0, 3)), - (XCM_VERSION, Parachain(1002).into_versioned(), (71, 0, 3)), - (XCM_VERSION, Parachain(1003).into_versioned(), (72, 0, 3)), + (XCM_VERSION, Parachain(1001).into_versioned(), (70, Weight::zero(), 3)), + (XCM_VERSION, Parachain(1002).into_versioned(), (71, Weight::zero(), 3)), + (XCM_VERSION, Parachain(1003).into_versioned(), (72, Weight::zero(), 3)), ] ); }); diff --git a/xcm/src/v2/junction.rs b/xcm/src/v2/junction.rs index 3a20e7b15c9d..45c48aa86a8e 100644 --- a/xcm/src/v2/junction.rs +++ b/xcm/src/v2/junction.rs @@ -20,7 +20,7 @@ use super::{BodyId, BodyPart, Junctions, MultiLocation, NetworkId}; use crate::v3::Junction as NewJunction; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_runtime::{traits::ConstU32, WeakBoundedVec}; +use sp_core::{bounded::WeakBoundedVec, ConstU32}; /// A single item in a path to describe the relative location of a consensus system. /// diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index d70a08185e28..9556edfbb8a8 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -53,7 +53,8 @@ use super::{ v3::{ BodyId as NewBodyId, BodyPart as NewBodyPart, Instruction as NewInstruction, - NetworkId as NewNetworkId, Response as NewResponse, Xcm as NewXcm, + NetworkId as NewNetworkId, Response as NewResponse, WeightLimit as NewWeightLimit, + Xcm as NewXcm, }, DoubleEncoded, GetWeight, }; @@ -62,7 +63,7 @@ use core::{fmt::Debug, result}; use derivative::Derivative; use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_runtime::{traits::ConstU32, WeakBoundedVec}; +use sp_core::{bounded::WeakBoundedVec, ConstU32}; mod junction; mod multiasset; @@ -380,6 +381,17 @@ impl From for Option { } } +impl TryFrom for WeightLimit { + type Error = (); + fn try_from(x: NewWeightLimit) -> result::Result { + use NewWeightLimit::*; + match x { + Limited(w) => Ok(Self::Limited(w.ref_time())), + Unlimited => Ok(Self::Unlimited), + } + } +} + /// Local weight type; execution time in picoseconds. pub type Weight = u64; @@ -885,48 +897,81 @@ impl Instruction { // TODO: Automate Generation impl> GetWeight for Instruction { - fn weight(&self) -> Weight { + fn weight(&self) -> sp_weights::Weight { use Instruction::*; match self { - WithdrawAsset(assets) => W::withdraw_asset(assets), - ReserveAssetDeposited(assets) => W::reserve_asset_deposited(assets), - ReceiveTeleportedAsset(assets) => W::receive_teleported_asset(assets), + WithdrawAsset(assets) => sp_weights::Weight::from_ref_time(W::withdraw_asset(assets)), + ReserveAssetDeposited(assets) => + sp_weights::Weight::from_ref_time(W::reserve_asset_deposited(assets)), + ReceiveTeleportedAsset(assets) => + sp_weights::Weight::from_ref_time(W::receive_teleported_asset(assets)), QueryResponse { query_id, response, max_weight } => - W::query_response(query_id, response, max_weight), - TransferAsset { assets, beneficiary } => W::transfer_asset(assets, beneficiary), + sp_weights::Weight::from_ref_time(W::query_response(query_id, response, max_weight)), + TransferAsset { assets, beneficiary } => + sp_weights::Weight::from_ref_time(W::transfer_asset(assets, beneficiary)), TransferReserveAsset { assets, dest, xcm } => - W::transfer_reserve_asset(&assets, dest, xcm), + sp_weights::Weight::from_ref_time(W::transfer_reserve_asset(&assets, dest, xcm)), Transact { origin_type, require_weight_at_most, call } => - W::transact(origin_type, require_weight_at_most, call), + sp_weights::Weight::from_ref_time(W::transact( + origin_type, + require_weight_at_most, + call, + )), HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => - W::hrmp_new_channel_open_request(sender, max_message_size, max_capacity), - HrmpChannelAccepted { recipient } => W::hrmp_channel_accepted(recipient), + sp_weights::Weight::from_ref_time(W::hrmp_new_channel_open_request( + sender, + max_message_size, + max_capacity, + )), + HrmpChannelAccepted { recipient } => + sp_weights::Weight::from_ref_time(W::hrmp_channel_accepted(recipient)), HrmpChannelClosing { initiator, sender, recipient } => - W::hrmp_channel_closing(initiator, sender, recipient), - ClearOrigin => W::clear_origin(), - DescendOrigin(who) => W::descend_origin(who), + sp_weights::Weight::from_ref_time(W::hrmp_channel_closing( + initiator, sender, recipient, + )), + ClearOrigin => sp_weights::Weight::from_ref_time(W::clear_origin()), + DescendOrigin(who) => sp_weights::Weight::from_ref_time(W::descend_origin(who)), ReportError { query_id, dest, max_response_weight } => - W::report_error(query_id, dest, max_response_weight), + sp_weights::Weight::from_ref_time(W::report_error( + query_id, + dest, + max_response_weight, + )), DepositAsset { assets, max_assets, beneficiary } => - W::deposit_asset(assets, max_assets, beneficiary), + sp_weights::Weight::from_ref_time(W::deposit_asset(assets, max_assets, beneficiary)), DepositReserveAsset { assets, max_assets, dest, xcm } => - W::deposit_reserve_asset(assets, max_assets, dest, xcm), - ExchangeAsset { give, receive } => W::exchange_asset(give, receive), - InitiateReserveWithdraw { assets, reserve, xcm } => + sp_weights::Weight::from_ref_time(W::deposit_reserve_asset( + assets, max_assets, dest, xcm, + )), + ExchangeAsset { give, receive } => + sp_weights::Weight::from_ref_time(W::exchange_asset(give, receive)), + InitiateReserveWithdraw { assets, reserve, xcm } => sp_weights::Weight::from_ref_time( W::initiate_reserve_withdraw(assets, reserve, xcm), - InitiateTeleport { assets, dest, xcm } => W::initiate_teleport(assets, dest, xcm), + ), + InitiateTeleport { assets, dest, xcm } => + sp_weights::Weight::from_ref_time(W::initiate_teleport(assets, dest, xcm)), QueryHolding { query_id, dest, assets, max_response_weight } => - W::query_holding(query_id, dest, assets, max_response_weight), - BuyExecution { fees, weight_limit } => W::buy_execution(fees, weight_limit), - RefundSurplus => W::refund_surplus(), - SetErrorHandler(xcm) => W::set_error_handler(xcm), - SetAppendix(xcm) => W::set_appendix(xcm), - ClearError => W::clear_error(), - ClaimAsset { assets, ticket } => W::claim_asset(assets, ticket), - Trap(code) => W::trap(code), + sp_weights::Weight::from_ref_time(W::query_holding( + query_id, + dest, + assets, + max_response_weight, + )), + BuyExecution { fees, weight_limit } => + sp_weights::Weight::from_ref_time(W::buy_execution(fees, weight_limit)), + RefundSurplus => sp_weights::Weight::from_ref_time(W::refund_surplus()), + SetErrorHandler(xcm) => sp_weights::Weight::from_ref_time(W::set_error_handler(xcm)), + SetAppendix(xcm) => sp_weights::Weight::from_ref_time(W::set_appendix(xcm)), + ClearError => sp_weights::Weight::from_ref_time(W::clear_error()), + ClaimAsset { assets, ticket } => + sp_weights::Weight::from_ref_time(W::claim_asset(assets, ticket)), + Trap(code) => sp_weights::Weight::from_ref_time(W::trap(code)), SubscribeVersion { query_id, max_response_weight } => - W::subscribe_version(query_id, max_response_weight), - UnsubscribeVersion => W::unsubscribe_version(), + sp_weights::Weight::from_ref_time(W::subscribe_version( + query_id, + max_response_weight, + )), + UnsubscribeVersion => sp_weights::Weight::from_ref_time(W::unsubscribe_version()), } } } @@ -975,8 +1020,11 @@ impl TryFrom> for Instruction Self::WithdrawAsset(assets.try_into()?), ReserveAssetDeposited(assets) => Self::ReserveAssetDeposited(assets.try_into()?), ReceiveTeleportedAsset(assets) => Self::ReceiveTeleportedAsset(assets.try_into()?), - QueryResponse { query_id, response, max_weight, .. } => - Self::QueryResponse { query_id, response: response.try_into()?, max_weight }, + QueryResponse { query_id, response, max_weight, .. } => Self::QueryResponse { + query_id, + response: response.try_into()?, + max_weight: max_weight.ref_time(), + }, TransferAsset { assets, beneficiary } => Self::TransferAsset { assets: assets.try_into()?, beneficiary: beneficiary.try_into()?, @@ -993,13 +1041,13 @@ impl TryFrom> for Instruction Self::Transact { origin_type: origin_kind, - require_weight_at_most, + require_weight_at_most: require_weight_at_most.ref_time(), call: call.into(), }, ReportError(response_info) => Self::ReportError { query_id: response_info.query_id, dest: response_info.destination.try_into()?, - max_response_weight: response_info.max_weight, + max_response_weight: response_info.max_weight.ref_time(), }, DepositAsset { assets, beneficiary } => { let max_assets = assets.count().ok_or(())?; @@ -1037,10 +1085,11 @@ impl TryFrom> for Instruction { let fees = fees.try_into()?; + let weight_limit = weight_limit.try_into()?; Self::BuyExecution { fees, weight_limit } }, ClearOrigin => Self::ClearOrigin, @@ -1055,8 +1104,10 @@ impl TryFrom> for Instruction Self::Trap(code), - SubscribeVersion { query_id, max_response_weight } => - Self::SubscribeVersion { query_id, max_response_weight }, + SubscribeVersion { query_id, max_response_weight } => Self::SubscribeVersion { + query_id, + max_response_weight: max_response_weight.ref_time(), + }, UnsubscribeVersion => Self::UnsubscribeVersion, _ => return Err(()), }) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 7369d4a9c20c..7b3478507dc7 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -16,7 +16,10 @@ //! Version 3 of the Cross-Consensus Message format data structures. -use super::v2::{Instruction as OldInstruction, Response as OldResponse, Xcm as OldXcm}; +use super::v2::{ + Instruction as OldInstruction, Response as OldResponse, WeightLimit as OldWeightLimit, + Xcm as OldXcm, +}; use crate::{DoubleEncoded, GetWeight}; use alloc::{vec, vec::Vec}; use core::{ @@ -48,7 +51,7 @@ pub use traits::{ SendResult, SendXcm, Unwrappable, Weight, XcmHash, }; // These parts of XCM v2 are unchanged in XCM v3, and are re-imported here. -pub use super::v2::{OriginKind, WeightLimit}; +pub use super::v2::OriginKind; /// This module's XCM version. pub const VERSION: super::Version = 3; @@ -325,10 +328,47 @@ pub struct QueryResponseInfo { #[codec(compact)] pub query_id: QueryId, /// The `max_weight` field of the `QueryResponse` message. - #[codec(compact)] pub max_weight: Weight, } +/// An optional weight limit. +#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] +pub enum WeightLimit { + /// No weight limit imposed. + Unlimited, + /// Weight limit imposed of the inner value. + Limited(Weight), +} + +impl From> for WeightLimit { + fn from(x: Option) -> Self { + match x { + Some(w) => WeightLimit::Limited(w), + None => WeightLimit::Unlimited, + } + } +} + +impl From for Option { + fn from(x: WeightLimit) -> Self { + match x { + WeightLimit::Limited(w) => Some(w), + WeightLimit::Unlimited => None, + } + } +} + +impl TryFrom for WeightLimit { + type Error = (); + fn try_from(x: OldWeightLimit) -> result::Result { + use OldWeightLimit::*; + match x { + Limited(w) => Ok(Self::Limited(Weight::from_parts(w, DEFAULT_PROOF_SIZE))), + Unlimited => Ok(Self::Unlimited), + } + } +} + /// Contextual data pertaining to a specific list of XCM instructions. #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug)] pub struct XcmContext { @@ -420,7 +460,6 @@ pub enum Instruction { #[codec(compact)] query_id: QueryId, response: Response, - #[codec(compact)] max_weight: Weight, querier: Option, }, @@ -473,12 +512,7 @@ pub enum Instruction { /// Kind: *Instruction*. /// /// Errors: - Transact { - origin_kind: OriginKind, - #[codec(compact)] - require_weight_at_most: u64, - call: DoubleEncoded, - }, + Transact { origin_kind: OriginKind, require_weight_at_most: Weight, call: DoubleEncoded }, /// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the /// relay-chain to a para. @@ -751,7 +785,6 @@ pub enum Instruction { SubscribeVersion { #[codec(compact)] query_id: QueryId, - #[codec(compact)] max_response_weight: Weight, }, @@ -1180,6 +1213,9 @@ impl TryFrom> for Xcm { } } +/// Default value for the proof size weight component. Set at 64 KB. +const DEFAULT_PROOF_SIZE: u64 = 64 * 1024; + // Convert from a v2 instruction to a v3 instruction. impl TryFrom> for Instruction { type Error = (); @@ -1192,7 +1228,7 @@ impl TryFrom> for Instruction { QueryResponse { query_id, response, max_weight } => Self::QueryResponse { query_id, response: response.try_into()?, - max_weight, + max_weight: Weight::from_parts(max_weight, DEFAULT_PROOF_SIZE), querier: None, }, TransferAsset { assets, beneficiary } => Self::TransferAsset { @@ -1211,14 +1247,17 @@ impl TryFrom> for Instruction { Self::HrmpChannelClosing { initiator, sender, recipient }, Transact { origin_type, require_weight_at_most, call } => Self::Transact { origin_kind: origin_type, - require_weight_at_most, + require_weight_at_most: Weight::from_parts( + require_weight_at_most, + DEFAULT_PROOF_SIZE, + ), call: call.into(), }, ReportError { query_id, dest, max_response_weight } => { let response_info = QueryResponseInfo { destination: dest.try_into()?, query_id, - max_weight: max_response_weight, + max_weight: Weight::from_parts(max_response_weight, DEFAULT_PROOF_SIZE), }; Self::ReportError(response_info) }, @@ -1249,12 +1288,14 @@ impl TryFrom> for Instruction { let response_info = QueryResponseInfo { destination: dest.try_into()?, query_id, - max_weight: max_response_weight, + max_weight: Weight::from_parts(max_response_weight, DEFAULT_PROOF_SIZE), }; Self::ReportHolding { response_info, assets: assets.try_into()? } }, - BuyExecution { fees, weight_limit } => - Self::BuyExecution { fees: fees.try_into()?, weight_limit }, + BuyExecution { fees, weight_limit } => Self::BuyExecution { + fees: fees.try_into()?, + weight_limit: weight_limit.try_into()?, + }, ClearOrigin => Self::ClearOrigin, DescendOrigin(who) => Self::DescendOrigin(who.try_into()?), RefundSurplus => Self::RefundSurplus, @@ -1267,8 +1308,10 @@ impl TryFrom> for Instruction { Self::ClaimAsset { assets, ticket } }, Trap(code) => Self::Trap(code), - SubscribeVersion { query_id, max_response_weight } => - Self::SubscribeVersion { query_id, max_response_weight }, + SubscribeVersion { query_id, max_response_weight } => Self::SubscribeVersion { + query_id, + max_response_weight: Weight::from_parts(max_response_weight, DEFAULT_PROOF_SIZE), + }, UnsubscribeVersion => Self::UnsubscribeVersion, }) } @@ -1323,7 +1366,10 @@ mod tests { let xcm = Xcm::<()>(vec![ ReserveAssetDeposited((Here, 1u128).into()), ClearOrigin, - BuyExecution { fees: (Here, 1u128).into(), weight_limit: Some(1).into() }, + BuyExecution { + fees: (Here, 1u128).into(), + weight_limit: Some(Weight::from_parts(1, DEFAULT_PROOF_SIZE)).into(), + }, DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Here.into() }, ]); let old_xcm = OldXcm::<()>(vec![ diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 5d657b3e65d5..4325eb272d19 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -21,6 +21,8 @@ use core::result; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +pub use sp_weights::Weight; + use super::*; #[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] @@ -205,9 +207,6 @@ impl From for Error { pub type Result = result::Result<(), Error>; -/// Local weight type; execution time in picoseconds. -pub type Weight = u64; - /// Outcome of an XCM execution. #[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] pub enum Outcome { @@ -239,7 +238,7 @@ impl Outcome { match self { Outcome::Complete(w) => *w, Outcome::Incomplete(w, _) => *w, - Outcome::Error(_) => 0, + Outcome::Error(_) => Weight::zero(), } } } @@ -276,7 +275,7 @@ pub trait ExecuteXcm { message, weight_limit, ); - Self::execute_xcm_in_credit(origin, message, hash, weight_limit, 0) + Self::execute_xcm_in_credit(origin, message, hash, weight_limit, Weight::zero()) } /// Execute some XCM `message` with the message `hash` from `origin` using no more than `weight_limit` weight. @@ -295,7 +294,7 @@ pub trait ExecuteXcm { Err(_) => return Outcome::Error(Error::WeightNotComputable), }; let xcm_weight = pre.weight_of(); - if xcm_weight > weight_limit { + if xcm_weight.any_gt(weight_limit) { return Outcome::Error(Error::WeightLimitReached(xcm_weight)) } Self::execute(origin, pre, hash, weight_credit) @@ -388,7 +387,7 @@ impl Unwrappable for Option { /// # Example /// ```rust /// # use parity_scale_codec::Encode; -/// # use xcm::v3::prelude::*; +/// # use xcm::v3::{prelude::*, Weight}; /// # use xcm::VersionedXcm; /// # use std::convert::Infallible; /// @@ -439,7 +438,7 @@ impl Unwrappable for Option { /// let call: Vec = ().encode(); /// let message = Xcm(vec![Instruction::Transact { /// origin_kind: OriginKind::Superuser, -/// require_weight_at_most: 0, +/// require_weight_at_most: Weight::zero(), /// call: call.into(), /// }]); /// let message_hash = message.using_encoded(sp_io::hashing::blake2_256); diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 7bb66917f1d9..e23065c09c83 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -49,7 +49,7 @@ impl ShouldExecute for TakeWeightCredit { "TakeWeightCredit origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", _origin, _instructions, max_weight, weight_credit, ); - *weight_credit = weight_credit.checked_sub(max_weight).ok_or(())?; + *weight_credit = weight_credit.checked_sub(&max_weight).ok_or(())?; Ok(()) } } @@ -91,8 +91,10 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionFro i = iter.next().ok_or(())?; } match i { - BuyExecution { weight_limit: Limited(ref mut weight), .. } if *weight >= max_weight => { - *weight = max_weight; + BuyExecution { weight_limit: Limited(ref mut weight), .. } + if weight.all_gte(max_weight) => + { + *weight = weight.max(max_weight); Ok(()) }, BuyExecution { ref mut weight_limit, .. } if weight_limit == &Unlimited => { @@ -240,7 +242,8 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF ); ensure!(T::contains(origin), ()); match instructions.first() { - Some(UnpaidExecution { weight_limit: Limited(m), .. }) if *m >= max_weight => Ok(()), + Some(UnpaidExecution { weight_limit: Limited(m), .. }) if m.all_gte(max_weight) => + Ok(()), Some(UnpaidExecution { weight_limit: Unlimited, .. }) => Ok(()), _ => Err(()), } diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index eabb46d62ffe..97b76a2eda06 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -31,7 +31,7 @@ pub use xcm_executor::{ }; parameter_types! { - pub static SubscriptionRequests: Vec<(MultiLocation, Option<(QueryId, u64)>)> = vec![]; + pub static SubscriptionRequests: Vec<(MultiLocation, Option<(QueryId, Weight)>)> = vec![]; pub static MaxAssetsIntoHolding: u32 = 4; } @@ -41,7 +41,7 @@ impl VersionChangeNotifier for TestSubscriptionService { fn start( location: &MultiLocation, query_id: QueryId, - max_weight: u64, + max_weight: Weight, _context: &XcmContext, ) -> XcmResult { let mut r = SubscriptionRequests::get(); @@ -73,7 +73,7 @@ impl DropAssets for TestAssetTrap { let mut t: Vec<(MultiLocation, MultiAssets)> = TrappedAssets::get(); t.push((origin.clone(), assets.into())); TrappedAssets::set(t); - 5 + Weight::from_parts(5, 5) } } diff --git a/xcm/xcm-builder/src/tests/assets.rs b/xcm/xcm-builder/src/tests/assets.rs index e78047988e04..b5b54cb6e9a5 100644 --- a/xcm/xcm-builder/src/tests/assets.rs +++ b/xcm/xcm-builder/src/tests/assets.rs @@ -33,8 +33,9 @@ fn exchange_asset_should_work() { }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parent, message, hash, 50); - assert_eq!(r, Outcome::Complete(40)); + let r = + XcmExecutor::::execute_xcm(Parent, message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(40, 40))); assert_eq!(asset_list(Parent), vec![(Here, 100u128).into(), (Parent, 950u128).into()]); assert_eq!(exchange_assets(), vec![(Parent, 50u128).into()].into()); } @@ -56,8 +57,9 @@ fn exchange_asset_without_maximal_should_work() { }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parent, message, hash, 50); - assert_eq!(r, Outcome::Complete(40)); + let r = + XcmExecutor::::execute_xcm(Parent, message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(40, 40))); assert_eq!(asset_list(Parent), vec![(Here, 50u128).into(), (Parent, 950u128).into()]); assert_eq!(exchange_assets(), vec![(Here, 50u128).into(), (Parent, 50u128).into()].into()); } @@ -79,8 +81,9 @@ fn exchange_asset_should_fail_when_no_deal_possible() { }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parent, message, hash, 50); - assert_eq!(r, Outcome::Incomplete(40, XcmError::NoDeal)); + let r = + XcmExecutor::::execute_xcm(Parent, message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(40, 40), XcmError::NoDeal)); assert_eq!(asset_list(Parent), vec![(Parent, 1000u128).into()]); assert_eq!(exchange_assets(), vec![(Here, 100u128).into()].into()); } @@ -94,13 +97,13 @@ fn paying_reserve_deposit_should_work() { let fees = (Parent, 30u128).into(); let message = Xcm(vec![ ReserveAssetDeposited((Parent, 100u128).into()), - BuyExecution { fees, weight_limit: Limited(30) }, + BuyExecution { fees, weight_limit: Limited(Weight::from_parts(30, 30)) }, DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); let hash = fake_message_hash(&message); - let weight_limit = 50; + let weight_limit = Weight::from_parts(50, 50); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(30)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(30, 30))); assert_eq!(asset_list(Here), vec![(Parent, 70u128).into()]); } @@ -116,8 +119,13 @@ fn transfer_should_work() { beneficiary: X1(AccountIndex64 { index: 3, network: None }).into(), }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); assert_eq!( asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 100u128).into()] @@ -145,8 +153,13 @@ fn reserve_transfer_should_work() { }]), }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); let expected_msg = Xcm::<()>(vec![ ReserveAssetDeposited((Parent, 100u128).into()), @@ -171,8 +184,13 @@ fn burn_should_work() { DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(30)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(30, 30))); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(sent_xcm(), vec![]); @@ -183,8 +201,13 @@ fn burn_should_work() { DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parachain(1).into() }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(30)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(30, 30))); assert_eq!(asset_list(Parachain(1)), vec![]); assert_eq!(sent_xcm(), vec![]); } @@ -205,8 +228,13 @@ fn basic_asset_trap_should_work() { }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); - assert_eq!(r, Outcome::Complete(25)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(20, 20), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(25, 25))); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); @@ -220,8 +248,13 @@ fn basic_asset_trap_should_work() { ]); let hash = fake_message_hash(&message); let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); - assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(20, 20), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::UnknownClaim)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); @@ -236,8 +269,13 @@ fn basic_asset_trap_should_work() { ]); let hash = fake_message_hash(&message); let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm(Parachain(2), message, hash, 20); - assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); + let r = XcmExecutor::::execute_xcm( + Parachain(2), + message, + hash, + Weight::from_parts(20, 20), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::UnknownClaim)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); @@ -252,8 +290,13 @@ fn basic_asset_trap_should_work() { ]); let hash = fake_message_hash(&message); let old_trapped_assets = TrappedAssets::get(); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); - assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(20, 20), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::UnknownClaim)); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![]); assert_eq!(old_trapped_assets, TrappedAssets::get()); @@ -266,8 +309,13 @@ fn basic_asset_trap_should_work() { }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); - assert_eq!(r, Outcome::Complete(20)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(20, 20), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(20, 20))); assert_eq!(asset_list(Parachain(1)), vec![(Here, 900u128).into()]); assert_eq!( asset_list(AccountIndex64 { index: 3, network: None }), @@ -283,8 +331,13 @@ fn basic_asset_trap_should_work() { }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 20); - assert_eq!(r, Outcome::Incomplete(10, XcmError::UnknownClaim)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(20, 20), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::UnknownClaim)); } #[test] @@ -314,8 +367,13 @@ fn max_assets_limit_should_work() { WithdrawAsset(([8u8; 32], 100u128).into()), ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 100); - assert_eq!(r, Outcome::Complete(85)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(100, 100), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(85, 85))); // Attempt to withdraw 9 different assets will fail. let message = Xcm(vec![ @@ -330,8 +388,13 @@ fn max_assets_limit_should_work() { WithdrawAsset(([9u8; 32], 100u128).into()), ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 100); - assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(100, 100), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(95, 95), XcmError::HoldingWouldOverflow)); // Attempt to withdraw 4 different assets and then the same 4 and then a different 4 will succeed. let message = Xcm(vec![ @@ -349,8 +412,13 @@ fn max_assets_limit_should_work() { WithdrawAsset(([8u8; 32], 100u128).into()), ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 200); - assert_eq!(r, Outcome::Complete(125)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(200, 200), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(125, 125))); // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. let message = Xcm(vec![ @@ -368,8 +436,13 @@ fn max_assets_limit_should_work() { WithdrawAsset(([4u8; 32], 100u128).into()), ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 200); - assert_eq!(r, Outcome::Incomplete(95, XcmError::HoldingWouldOverflow)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(200, 200), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(95, 95), XcmError::HoldingWouldOverflow)); // Attempt to withdraw 4 different assets and then a different 4 and then the same 4 will fail. let message = Xcm(vec![ @@ -386,6 +459,11 @@ fn max_assets_limit_should_work() { WithdrawAsset(([1u8; 32], 100u128).into()), ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 200); - assert_eq!(r, Outcome::Incomplete(25, XcmError::HoldingWouldOverflow)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(200, 200), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(25, 25), XcmError::HoldingWouldOverflow)); } diff --git a/xcm/xcm-builder/src/tests/barriers.rs b/xcm/xcm-builder/src/tests/barriers.rs index b3cfaa48f0f5..ea9078a892f5 100644 --- a/xcm/xcm-builder/src/tests/barriers.rs +++ b/xcm/xcm-builder/src/tests/barriers.rs @@ -20,24 +20,24 @@ use super::*; fn take_weight_credit_barrier_should_work() { let mut message = Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); - let mut weight_credit = 10; + let mut weight_credit = Weight::from_parts(10, 10); let r = TakeWeightCredit::should_execute( &Parent.into(), message.inner_mut(), - 10, + Weight::from_parts(10, 10), &mut weight_credit, ); assert_eq!(r, Ok(())); - assert_eq!(weight_credit, 0); + assert_eq!(weight_credit, Weight::zero()); let r = TakeWeightCredit::should_execute( &Parent.into(), message.inner_mut(), - 10, + Weight::from_parts(10, 10), &mut weight_credit, ); assert_eq!(r, Err(())); - assert_eq!(weight_credit, 0); + assert_eq!(weight_credit, Weight::zero()); } #[test] @@ -47,7 +47,10 @@ fn computed_origin_should_work() { DescendOrigin(Parachain(100).into()), DescendOrigin(PalletInstance(69).into()), WithdrawAsset((Parent, 100).into()), - BuyExecution { fees: (Parent, 100).into(), weight_limit: Limited(100) }, + BuyExecution { + fees: (Parent, 100).into(), + weight_limit: Limited(Weight::from_parts(100, 100)), + }, TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, ]); @@ -63,8 +66,8 @@ fn computed_origin_should_work() { let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parent.into(), message.inner_mut(), - 100, - &mut 0, + Weight::from_parts(100, 100), + &mut Weight::zero(), ); assert_eq!(r, Err(())); @@ -72,14 +75,24 @@ fn computed_origin_should_work() { AllowTopLevelPaidExecutionFrom>, ExecutorUniversalLocation, ConstU32<2>, - >::should_execute(&Parent.into(), message.inner_mut(), 100, &mut 0); + >::should_execute( + &Parent.into(), + message.inner_mut(), + Weight::from_parts(100, 100), + &mut Weight::zero(), + ); assert_eq!(r, Err(())); let r = WithComputedOrigin::< AllowTopLevelPaidExecutionFrom>, ExecutorUniversalLocation, ConstU32<5>, - >::should_execute(&Parent.into(), message.inner_mut(), 100, &mut 0); + >::should_execute( + &Parent.into(), + message.inner_mut(), + Weight::from_parts(100, 100), + &mut Weight::zero(), + ); assert_eq!(r, Ok(())); } @@ -93,16 +106,16 @@ fn allow_unpaid_should_work() { let r = AllowUnpaidExecutionFrom::>::should_execute( &Parachain(1).into(), message.inner_mut(), - 10, - &mut 0, + Weight::from_parts(10, 10), + &mut Weight::zero(), ); assert_eq!(r, Err(())); let r = AllowUnpaidExecutionFrom::>::should_execute( &Parent.into(), message.inner_mut(), - 10, - &mut 0, + Weight::from_parts(10, 10), + &mut Weight::zero(), ); assert_eq!(r, Ok(())); } @@ -113,12 +126,18 @@ fn allow_explicit_unpaid_should_work() { Xcm::<()>(vec![TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }]); let mut bad_message2 = Xcm::<()>(vec![ - UnpaidExecution { weight_limit: Limited(10), check_origin: Some(Parent.into()) }, + UnpaidExecution { + weight_limit: Limited(Weight::from_parts(10, 10)), + check_origin: Some(Parent.into()), + }, TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, ]); let mut good_message = Xcm::<()>(vec![ - UnpaidExecution { weight_limit: Limited(20), check_origin: Some(Parent.into()) }, + UnpaidExecution { + weight_limit: Limited(Weight::from_parts(20, 20)), + check_origin: Some(Parent.into()), + }, TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, ]); @@ -127,32 +146,32 @@ fn allow_explicit_unpaid_should_work() { let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( &Parachain(1).into(), good_message.inner_mut(), - 20, - &mut 0, + Weight::from_parts(20, 20), + &mut Weight::zero(), ); assert_eq!(r, Err(())); let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( &Parent.into(), bad_message1.inner_mut(), - 20, - &mut 0, + Weight::from_parts(20, 20), + &mut Weight::zero(), ); assert_eq!(r, Err(())); let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( &Parent.into(), bad_message2.inner_mut(), - 20, - &mut 0, + Weight::from_parts(20, 20), + &mut Weight::zero(), ); assert_eq!(r, Err(())); let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( &Parent.into(), good_message.inner_mut(), - 20, - &mut 0, + Weight::from_parts(20, 20), + &mut Weight::zero(), ); assert_eq!(r, Ok(())); } @@ -167,46 +186,46 @@ fn allow_paid_should_work() { let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parachain(1).into(), message.inner_mut(), - 10, - &mut 0, + Weight::from_parts(10, 10), + &mut Weight::zero(), ); assert_eq!(r, Err(())); let fees = (Parent, 1).into(); let mut underpaying_message = Xcm::<()>(vec![ ReserveAssetDeposited((Parent, 100).into()), - BuyExecution { fees, weight_limit: Limited(20) }, + BuyExecution { fees, weight_limit: Limited(Weight::from_parts(20, 20)) }, DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parent.into(), underpaying_message.inner_mut(), - 30, - &mut 0, + Weight::from_parts(30, 30), + &mut Weight::zero(), ); assert_eq!(r, Err(())); let fees = (Parent, 1).into(); let mut paying_message = Xcm::<()>(vec![ ReserveAssetDeposited((Parent, 100).into()), - BuyExecution { fees, weight_limit: Limited(30) }, + BuyExecution { fees, weight_limit: Limited(Weight::from_parts(30, 30)) }, DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parachain(1).into(), paying_message.inner_mut(), - 30, - &mut 0, + Weight::from_parts(30, 30), + &mut Weight::zero(), ); assert_eq!(r, Err(())); let r = AllowTopLevelPaidExecutionFrom::>::should_execute( &Parent.into(), paying_message.inner_mut(), - 30, - &mut 0, + Weight::from_parts(30, 30), + &mut Weight::zero(), ); assert_eq!(r, Ok(())); } diff --git a/xcm/xcm-builder/src/tests/basic.rs b/xcm/xcm-builder/src/tests/basic.rs index ea378e849873..6a821e22b66a 100644 --- a/xcm/xcm-builder/src/tests/basic.rs +++ b/xcm/xcm-builder/src/tests/basic.rs @@ -42,10 +42,16 @@ fn basic_setup_works() { fn weigher_should_work() { let mut message = Xcm(vec![ ReserveAssetDeposited((Parent, 100u128).into()), - BuyExecution { fees: (Parent, 1u128).into(), weight_limit: Limited(30) }, + BuyExecution { + fees: (Parent, 1u128).into(), + weight_limit: Limited(Weight::from_parts(30, 30)), + }, DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, ]); - assert_eq!(::Weigher::weight(&mut message), Ok(30)); + assert_eq!( + ::Weigher::weight(&mut message), + Ok(Weight::from_parts(30, 30)) + ); } #[test] @@ -82,18 +88,18 @@ fn code_registers_should_work() { ]); // Weight limit of 70 is needed. let limit = ::Weigher::weight(&mut message).unwrap(); - assert_eq!(limit, 70); + assert_eq!(limit, Weight::from_parts(70, 70)); let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm(Here, message.clone(), hash, limit); - assert_eq!(r, Outcome::Complete(50)); // We don't pay the 20 weight for the error handler. + assert_eq!(r, Outcome::Complete(Weight::from_parts(50, 50))); // We don't pay the 20 weight for the error handler. assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 13u128).into()]); assert_eq!(asset_list(Here), vec![(Here, 8u128).into()]); assert_eq!(sent_xcm(), vec![]); let r = XcmExecutor::::execute_xcm(Here, message, hash, limit); - assert_eq!(r, Outcome::Complete(70)); // We pay the full weight here. + assert_eq!(r, Outcome::Complete(Weight::from_parts(70, 70))); // We pay the full weight here. assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 20u128).into()]); assert_eq!(asset_list(Here), vec![(Here, 1u128).into()]); assert_eq!(sent_xcm(), vec![]); diff --git a/xcm/xcm-builder/src/tests/bridging/mod.rs b/xcm/xcm-builder/src/tests/bridging/mod.rs index aac51f228b0d..c06e5afceb13 100644 --- a/xcm/xcm-builder/src/tests/bridging/mod.rs +++ b/xcm/xcm-builder/src/tests/bridging/mod.rs @@ -133,8 +133,12 @@ impl, Remote: Get, RemoteExporter: ExportXcm> S set_exporter_override(price::, deliver::); // The we execute it: let hash = fake_message_hash(&message); - let outcome = - XcmExecutor::::execute_xcm(origin, message.into(), hash, 2_000_000_000_000); + let outcome = XcmExecutor::::execute_xcm( + origin, + message.into(), + hash, + Weight::from_parts(2_000_000_000_000, 2_000_000_000_000), + ); match outcome { Outcome::Complete(..) => Ok(hash), Outcome::Incomplete(..) => Err(Transport("Error executing")), @@ -174,8 +178,12 @@ impl, Remote: Get, RemoteExporter: ExportXcm> S set_exporter_override(price::, deliver::); // The we execute it: let hash = fake_message_hash(&message); - let outcome = - XcmExecutor::::execute_xcm(origin, message.into(), hash, 2_000_000_000_000); + let outcome = XcmExecutor::::execute_xcm( + origin, + message.into(), + hash, + Weight::from_parts(2_000_000_000_000, 2_000_000_000_000), + ); match outcome { Outcome::Complete(..) => Ok(hash), Outcome::Incomplete(..) => Err(Transport("Error executing")), diff --git a/xcm/xcm-builder/src/tests/expecting.rs b/xcm/xcm-builder/src/tests/expecting.rs index 33830a721e05..b93b73224dcc 100644 --- a/xcm/xcm-builder/src/tests/expecting.rs +++ b/xcm/xcm-builder/src/tests/expecting.rs @@ -29,8 +29,13 @@ fn expect_pallet_should_work() { min_crate_minor: 42, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); let message = Xcm(vec![ExpectPallet { index: 1, @@ -40,8 +45,13 @@ fn expect_pallet_should_work() { min_crate_minor: 41, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); } #[test] @@ -55,8 +65,13 @@ fn expect_pallet_should_fail_correctly() { min_crate_minor: 60, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::VersionIncompatible)); let message = Xcm(vec![ExpectPallet { index: 1, @@ -66,8 +81,13 @@ fn expect_pallet_should_fail_correctly() { min_crate_minor: 42, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::NameMismatch)); let message = Xcm(vec![ExpectPallet { index: 1, @@ -77,8 +97,13 @@ fn expect_pallet_should_fail_correctly() { min_crate_minor: 42, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::NameMismatch)); let message = Xcm(vec![ExpectPallet { index: 0, @@ -88,8 +113,13 @@ fn expect_pallet_should_fail_correctly() { min_crate_minor: 42, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NameMismatch)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::NameMismatch)); let message = Xcm(vec![ExpectPallet { index: 2, @@ -99,8 +129,13 @@ fn expect_pallet_should_fail_correctly() { min_crate_minor: 42, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::PalletNotFound)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::PalletNotFound)); let message = Xcm(vec![ExpectPallet { index: 1, @@ -110,8 +145,13 @@ fn expect_pallet_should_fail_correctly() { min_crate_minor: 42, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::VersionIncompatible)); let message = Xcm(vec![ExpectPallet { index: 1, @@ -121,8 +161,13 @@ fn expect_pallet_should_fail_correctly() { min_crate_minor: 42, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::VersionIncompatible)); let message = Xcm(vec![ExpectPallet { index: 1, @@ -132,6 +177,11 @@ fn expect_pallet_should_fail_correctly() { min_crate_minor: 43, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::VersionIncompatible)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::VersionIncompatible)); } diff --git a/xcm/xcm-builder/src/tests/locking.rs b/xcm/xcm-builder/src/tests/locking.rs index 9f58936faa39..f226c1bb5766 100644 --- a/xcm/xcm-builder/src/tests/locking.rs +++ b/xcm/xcm-builder/src/tests/locking.rs @@ -35,8 +35,9 @@ fn lock_roundtrip_should_work() { LockAsset { asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into() }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); - assert_eq!(r, Outcome::Complete(40)); + let r = + XcmExecutor::::execute_xcm((3u64,), message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(40, 40))); assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); let expected_msg = Xcm::<()>(vec![NoteUnlockable { @@ -58,8 +59,13 @@ fn lock_roundtrip_should_work() { let message = Xcm(vec![UnlockAsset { asset: (Parent, 100u128).into(), target: (3u64,).into() }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((Parent, Parachain(1)), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + (Parent, Parachain(1)), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); } #[test] @@ -77,8 +83,9 @@ fn auto_fee_paying_should_work() { LockAsset { asset: (Parent, 100u128).into(), unlocker: (Parent, Parachain(1)).into() }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); - assert_eq!(r, Outcome::Complete(20)); + let r = + XcmExecutor::::execute_xcm((3u64,), message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(20, 20))); assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); } @@ -94,8 +101,9 @@ fn lock_should_fail_correctly() { unlocker: (Parent, Parachain(1)).into(), }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::LockError)); + let r = + XcmExecutor::::execute_xcm((3u64,), message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::LockError)); assert_eq!(sent_xcm(), vec![]); assert_eq!(take_lock_trace(), vec![]); @@ -111,8 +119,9 @@ fn lock_should_fail_correctly() { unlocker: (Parent, Parachain(1)).into(), }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NotHoldingFees)); + let r = + XcmExecutor::::execute_xcm((3u64,), message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::NotHoldingFees)); assert_eq!(sent_xcm(), vec![]); assert_eq!(take_lock_trace(), vec![]); } @@ -130,8 +139,13 @@ fn remote_unlock_roundtrip_should_work() { let message = Xcm(vec![NoteUnlockable { asset: (Parent, 100u128).into(), owner: (3u64,).into() }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((Parent, Parachain(1)), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + (Parent, Parachain(1)), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); assert_eq!( take_lock_trace(), vec![Note { @@ -150,8 +164,9 @@ fn remote_unlock_roundtrip_should_work() { RequestUnlock { asset: (Parent, 100u128).into(), locker: (Parent, Parachain(1)).into() }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); - assert_eq!(r, Outcome::Complete(40)); + let r = + XcmExecutor::::execute_xcm((3u64,), message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(40, 40))); assert_eq!(asset_list((3u64,)), vec![(Parent, 990u128).into()]); let expected_msg = @@ -183,8 +198,9 @@ fn remote_unlock_should_fail_correctly() { locker: (Parent, Parachain(1)).into(), }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::LockError)); + let r = + XcmExecutor::::execute_xcm((3u64,), message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::LockError)); assert_eq!(sent_xcm(), vec![]); assert_eq!(take_lock_trace(), vec![]); @@ -192,8 +208,13 @@ fn remote_unlock_should_fail_correctly() { let message = Xcm(vec![NoteUnlockable { asset: (Parent, 100u128).into(), owner: (3u64,).into() }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((Parent, Parachain(1)), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + (Parent, Parachain(1)), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); let _discard = take_lock_trace(); // We want to unlock 100 of the native parent tokens which were locked for us on parachain. @@ -204,8 +225,9 @@ fn remote_unlock_should_fail_correctly() { locker: (Parent, Parachain(1)).into(), }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm((3u64,), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NotHoldingFees)); + let r = + XcmExecutor::::execute_xcm((3u64,), message, hash, Weight::from_parts(50, 50)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::NotHoldingFees)); assert_eq!(sent_xcm(), vec![]); assert_eq!(take_lock_trace(), vec![]); diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index 46590b08f679..eb7fd9491c29 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -77,8 +77,7 @@ impl Dispatchable for TestCall { TestCall::OnlyParachain(_, maybe_actual, _) | TestCall::Any(_, maybe_actual) => maybe_actual, }; - post_info.actual_weight = - maybe_actual.map(|x| frame_support::weights::Weight::from_ref_time(x)); + post_info.actual_weight = maybe_actual; if match (&origin, &self) { (TestOrigin::Parachain(i), TestCall::OnlyParachain(_, _, Some(j))) => i == j, (TestOrigin::Signed(i), TestCall::OnlySigned(_, _, Some(j))) => i == j, @@ -103,10 +102,7 @@ impl GetDispatchInfo for TestCall { TestCall::OnlySigned(estimate, ..) | TestCall::Any(estimate, ..) => estimate, }; - DispatchInfo { - weight: frame_support::weights::Weight::from_ref_time(weight), - ..Default::default() - } + DispatchInfo { weight, ..Default::default() } } } @@ -390,7 +386,7 @@ impl OnResponse for TestResponseHandler { } }); }); - 10 + Weight::from_parts(10, 10) } } pub fn expect_response(query_id: u64, from: MultiLocation) { @@ -408,7 +404,7 @@ pub fn response(query_id: u64) -> Option { parameter_types! { pub static ExecutorUniversalLocation: InteriorMultiLocation = (ByGenesis([0; 32]), Parachain(42)).into(); - pub UnitWeightCost: u64 = 10; + pub UnitWeightCost: Weight = Weight::from_parts(10, 10); } parameter_types! { // Nothing is allowed to be paid/unpaid by default. diff --git a/xcm/xcm-builder/src/tests/origins.rs b/xcm/xcm-builder/src/tests/origins.rs index 6ae3397492fe..a7454a4f423e 100644 --- a/xcm/xcm-builder/src/tests/origins.rs +++ b/xcm/xcm-builder/src/tests/origins.rs @@ -30,16 +30,26 @@ fn universal_origin_should_work() { TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(2), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::InvalidLocation)); + let r = XcmExecutor::::execute_xcm( + Parachain(2), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::InvalidLocation)); let message = Xcm(vec![ UniversalOrigin(GlobalConsensus(Kusama)), TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(20, 20), XcmError::NotWithdrawable)); add_asset((Ancestor(2), GlobalConsensus(Kusama)), (Parent, 100)); let message = Xcm(vec![ @@ -47,8 +57,13 @@ fn universal_origin_should_work() { TransferAsset { assets: (Parent, 100u128).into(), beneficiary: Here.into() }, ]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(20)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(20, 20))); assert_eq!(asset_list((Ancestor(2), GlobalConsensus(Kusama))), vec![]); } @@ -69,8 +84,13 @@ fn export_message_should_work() { xcm: expected_message.clone(), }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); let uni_src = (ByGenesis([0; 32]), Parachain(42), Parachain(1)).into(); assert_eq!( exported_xcm(), @@ -87,19 +107,34 @@ fn unpaid_execution_should_work() { AllowExplicitUnpaidFrom::set(vec![X1(Parachain(2)).into()]); // Asking for unpaid execution of up to 9 weight on the assumption it is origin of #2. let message = Xcm(vec![UnpaidExecution { - weight_limit: Limited(9), + weight_limit: Limited(Weight::from_parts(9, 9)), check_origin: Some(Parachain(2).into()), }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message.clone(), hash, 50); - assert_eq!(r, Outcome::Incomplete(10, XcmError::BadOrigin)); - let r = XcmExecutor::::execute_xcm(Parachain(2), message.clone(), hash, 50); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message.clone(), + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::BadOrigin)); + let r = XcmExecutor::::execute_xcm( + Parachain(2), + message.clone(), + hash, + Weight::from_parts(50, 50), + ); assert_eq!(r, Outcome::Error(XcmError::Barrier)); let message = Xcm(vec![UnpaidExecution { - weight_limit: Limited(10), + weight_limit: Limited(Weight::from_parts(10, 10)), check_origin: Some(Parachain(2).into()), }]); - let r = XcmExecutor::::execute_xcm(Parachain(2), message.clone(), hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + Parachain(2), + message.clone(), + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); } diff --git a/xcm/xcm-builder/src/tests/querying.rs b/xcm/xcm-builder/src/tests/querying.rs index 43b3235cbaca..014bbe713cf9 100644 --- a/xcm/xcm-builder/src/tests/querying.rs +++ b/xcm/xcm-builder/src/tests/querying.rs @@ -26,16 +26,21 @@ fn pallet_query_should_work() { response_info: QueryResponseInfo { destination: Parachain(1).into(), query_id: 1, - max_weight: 50, + max_weight: Weight::from_parts(50, 50), }, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); let expected_msg = Xcm::<()>(vec![QueryResponse { query_id: 1, - max_weight: 50, + max_weight: Weight::from_parts(50, 50), response: Response::PalletsInfo(vec![].try_into().unwrap()), querier: Some(Here.into()), }]); @@ -53,16 +58,21 @@ fn pallet_query_with_results_should_work() { response_info: QueryResponseInfo { destination: Parachain(1).into(), query_id: 1, - max_weight: 50, + max_weight: Weight::from_parts(50, 50), }, }]); let hash = fake_message_hash(&message); - let r = XcmExecutor::::execute_xcm(Parachain(1), message, hash, 50); - assert_eq!(r, Outcome::Complete(10)); + let r = XcmExecutor::::execute_xcm( + Parachain(1), + message, + hash, + Weight::from_parts(50, 50), + ); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); let expected_msg = Xcm::<()>(vec![QueryResponse { query_id: 1, - max_weight: 50, + max_weight: Weight::from_parts(50, 50), response: Response::PalletsInfo( vec![PalletInfo::new( 1, @@ -92,15 +102,15 @@ fn prepaid_result_of_query_should_get_free_execution() { let message = Xcm::(vec![QueryResponse { query_id, response: the_response.clone(), - max_weight: 10, + max_weight: Weight::from_parts(10, 10), querier: Some(Here.into()), }]); let hash = fake_message_hash(&message); - let weight_limit = 10; + let weight_limit = Weight::from_parts(10, 10); // First time the response gets through since we're expecting it... let r = XcmExecutor::::execute_xcm(Parent, message.clone(), hash, weight_limit); - assert_eq!(r, Outcome::Complete(10)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); assert_eq!(response(query_id).unwrap(), the_response); // Second time it doesn't, since we're not. diff --git a/xcm/xcm-builder/src/tests/transacting.rs b/xcm/xcm-builder/src/tests/transacting.rs index 4528cef2202b..972ce61a78c2 100644 --- a/xcm/xcm-builder/src/tests/transacting.rs +++ b/xcm/xcm-builder/src/tests/transacting.rs @@ -22,13 +22,13 @@ fn transacting_should_work() { let message = Xcm::(vec![Transact { origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::Any(50, None).encode().into(), + require_weight_at_most: Weight::from_parts(50, 50), + call: TestCall::Any(Weight::from_parts(50, 50), None).encode().into(), }]); let hash = fake_message_hash(&message); - let weight_limit = 60; + let weight_limit = Weight::from_parts(60, 60); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(60)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(60, 60))); } #[test] @@ -37,13 +37,13 @@ fn transacting_should_respect_max_weight_requirement() { let message = Xcm::(vec![Transact { origin_kind: OriginKind::Native, - require_weight_at_most: 40, - call: TestCall::Any(50, None).encode().into(), + require_weight_at_most: Weight::from_parts(40, 40), + call: TestCall::Any(Weight::from_parts(50, 50), None).encode().into(), }]); let hash = fake_message_hash(&message); - let weight_limit = 60; + let weight_limit = Weight::from_parts(60, 60); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Incomplete(50, XcmError::MaxWeightInvalid)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(50, 50), XcmError::MaxWeightInvalid)); } #[test] @@ -52,13 +52,15 @@ fn transacting_should_refund_weight() { let message = Xcm::(vec![Transact { origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::Any(50, Some(30)).encode().into(), + require_weight_at_most: Weight::from_parts(50, 50), + call: TestCall::Any(Weight::from_parts(50, 50), Some(Weight::from_parts(30, 30))) + .encode() + .into(), }]); let hash = fake_message_hash(&message); - let weight_limit = 60; + let weight_limit = Weight::from_parts(60, 60); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(40)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(40, 40))); } #[test] @@ -72,20 +74,22 @@ fn paid_transacting_should_refund_payment_for_unused_weight() { let fees = (Parent, 100u128).into(); let message = Xcm::(vec![ WithdrawAsset((Parent, 100u128).into()), // enough for 100 units of weight. - BuyExecution { fees, weight_limit: Limited(100) }, + BuyExecution { fees, weight_limit: Limited(Weight::from_parts(100, 100)) }, Transact { origin_kind: OriginKind::Native, - require_weight_at_most: 50, + require_weight_at_most: Weight::from_parts(50, 50), // call estimated at 50 but only takes 10. - call: TestCall::Any(50, Some(10)).encode().into(), + call: TestCall::Any(Weight::from_parts(50, 50), Some(Weight::from_parts(10, 10))) + .encode() + .into(), }, RefundSurplus, DepositAsset { assets: AllCounted(1).into(), beneficiary: one.clone() }, ]); let hash = fake_message_hash(&message); - let weight_limit = 100; + let weight_limit = Weight::from_parts(100, 100); let r = XcmExecutor::::execute_xcm(origin, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(60)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(60, 60))); assert_eq!( asset_list(AccountIndex64 { index: 1, network: None }), vec![(Parent, 40u128).into()] @@ -99,23 +103,23 @@ fn report_successful_transact_status_should_work() { let message = Xcm::(vec![ Transact { origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::Any(50, None).encode().into(), + require_weight_at_most: Weight::from_parts(50, 50), + call: TestCall::Any(Weight::from_parts(50, 50), None).encode().into(), }, ReportTransactStatus(QueryResponseInfo { destination: Parent.into(), query_id: 42, - max_weight: 5000, + max_weight: Weight::from_parts(5000, 5000), }), ]); let hash = fake_message_hash(&message); - let weight_limit = 70; + let weight_limit = Weight::from_parts(70, 70); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(70)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(70, 70))); let expected_msg = Xcm(vec![QueryResponse { response: Response::DispatchResult(MaybeErrorCode::Success), query_id: 42, - max_weight: 5000, + max_weight: Weight::from_parts(5000, 5000), querier: Some(Here.into()), }]); let expected_hash = fake_message_hash(&expected_msg); @@ -129,23 +133,23 @@ fn report_failed_transact_status_should_work() { let message = Xcm::(vec![ Transact { origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::OnlyRoot(50, None).encode().into(), + require_weight_at_most: Weight::from_parts(50, 50), + call: TestCall::OnlyRoot(Weight::from_parts(50, 50), None).encode().into(), }, ReportTransactStatus(QueryResponseInfo { destination: Parent.into(), query_id: 42, - max_weight: 5000, + max_weight: Weight::from_parts(5000, 5000), }), ]); let hash = fake_message_hash(&message); - let weight_limit = 70; + let weight_limit = Weight::from_parts(70, 70); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(70)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(70, 70))); let expected_msg = Xcm(vec![QueryResponse { response: Response::DispatchResult(MaybeErrorCode::Error(vec![2])), query_id: 42, - max_weight: 5000, + max_weight: Weight::from_parts(5000, 5000), querier: Some(Here.into()), }]); let expected_hash = fake_message_hash(&expected_msg); @@ -159,24 +163,24 @@ fn clear_transact_status_should_work() { let message = Xcm::(vec![ Transact { origin_kind: OriginKind::Native, - require_weight_at_most: 50, - call: TestCall::OnlyRoot(50, None).encode().into(), + require_weight_at_most: Weight::from_parts(50, 50), + call: TestCall::OnlyRoot(Weight::from_parts(50, 50), None).encode().into(), }, ClearTransactStatus, ReportTransactStatus(QueryResponseInfo { destination: Parent.into(), query_id: 42, - max_weight: 5000, + max_weight: Weight::from_parts(5000, 5000), }), ]); let hash = fake_message_hash(&message); - let weight_limit = 80; + let weight_limit = Weight::from_parts(80, 80); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(80)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(80, 80))); let expected_msg = Xcm(vec![QueryResponse { response: Response::DispatchResult(MaybeErrorCode::Success), query_id: 42, - max_weight: 5000, + max_weight: Weight::from_parts(5000, 5000), querier: Some(Here.into()), }]); let expected_hash = fake_message_hash(&expected_msg); diff --git a/xcm/xcm-builder/src/tests/version_subscriptions.rs b/xcm/xcm-builder/src/tests/version_subscriptions.rs index e7125e6e75a5..4aba90c2c82f 100644 --- a/xcm/xcm-builder/src/tests/version_subscriptions.rs +++ b/xcm/xcm-builder/src/tests/version_subscriptions.rs @@ -23,25 +23,30 @@ fn simple_version_subscriptions_should_work() { let origin = Parachain(1000); let message = Xcm::(vec![ SetAppendix(Xcm(vec![])), - SubscribeVersion { query_id: 42, max_response_weight: 5000 }, + SubscribeVersion { query_id: 42, max_response_weight: Weight::from_parts(5000, 5000) }, ]); let hash = fake_message_hash(&message); - let weight_limit = 20; + let weight_limit = Weight::from_parts(20, 20); let r = XcmExecutor::::execute_xcm(origin, message, hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); let origin = Parachain(1000); - let message = - Xcm::(vec![SubscribeVersion { query_id: 42, max_response_weight: 5000 }]); + let message = Xcm::(vec![SubscribeVersion { + query_id: 42, + max_response_weight: Weight::from_parts(5000, 5000), + }]); let hash = fake_message_hash(&message); - let weight_limit = 10; + let weight_limit = Weight::from_parts(10, 10); let r = XcmExecutor::::execute_xcm(origin, message.clone(), hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(10)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); - assert_eq!(SubscriptionRequests::get(), vec![(Parent.into(), Some((42, 5000)))]); + assert_eq!( + SubscriptionRequests::get(), + vec![(Parent.into(), Some((42, Weight::from_parts(5000, 5000))))] + ); } #[test] @@ -49,10 +54,10 @@ fn version_subscription_instruction_should_work() { let origin = Parachain(1000); let message = Xcm::(vec![ DescendOrigin(X1(AccountIndex64 { index: 1, network: None })), - SubscribeVersion { query_id: 42, max_response_weight: 5000 }, + SubscribeVersion { query_id: 42, max_response_weight: Weight::from_parts(5000, 5000) }, ]); let hash = fake_message_hash(&message); - let weight_limit = 20; + let weight_limit = Weight::from_parts(20, 20); let r = XcmExecutor::::execute_xcm_in_credit( origin.clone(), message, @@ -60,11 +65,11 @@ fn version_subscription_instruction_should_work() { weight_limit, weight_limit, ); - assert_eq!(r, Outcome::Incomplete(20, XcmError::BadOrigin)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(20, 20), XcmError::BadOrigin)); let message = Xcm::(vec![ SetAppendix(Xcm(vec![])), - SubscribeVersion { query_id: 42, max_response_weight: 5000 }, + SubscribeVersion { query_id: 42, max_response_weight: Weight::from_parts(5000, 5000) }, ]); let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm_in_credit( @@ -74,9 +79,12 @@ fn version_subscription_instruction_should_work() { weight_limit, weight_limit, ); - assert_eq!(r, Outcome::Complete(20)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(20, 20))); - assert_eq!(SubscriptionRequests::get(), vec![(Parachain(1000).into(), Some((42, 5000)))]); + assert_eq!( + SubscriptionRequests::get(), + vec![(Parachain(1000).into(), Some((42, Weight::from_parts(5000, 5000))))] + ); } #[test] @@ -86,19 +94,19 @@ fn simple_version_unsubscriptions_should_work() { let origin = Parachain(1000); let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); let hash = fake_message_hash(&message); - let weight_limit = 20; + let weight_limit = Weight::from_parts(20, 20); let r = XcmExecutor::::execute_xcm(origin, message, hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); let origin = Parachain(1000); let message = Xcm::(vec![UnsubscribeVersion]); let hash = fake_message_hash(&message); - let weight_limit = 10; + let weight_limit = Weight::from_parts(10, 10); let r = XcmExecutor::::execute_xcm(origin, message.clone(), hash, weight_limit); assert_eq!(r, Outcome::Error(XcmError::Barrier)); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); - assert_eq!(r, Outcome::Complete(10)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(10, 10))); assert_eq!(SubscriptionRequests::get(), vec![(Parent.into(), None)]); assert_eq!(sent_xcm(), vec![]); @@ -114,7 +122,7 @@ fn version_unsubscription_instruction_should_work() { UnsubscribeVersion, ]); let hash = fake_message_hash(&message); - let weight_limit = 20; + let weight_limit = Weight::from_parts(20, 20); let r = XcmExecutor::::execute_xcm_in_credit( origin.clone(), message, @@ -122,7 +130,7 @@ fn version_unsubscription_instruction_should_work() { weight_limit, weight_limit, ); - assert_eq!(r, Outcome::Incomplete(20, XcmError::BadOrigin)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(20, 20), XcmError::BadOrigin)); // Fine to do it when origin is untouched. let message = Xcm::(vec![SetAppendix(Xcm(vec![])), UnsubscribeVersion]); @@ -134,7 +142,7 @@ fn version_unsubscription_instruction_should_work() { weight_limit, weight_limit, ); - assert_eq!(r, Outcome::Complete(20)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(20, 20))); assert_eq!(SubscriptionRequests::get(), vec![(Parachain(1000).into(), None)]); assert_eq!(sent_xcm(), vec![]); diff --git a/xcm/xcm-builder/src/tests/weight.rs b/xcm/xcm-builder/src/tests/weight.rs index 41a9a0c98ea3..de77aa600ea5 100644 --- a/xcm/xcm-builder/src/tests/weight.rs +++ b/xcm/xcm-builder/src/tests/weight.rs @@ -41,30 +41,30 @@ fn errors_should_return_unused_weight() { ]); // Weight limit of 70 is needed. let limit = ::Weigher::weight(&mut message).unwrap(); - assert_eq!(limit, 30); + assert_eq!(limit, Weight::from_parts(30, 30)); let hash = fake_message_hash(&message); let r = XcmExecutor::::execute_xcm(Here, message.clone(), hash, limit); - assert_eq!(r, Outcome::Complete(30)); + assert_eq!(r, Outcome::Complete(Weight::from_parts(30, 30))); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 7u128).into()]); assert_eq!(asset_list(Here), vec![(Here, 4u128).into()]); assert_eq!(sent_xcm(), vec![]); let r = XcmExecutor::::execute_xcm(Here, message.clone(), hash, limit); - assert_eq!(r, Outcome::Incomplete(30, XcmError::NotWithdrawable)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(30, 30), XcmError::NotWithdrawable)); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 10u128).into()]); assert_eq!(asset_list(Here), vec![(Here, 1u128).into()]); assert_eq!(sent_xcm(), vec![]); let r = XcmExecutor::::execute_xcm(Here, message.clone(), hash, limit); - assert_eq!(r, Outcome::Incomplete(20, XcmError::NotWithdrawable)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(20, 20), XcmError::NotWithdrawable)); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11u128).into()]); assert_eq!(asset_list(Here), vec![]); assert_eq!(sent_xcm(), vec![]); let r = XcmExecutor::::execute_xcm(Here, message, hash, limit); - assert_eq!(r, Outcome::Incomplete(10, XcmError::NotWithdrawable)); + assert_eq!(r, Outcome::Incomplete(Weight::from_parts(10, 10), XcmError::NotWithdrawable)); assert_eq!(asset_list(AccountIndex64 { index: 3, network: None }), vec![(Here, 11u128).into()]); assert_eq!(asset_list(Here), vec![]); assert_eq!(sent_xcm(), vec![]); @@ -92,7 +92,10 @@ fn weight_bounds_should_respect_instructions_limit() { let mut message = Xcm(vec![SetErrorHandler(Xcm(vec![SetErrorHandler(Xcm(vec![ClearOrigin]))]))]); // 3 instructions are OK. - assert_eq!(::Weigher::weight(&mut message), Ok(30)); + assert_eq!( + ::Weigher::weight(&mut message), + Ok(Weight::from_parts(30, 30)) + ); } #[test] @@ -115,27 +118,34 @@ fn weight_trader_tuple_should_work() { let mut traders = Traders::new(); // trader one buys weight assert_eq!( - traders.buy_weight(5, fungible_multi_asset(Here.into(), 10).into()), + traders.buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(Here.into(), 10).into()), Ok(fungible_multi_asset(Here.into(), 5).into()), ); // trader one refunds - assert_eq!(traders.refund_weight(2), Some(fungible_multi_asset(Here.into(), 2))); + assert_eq!( + traders.refund_weight(Weight::from_parts(2, 2)), + Some(fungible_multi_asset(Here.into(), 2)) + ); let mut traders = Traders::new(); // trader one failed; trader two buys weight assert_eq!( - traders.buy_weight(5, fungible_multi_asset(para_1.clone(), 10).into()), + traders + .buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(para_1.clone(), 10).into()), Ok(fungible_multi_asset(para_1.clone(), 5).into()), ); // trader two refunds - assert_eq!(traders.refund_weight(2), Some(fungible_multi_asset(para_1, 2))); + assert_eq!( + traders.refund_weight(Weight::from_parts(2, 2)), + Some(fungible_multi_asset(para_1, 2)) + ); let mut traders = Traders::new(); // all traders fails assert_err!( - traders.buy_weight(5, fungible_multi_asset(para_2, 10).into()), + traders.buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(para_2, 10).into()), XcmError::TooExpensive, ); // and no refund - assert_eq!(traders.refund_weight(2), None); + assert_eq!(traders.refund_weight(Weight::from_parts(2, 2)), None); } diff --git a/xcm/xcm-builder/src/weight.rs b/xcm/xcm-builder/src/weight.rs index bad06674c543..201ed355a1e0 100644 --- a/xcm/xcm-builder/src/weight.rs +++ b/xcm/xcm-builder/src/weight.rs @@ -44,10 +44,10 @@ impl, C: Decode + GetDispatchInfo, M: Get> WeightBounds impl, C: Decode + GetDispatchInfo, M> FixedWeightBounds { fn weight_with_limit(message: &Xcm, instrs_limit: &mut u32) -> Result { - let mut r: Weight = 0; + let mut r: Weight = Weight::zero(); *instrs_limit = instrs_limit.checked_sub(message.0.len() as u32).ok_or(())?; for m in message.0.iter() { - r = r.checked_add(Self::instr_weight_with_limit(m, instrs_limit)?).ok_or(())?; + r = r.checked_add(&Self::instr_weight_with_limit(m, instrs_limit)?).ok_or(())?; } Ok(r) } @@ -55,14 +55,12 @@ impl, C: Decode + GetDispatchInfo, M> FixedWeightBounds instruction: &Instruction, instrs_limit: &mut u32, ) -> Result { - T::get() - .checked_add(match instruction { - Transact { require_weight_at_most, .. } => *require_weight_at_most, - SetErrorHandler(xcm) | SetAppendix(xcm) => - Self::weight_with_limit(xcm, instrs_limit)?, - _ => 0, - }) - .ok_or(()) + let instr_weight = match instruction { + Transact { require_weight_at_most, .. } => *require_weight_at_most, + SetErrorHandler(xcm) | SetAppendix(xcm) => Self::weight_with_limit(xcm, instrs_limit)?, + _ => Weight::zero(), + }; + T::get().checked_add(&instr_weight).ok_or(()) } } @@ -92,10 +90,10 @@ where Instruction: xcm::GetWeight, { fn weight_with_limit(message: &Xcm, instrs_limit: &mut u32) -> Result { - let mut r: Weight = 0; + let mut r: Weight = Weight::zero(); *instrs_limit = instrs_limit.checked_sub(message.0.len() as u32).ok_or(())?; for m in message.0.iter() { - r = r.checked_add(Self::instr_weight_with_limit(m, instrs_limit)?).ok_or(())?; + r = r.checked_add(&Self::instr_weight_with_limit(m, instrs_limit)?).ok_or(())?; } Ok(r) } @@ -104,15 +102,12 @@ where instrs_limit: &mut u32, ) -> Result { use xcm::GetWeight; - instruction - .weight() - .checked_add(match instruction { - Transact { require_weight_at_most, .. } => *require_weight_at_most, - SetErrorHandler(xcm) | SetAppendix(xcm) => - Self::weight_with_limit(xcm, instrs_limit)?, - _ => 0, - }) - .ok_or(()) + let instr_weight = match instruction { + Transact { require_weight_at_most, .. } => *require_weight_at_most, + SetErrorHandler(xcm) | SetAppendix(xcm) => Self::weight_with_limit(xcm, instrs_limit)?, + _ => Weight::zero(), + }; + instruction.weight().checked_add(&instr_weight).ok_or(()) } } @@ -139,7 +134,7 @@ pub struct FixedRateOfFungible, R: TakeRevenue>( ); impl, R: TakeRevenue> WeightTrader for FixedRateOfFungible { fn new() -> Self { - Self(0, 0, PhantomData) + Self(Weight::zero(), 0, PhantomData) } fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { @@ -149,7 +144,8 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOfFungib weight, payment, ); let (id, units_per_second) = T::get(); - let amount = units_per_second * (weight as u128) / (WEIGHT_PER_SECOND.ref_time() as u128); + let amount = + units_per_second * (weight.ref_time() as u128) / (WEIGHT_PER_SECOND.ref_time() as u128); if amount == 0 { return Ok(payment) } @@ -164,7 +160,8 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOfFungib log::trace!(target: "xcm::weight", "FixedRateOfFungible::refund_weight weight: {:?}", weight); let (id, units_per_second) = T::get(); let weight = weight.min(self.0); - let amount = units_per_second * (weight as u128) / (WEIGHT_PER_SECOND.ref_time() as u128); + let amount = + units_per_second * (weight.ref_time() as u128) / (WEIGHT_PER_SECOND.ref_time() as u128); self.0 -= weight; self.1 = self.1.saturating_sub(amount); if amount > 0 { @@ -205,13 +202,12 @@ impl< > WeightTrader for UsingComponents { fn new() -> Self { - Self(0, Zero::zero(), PhantomData) + Self(Weight::zero(), Zero::zero(), PhantomData) } fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { log::trace!(target: "xcm::weight", "UsingComponents::buy_weight weight: {:?}, payment: {:?}", weight, payment); - let amount = - WeightToFee::weight_to_fee(&frame_support::weights::Weight::from_ref_time(weight)); + let amount = WeightToFee::weight_to_fee(&weight); let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?; let required = (Concrete(AssetId::get()), u128_amount).into(); let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?; @@ -223,8 +219,7 @@ impl< fn refund_weight(&mut self, weight: Weight) -> Option { log::trace!(target: "xcm::weight", "UsingComponents::refund_weight weight: {:?}", weight); let weight = weight.min(self.0); - let amount = - WeightToFee::weight_to_fee(&frame_support::weights::Weight::from_ref_time(weight)); + let amount = WeightToFee::weight_to_fee(&weight); self.0 -= weight; self.1 = self.1.saturating_sub(amount); let amount: u128 = amount.saturated_into(); diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 410aa19d6315..99e7843f8dc1 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -17,6 +17,7 @@ use frame_support::{ construct_runtime, parameter_types, traits::{Everything, Nothing}, + weights::Weight, }; use parity_scale_codec::Encode; use sp_core::H256; @@ -152,7 +153,7 @@ type LocalOriginConverter = ( ); parameter_types! { - pub const BaseXcmWeight: u64 = 1_000_000_000; + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000_000); pub KsmPerSecond: (AssetId, u128) = (KsmLocation::get().into(), 1); } @@ -220,6 +221,7 @@ impl pallet_xcm::Config for Runtime { type Currency = Balances; type CurrencyMatcher = IsConcrete; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; } impl origin::Config for Runtime {} diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index cd237413d48d..05227fbd742c 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -16,6 +16,7 @@ mod mock; +use frame_support::weights::Weight; use mock::{ fake_message_hash, kusama_like_with_balances, AccountId, Balance, Balances, BaseXcmWeight, System, XcmConfig, CENTS, @@ -46,7 +47,7 @@ fn withdraw_and_deposit_works() { kusama_like_with_balances(balances).execute_with(|| { let other_para_id = 3000; let amount = REGISTER_AMOUNT; - let weight = 3 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 3; let message = Xcm(vec![ WithdrawAsset((Here, amount).into()), buy_execution(), @@ -113,11 +114,11 @@ fn report_holding_works() { kusama_like_with_balances(balances).execute_with(|| { let other_para_id = 3000; let amount = REGISTER_AMOUNT; - let weight = 4 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 4; let response_info = QueryResponseInfo { destination: Parachain(PARA_ID).into(), query_id: 1234, - max_weight: 1_000_000_000, + max_weight: Weight::from_parts(1_000_000_000, 1_000_000_000), }; let message = Xcm(vec![ WithdrawAsset((Here, amount).into()), @@ -197,7 +198,7 @@ fn teleport_to_statemine_works() { beneficiary: (Parent, Parachain(PARA_ID)).into(), }, ]; - let weight = 3 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 3; // teleports are allowed to community chains, even in the absence of trust from their side. let message = Xcm(vec![ @@ -283,7 +284,7 @@ fn reserve_based_transfer_works() { }, ]); let hash = fake_message_hash(&message); - let weight = 3 * BaseXcmWeight::get(); + let weight = BaseXcmWeight::get() * 3; let r = XcmExecutor::::execute_xcm(Parachain(PARA_ID), message, hash, weight); assert_eq!(r, Outcome::Complete(weight)); assert_eq!(Balances::free_balance(para_acc), INITIAL_BALANCE - amount); diff --git a/xcm/xcm-executor/Cargo.toml b/xcm/xcm-executor/Cargo.toml index 1f9842887eae..6dd6aded96ae 100644 --- a/xcm/xcm-executor/Cargo.toml +++ b/xcm/xcm-executor/Cargo.toml @@ -14,6 +14,7 @@ sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", de sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-weights = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } log = { version = "0.4.17", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false, optional = true } @@ -31,6 +32,7 @@ std = [ "sp-arithmetic/std", "sp-core/std", "sp-runtime/std", + "sp-weights/std", "frame-support/std", "log/std", ] diff --git a/xcm/xcm-executor/integration-tests/src/lib.rs b/xcm/xcm-executor/integration-tests/src/lib.rs index 952c2ea18f63..65be5620f7a5 100644 --- a/xcm/xcm-executor/integration-tests/src/lib.rs +++ b/xcm/xcm-executor/integration-tests/src/lib.rs @@ -17,6 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg(test)] +use frame_support::weights::Weight; use polkadot_test_client::{ BlockBuilderExt, ClientBlockImportExt, DefaultTestClientBuilderExt, ExecutionStrategy, InitPolkadotBlockBuilder, TestClientBuilder, TestClientBuilderExt, @@ -46,7 +47,7 @@ fn basic_buy_fees_message_executes() { &client, polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute { message: Box::new(VersionedXcm::from(msg)), - max_weight: 1_000_000_000, + max_weight: Weight::from_parts(1_000_000_000, 1024 * 1024), }), sp_keyring::Sr25519Keyring::Alice, 0, @@ -114,7 +115,7 @@ fn query_response_fires() { let mut block_builder = client.init_polkadot_block_builder(); let response = Response::ExecutionResult(None); - let max_weight = 1_000_000; + let max_weight = Weight::from_parts(1_000_000, 1024 * 1024); let querier = Some(Here.into()); let msg = Xcm(vec![QueryResponse { query_id, response, max_weight, querier }]); let msg = Box::new(VersionedXcm::from(msg)); @@ -123,7 +124,7 @@ fn query_response_fires() { &client, polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute { message: msg, - max_weight: 1_000_000_000, + max_weight: Weight::from_parts(1_000_000_000, 1024 * 1024), }), sp_keyring::Sr25519Keyring::Alice, 1, @@ -198,7 +199,7 @@ fn query_response_elicits_handler() { let mut block_builder = client.init_polkadot_block_builder(); let response = Response::ExecutionResult(None); - let max_weight = 1_000_000; + let max_weight = Weight::from_parts(1_000_000, 1024 * 1024); let querier = Some(Here.into()); let msg = Xcm(vec![QueryResponse { query_id, response, max_weight, querier }]); @@ -206,7 +207,7 @@ fn query_response_elicits_handler() { &client, polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute { message: Box::new(VersionedXcm::from(msg)), - max_weight: 1_000_000_000, + max_weight: Weight::from_parts(1_000_000_000, 1024 * 1024), }), sp_keyring::Sr25519Keyring::Alice, 1, diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index df7d9061d5b9..07e6c063c486 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -23,8 +23,8 @@ use frame_support::{ }; use parity_scale_codec::{Decode, Encode}; use sp_io::hashing::blake2_128; -use sp_runtime::traits::Saturating; use sp_std::{marker::PhantomData, prelude::*}; +use sp_weights::Weight; use xcm::latest::prelude::*; pub mod traits; @@ -58,12 +58,12 @@ pub struct XcmExecutor { /// an over-estimate of the actual weight consumed. We do it this way to avoid needing the /// execution engine to keep track of all instructions' weights (it only needs to care about /// the weight of dynamically determined instructions such as `Transact`). - total_surplus: u64, - total_refunded: u64, + total_surplus: Weight, + total_refunded: Weight, error_handler: Xcm, - error_handler_weight: u64, + error_handler_weight: Weight, appendix: Xcm, - appendix_weight: u64, + appendix_weight: Weight, transact_status: MaybeErrorCode, fees_mode: FeesMode, topic: Option<[u8; 32]>, @@ -108,16 +108,16 @@ impl XcmExecutor { pub fn set_error(&mut self, v: Option<(u32, XcmError)>) { self.error = v } - pub fn total_surplus(&self) -> &u64 { + pub fn total_surplus(&self) -> &Weight { &self.total_surplus } - pub fn set_total_surplus(&mut self, v: u64) { + pub fn set_total_surplus(&mut self, v: Weight) { self.total_surplus = v } - pub fn total_refunded(&self) -> &u64 { + pub fn total_refunded(&self) -> &Weight { &self.total_refunded } - pub fn set_total_refunded(&mut self, v: u64) { + pub fn set_total_refunded(&mut self, v: Weight) { self.total_refunded = v } pub fn error_handler(&self) -> &Xcm { @@ -126,10 +126,10 @@ impl XcmExecutor { pub fn set_error_handler(&mut self, v: Xcm) { self.error_handler = v } - pub fn error_handler_weight(&self) -> &u64 { + pub fn error_handler_weight(&self) -> &Weight { &self.error_handler_weight } - pub fn set_error_handler_weight(&mut self, v: u64) { + pub fn set_error_handler_weight(&mut self, v: Weight) { self.error_handler_weight = v } pub fn appendix(&self) -> &Xcm { @@ -138,10 +138,10 @@ impl XcmExecutor { pub fn set_appendix(&mut self, v: Xcm) { self.appendix = v } - pub fn appendix_weight(&self) -> &u64 { + pub fn appendix_weight(&self) -> &Weight { &self.appendix_weight } - pub fn set_appendix_weight(&mut self, v: u64) { + pub fn set_appendix_weight(&mut self, v: Weight) { self.appendix_weight = v } pub fn transact_status(&self) -> &MaybeErrorCode { @@ -164,9 +164,9 @@ impl XcmExecutor { } } -pub struct WeighedMessage(u64, Xcm); +pub struct WeighedMessage(Weight, Xcm); impl PreparedMessage for WeighedMessage { - fn weight_of(&self) -> u64 { + fn weight_of(&self) -> Weight { self.0 } } @@ -185,7 +185,7 @@ impl ExecuteXcm for XcmExecutor, WeighedMessage(xcm_weight, mut message): WeighedMessage, message_hash: XcmHash, - mut weight_credit: u64, + mut weight_credit: Weight, ) -> Outcome { let origin = origin.into(); log::trace!( @@ -246,7 +246,7 @@ impl ExecuteXcm for XcmExecutor XcmExecutor { original_origin: origin, trader: Config::Trader::new(), error: None, - total_surplus: 0, - total_refunded: 0, + total_surplus: Weight::zero(), + total_refunded: Weight::zero(), error_handler: Xcm(vec![]), - error_handler_weight: 0, + error_handler_weight: Weight::zero(), appendix: Xcm(vec![]), - appendix_weight: 0, + appendix_weight: Weight::zero(), transact_status: Default::default(), fees_mode: FeesMode { jit_withdraw: false }, topic: None, @@ -305,7 +305,11 @@ impl XcmExecutor { r @ Ok(()) => if let Err(e) = self.process_instruction(instr) { log::trace!(target: "xcm::execute", "!!! ERROR: {:?}", e); - *r = Err(ExecutorError { index: i as u32, xcm_error: e, weight: 0 }); + *r = Err(ExecutorError { + index: i as u32, + xcm_error: e, + weight: Weight::zero(), + }); }, Err(ref mut error) => if let Ok(x) = Config::Weigher::instr_weight(&instr) { @@ -318,7 +322,7 @@ impl XcmExecutor { /// Execute any final operations after having executed the XCM message. /// This includes refunding surplus weight, trapping extra holding funds, and returning any errors during execution. - pub fn post_process(mut self, xcm_weight: u64) -> Outcome { + pub fn post_process(mut self, xcm_weight: Weight) -> Outcome { // We silently drop any error from our attempt to refund the surplus as it's a charitable // thing so best-effort is all we will do. let _ = self.refund_surplus(); @@ -376,7 +380,7 @@ impl XcmExecutor { fn take_error_handler(&mut self) -> Xcm { let mut r = Xcm::(vec![]); sp_std::mem::swap(&mut self.error_handler, &mut r); - self.error_handler_weight = 0; + self.error_handler_weight = Weight::zero(); r } @@ -384,14 +388,14 @@ impl XcmExecutor { fn drop_error_handler(&mut self) { self.error_handler = Xcm::(vec![]); self.total_surplus.saturating_accrue(self.error_handler_weight); - self.error_handler_weight = 0; + self.error_handler_weight = Weight::zero(); } /// Remove the registered appendix and return it. fn take_appendix(&mut self) -> Xcm { let mut r = Xcm::(vec![]); sp_std::mem::swap(&mut self.appendix, &mut r); - self.appendix_weight = 0; + self.appendix_weight = Weight::zero(); r } @@ -416,7 +420,7 @@ impl XcmExecutor { /// Refund any unused weight. fn refund_surplus(&mut self) -> Result<(), XcmError> { let current_surplus = self.total_surplus.saturating_sub(self.total_refunded); - if current_surplus > 0 { + if current_surplus.any_gt(Weight::zero()) { self.total_refunded.saturating_accrue(current_surplus); if let Some(w) = self.trader.refund_weight(current_surplus) { self.subsume_asset(w)?; @@ -514,7 +518,7 @@ impl XcmExecutor { let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_kind) .map_err(|_| XcmError::BadOrigin)?; let weight = message_call.get_dispatch_info().weight; - ensure!(weight.ref_time() <= require_weight_at_most, XcmError::MaxWeightInvalid); + ensure!(weight.all_lte(require_weight_at_most), XcmError::MaxWeightInvalid); let maybe_actual_weight = match Config::CallDispatcher::dispatch(message_call, dispatch_origin) { Ok(post_info) => { @@ -536,7 +540,7 @@ impl XcmExecutor { // reported back to the caller and this ensures that they account for the total // weight consumed correctly (potentially allowing them to do more operations in a // block than they otherwise would). - self.total_surplus.saturating_accrue(surplus.ref_time()); + self.total_surplus.saturating_accrue(surplus); Ok(()) }, QueryResponse { query_id, response, max_weight, querier } => { @@ -645,7 +649,7 @@ impl XcmExecutor { // would indicate that `AllowTopLevelPaidExecutionFrom` was unused for execution // and thus there is some other reason why it has been determined that this XCM // should be executed. - if let Some(weight) = Option::::from(weight_limit) { + if let Some(weight) = Option::::from(weight_limit) { // pay for `weight` using up to `fees` of the holding register. let max_fee = self.holding.try_take(fees.into()).map_err(|_| XcmError::NotHoldingFees)?; diff --git a/xcm/xcm-executor/src/traits/drop_assets.rs b/xcm/xcm-executor/src/traits/drop_assets.rs index f5e59ba50db4..1119f585345f 100644 --- a/xcm/xcm-executor/src/traits/drop_assets.rs +++ b/xcm/xcm-executor/src/traits/drop_assets.rs @@ -17,7 +17,6 @@ use crate::Assets; use core::marker::PhantomData; use frame_support::traits::Contains; -use sp_runtime::traits::Zero; use xcm::latest::{MultiAssets, MultiLocation, Weight, XcmContext}; /// Define a handler for when some non-empty `Assets` value should be dropped. diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index 59d6d47962b1..dbde3f940f41 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use sp_runtime::traits::Zero; use xcm::latest::{ Error as XcmError, MultiLocation, QueryId, Response, Result as XcmResult, Weight, XcmContext, }; @@ -72,7 +71,7 @@ pub trait VersionChangeNotifier { fn start( location: &MultiLocation, query_id: QueryId, - max_weight: u64, + max_weight: Weight, context: &XcmContext, ) -> XcmResult; @@ -85,7 +84,7 @@ pub trait VersionChangeNotifier { } impl VersionChangeNotifier for () { - fn start(_: &MultiLocation, _: QueryId, _: u64, _: &XcmContext) -> XcmResult { + fn start(_: &MultiLocation, _: QueryId, _: Weight, _: &XcmContext) -> XcmResult { Err(XcmError::Unimplemented) } fn stop(_: &MultiLocation, _: &XcmContext) -> XcmResult { diff --git a/xcm/xcm-simulator/example/Cargo.toml b/xcm/xcm-simulator/example/Cargo.toml index 54443959ba21..ea264ba611a9 100644 --- a/xcm/xcm-simulator/example/Cargo.toml +++ b/xcm/xcm-simulator/example/Cargo.toml @@ -39,7 +39,6 @@ runtime-benchmarks = [ "pallet-xcm/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", "polkadot-parachain/runtime-benchmarks", ] diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index 299007a307e3..0ddaf6337f5b 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -138,7 +138,7 @@ mod tests { use super::*; use codec::Encode; - use frame_support::assert_ok; + use frame_support::{assert_ok, weights::Weight}; use xcm::latest::QueryResponseInfo; use xcm_simulator::TestExt; @@ -167,7 +167,7 @@ mod tests { Parachain(1), Xcm(vec![Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: INITIAL_BALANCE as u64, + require_weight_at_most: Weight::from_parts(INITIAL_BALANCE as u64, 1024 * 1024), call: remark.encode().into(), }]), )); @@ -195,7 +195,7 @@ mod tests { Parent, Xcm(vec![Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: INITIAL_BALANCE as u64, + require_weight_at_most: Weight::from_parts(INITIAL_BALANCE as u64, 1024 * 1024), call: remark.encode().into(), }]), )); @@ -223,7 +223,7 @@ mod tests { (Parent, Parachain(2)), Xcm(vec![Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: INITIAL_BALANCE as u64, + require_weight_at_most: Weight::from_parts(INITIAL_BALANCE as u64, 1024 * 1024), call: remark.encode().into(), }]), )); @@ -494,7 +494,7 @@ mod tests { let message = Xcm(vec![Transact { origin_kind: OriginKind::Xcm, - require_weight_at_most: 1_000_000_000, + require_weight_at_most: Weight::from_parts(1_000_000_000, 1024 * 1024), call: parachain::RuntimeCall::from( pallet_uniques::Call::::create { collection: (Parent, 2u64).into(), @@ -586,7 +586,7 @@ mod tests { response_info: QueryResponseInfo { destination: Parachain(1).into(), query_id: query_id_set, - max_weight: 1_000_000_000, + max_weight: Weight::from_parts(1_000_000_000, 1024 * 1024), }, assets: All.into(), }, @@ -616,7 +616,7 @@ mod tests { vec![Xcm(vec![QueryResponse { query_id: query_id_set, response: Response::Assets(MultiAssets::new()), - max_weight: 1_000_000_000, + max_weight: Weight::from_parts(1_000_000_000, 1024 * 1024), querier: Some(Here.into()), }])], ); diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 6101b78bd9df..023e1a41ac15 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -187,7 +187,7 @@ pub type XcmOriginToCallOrigin = ( ); parameter_types! { - pub const UnitWeightCost: u64 = 1; + pub const UnitWeightCost: Weight = Weight::from_parts(1, 1); pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -318,19 +318,12 @@ pub mod mock_msg_queue { let (result, event) = match Xcm::::try_from(xcm) { Ok(xcm) => { let location = (Parent, Parachain(sender.into())); - match T::XcmExecutor::execute_xcm( - location, - xcm, - message_hash, - max_weight.ref_time(), - ) { + match T::XcmExecutor::execute_xcm(location, xcm, message_hash, max_weight) { Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), - Outcome::Complete(w) => - (Ok(Weight::from_ref_time(w)), Event::Success(Some(hash))), + Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), // As far as the caller is concerned, this was dispatched without error, so // we just report the weight used. - Outcome::Incomplete(w, e) => - (Ok(Weight::from_ref_time(w)), Event::Fail(Some(hash), e)), + Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)), } }, Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))), @@ -380,12 +373,7 @@ pub mod mock_msg_queue { Ok(versioned) => match Xcm::try_from(versioned) { Err(()) => Self::deposit_event(Event::UnsupportedVersion(id)), Ok(x) => { - let outcome = T::XcmExecutor::execute_xcm( - Parent, - x.clone(), - id, - limit.ref_time(), - ); + let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit); >::append(x); Self::deposit_event(Event::ExecutedDownward(id, outcome)); }, @@ -424,6 +412,7 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index f743b84ab280..c4161c0770a1 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -19,6 +19,7 @@ use frame_support::{ construct_runtime, parameter_types, traits::{AsEnsureOriginWithArg, Everything, Nothing}, + weights::Weight, }; use sp_core::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; @@ -148,7 +149,7 @@ type LocalOriginConverter = ( ); parameter_types! { - pub const BaseXcmWeight: u64 = 1_000; + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000, 1_000); pub TokensPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1_000_000_000_000); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -206,6 +207,7 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; } parameter_types! { diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 1785e1178bf6..6598589f2b3e 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -120,7 +120,7 @@ pub type XcmOriginToCallOrigin = ( ); parameter_types! { - pub const UnitWeightCost: u64 = 1; + pub const UnitWeightCost: Weight = Weight::from_parts(1, 1); pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -232,19 +232,12 @@ pub mod mock_msg_queue { let (result, event) = match Xcm::::try_from(xcm) { Ok(xcm) => { let location = MultiLocation::new(1, X1(Parachain(sender.into()))); - match T::XcmExecutor::execute_xcm( - location, - xcm, - message_hash, - max_weight.ref_time(), - ) { + match T::XcmExecutor::execute_xcm(location, xcm, message_hash, max_weight) { Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), - Outcome::Complete(w) => - (Ok(Weight::from_ref_time(w)), Event::Success(Some(hash))), + Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), // As far as the caller is concerned, this was dispatched without error, so // we just report the weight used. - Outcome::Incomplete(w, e) => - (Ok(Weight::from_ref_time(w)), Event::Fail(Some(hash), e)), + Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)), } }, Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))), @@ -296,8 +289,7 @@ pub mod mock_msg_queue { Self::deposit_event(Event::UnsupportedVersion(id)); }, Ok(Ok(x)) => { - let outcome = - T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit.ref_time()); + let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit); >::append(x); Self::deposit_event(Event::ExecutedDownward(id, outcome)); }, @@ -335,6 +327,7 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index aa6d4fd99583..4a464b64ec01 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -19,6 +19,7 @@ use frame_support::{ construct_runtime, parameter_types, traits::{Everything, Nothing}, + weights::Weight, }; use sp_core::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; @@ -97,7 +98,6 @@ parameter_types! { pub const ThisNetwork: NetworkId = NetworkId::ByGenesis([0; 32]); pub const AnyNetwork: Option = None; pub const UniversalLocation: InteriorMultiLocation = Here; - pub const UnitWeightCost: u64 = 1_000; } pub type SovereignAccountOf = @@ -114,7 +114,7 @@ type LocalOriginConverter = ( ); parameter_types! { - pub const BaseXcmWeight: u64 = 1_000; + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000, 1_000); pub KsmPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -172,6 +172,7 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; } parameter_types! { diff --git a/xcm/xcm-simulator/src/lib.rs b/xcm/xcm-simulator/src/lib.rs index 610b2f89e2ab..f87aae3f29a7 100644 --- a/xcm/xcm-simulator/src/lib.rs +++ b/xcm/xcm-simulator/src/lib.rs @@ -298,7 +298,7 @@ macro_rules! decl_test_network { $crate::Weight::MAX, ); if let Err((id, required)) = r { - return Err($crate::XcmError::WeightLimitReached(required.ref_time())); + return Err($crate::XcmError::WeightLimitReached(required)); } }, $( From aef02312590887cc156264cf7a7e278ec2da9216 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 11 Nov 2022 04:14:09 +0900 Subject: [PATCH 130/231] Replace Weight::MAX with 100b weight units --- xcm/pallet-xcm/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index f2da48273f86..061864651236 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -72,35 +72,35 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn send() -> Weight { - Weight::MAX + Weight::from_ref_time(100_000_000) } fn teleport_assets() -> Weight { - Weight::MAX + Weight::from_ref_time(100_000_000) } fn reserve_transfer_assets() -> Weight { - Weight::MAX + Weight::from_ref_time(100_000_000) } fn execute() -> Weight { - Weight::MAX + Weight::from_ref_time(100_000_000) } fn force_xcm_version() -> Weight { - Weight::MAX + Weight::from_ref_time(100_000_000) } fn force_default_xcm_version() -> Weight { - Weight::MAX + Weight::from_ref_time(100_000_000) } fn force_subscribe_version_notify() -> Weight { - Weight::MAX + Weight::from_ref_time(100_000_000) } fn force_unsubscribe_version_notify() -> Weight { - Weight::MAX + Weight::from_ref_time(100_000_000) } } From 2668b7538bef1a8fb7a37f6161fffa33323b33dc Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 28 Nov 2022 15:07:41 +0900 Subject: [PATCH 131/231] Add test to ensure all_gte in barriers is correct --- xcm/xcm-builder/src/tests/barriers.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/xcm/xcm-builder/src/tests/barriers.rs b/xcm/xcm-builder/src/tests/barriers.rs index ea9078a892f5..9026de31a768 100644 --- a/xcm/xcm-builder/src/tests/barriers.rs +++ b/xcm/xcm-builder/src/tests/barriers.rs @@ -228,4 +228,27 @@ fn allow_paid_should_work() { &mut Weight::zero(), ); assert_eq!(r, Ok(())); + + let fees = (Parent, 1).into(); + let mut paying_message_with_different_weight_parts = Xcm::<()>(vec![ + WithdrawAsset((Parent, 100).into()), + BuyExecution { fees, weight_limit: Limited(Weight::from_parts(20, 10)) }, + DepositAsset { assets: AllCounted(1).into(), beneficiary: Here.into() }, + ]); + + let r = AllowTopLevelPaidExecutionFrom::>::should_execute( + &Parent.into(), + paying_message_with_different_weight_parts.inner_mut(), + Weight::from_parts(20, 20), + &mut Weight::zero(), + ); + assert_eq!(r, Err(())); + + let r = AllowTopLevelPaidExecutionFrom::>::should_execute( + &Parent.into(), + paying_message_with_different_weight_parts.inner_mut(), + Weight::from_parts(10, 10), + &mut Weight::zero(), + ); + assert_eq!(r, Ok(())) } From 6280d1db46fa42f39fda70c8ce70e74b213bdd3b Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 28 Nov 2022 14:08:34 +0800 Subject: [PATCH 132/231] Update xcm/src/v3/junction.rs Co-authored-by: asynchronous rob --- xcm/src/v3/junction.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/src/v3/junction.rs b/xcm/src/v3/junction.rs index 17200f985de2..5bb5aa3e6370 100644 --- a/xcm/src/v3/junction.rs +++ b/xcm/src/v3/junction.rs @@ -51,7 +51,7 @@ pub enum NetworkId { Rococo, /// The Wococo testnet Relay-chain. Wococo, - /// The Ethereum network, including hard-forks supported by the Etheruem Foundation. + /// The Ethereum network, including hard-forks supported by the Ethereum Foundation. EthereumFoundation, /// The Ethereum network, including hard-forks supported by Ethereum Classic developers. EthereumClassic, From 599158b38c20a6ec2b0a0a57a3be345fb62991d3 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 28 Nov 2022 15:39:32 +0900 Subject: [PATCH 133/231] Add more weight tests --- xcm/xcm-builder/src/tests/barriers.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xcm/xcm-builder/src/tests/barriers.rs b/xcm/xcm-builder/src/tests/barriers.rs index 9026de31a768..a7889c7e212d 100644 --- a/xcm/xcm-builder/src/tests/barriers.rs +++ b/xcm/xcm-builder/src/tests/barriers.rs @@ -174,6 +174,30 @@ fn allow_explicit_unpaid_should_work() { &mut Weight::zero(), ); assert_eq!(r, Ok(())); + + let mut message_with_different_weight_parts = Xcm::<()>(vec![ + UnpaidExecution { + weight_limit: Limited(Weight::from_parts(20, 10)), + check_origin: Some(Parent.into()), + }, + TransferAsset { assets: (Parent, 100).into(), beneficiary: Here.into() }, + ]); + + let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( + &Parent.into(), + message_with_different_weight_parts.inner_mut(), + Weight::from_parts(20, 20), + &mut Weight::zero(), + ); + assert_eq!(r, Err(())); + + let r = AllowExplicitUnpaidExecutionFrom::>::should_execute( + &Parent.into(), + message_with_different_weight_parts.inner_mut(), + Weight::from_parts(10, 10), + &mut Weight::zero(), + ); + assert_eq!(r, Ok(())); } #[test] From 6f0339cdb48edd1296f8d80c1da771f87a211b49 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 2 Dec 2022 02:36:33 +0900 Subject: [PATCH 134/231] cargo fmt --- rpc/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 0f54840f2ca5..43efefcae15b 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -108,11 +108,7 @@ where + Sync + 'static, C::Api: frame_rpc_system::AccountNonceApi, - C::Api: mmr_rpc::MmrRuntimeApi< - Block, - ::Hash, - BlockNumber, - >, + C::Api: mmr_rpc::MmrRuntimeApi::Hash, BlockNumber>, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BabeApi, C::Api: BlockBuilder, From c34826f7b484a1733f937be3a959297022066fc8 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 2 Dec 2022 04:07:56 +0900 Subject: [PATCH 135/231] Create thread_local in XCM executor to limit recursion depth (#6304) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create thread_local in XCM executor to limit recursion depth * Add unit test for recursion limit * Fix statefulness in tests * Remove panic * Use defer and environmental macro * Fix the implementation * Use nicer interface * Change ThisNetwork to AnyNetwork * Move recursion check up to top level * cargo fmt * Update comment Co-authored-by: Bastian Köcher --- Cargo.lock | 5 +- runtime/test-runtime/src/lib.rs | 37 +----------- runtime/test-runtime/src/xcm_config.rs | 44 ++++++++++++-- xcm/src/v3/traits.rs | 2 + xcm/xcm-executor/Cargo.toml | 1 + xcm/xcm-executor/integration-tests/src/lib.rs | 58 ++++++++++++++++++- xcm/xcm-executor/src/lib.rs | 35 ++++++++++- 7 files changed, 134 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d0ca953616b..2fa95ad85143 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1737,9 +1737,9 @@ dependencies = [ [[package]] name = "environmental" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "erased-serde" @@ -12702,6 +12702,7 @@ dependencies = [ name = "xcm-executor" version = "0.9.33" dependencies = [ + "environmental", "frame-benchmarking", "frame-support", "impl-trait-for-tuples", diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index c765490fadb9..5d4625d76b94 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -131,7 +131,7 @@ parameter_types! { } impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = Everything; type BlockWeights = BlockWeights; type BlockLength = BlockLength; type DbWeight = (); @@ -538,41 +538,6 @@ impl parachains_ump::Config for Runtime { type WeightInfo = parachains_ump::TestWeightInfo; } -parameter_types! { - pub const BaseXcmWeight: xcm::latest::Weight = Weight::from_parts(1_000, 1_000); - pub const AnyNetwork: Option = None; - pub const MaxInstructions: u32 = 100; - pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; -} - -pub type LocalOriginToLocation = - xcm_builder::SignedToAccountId32; - -impl pallet_xcm::Config for Runtime { - // The config types here are entirely configurable, since the only one that is sorely needed - // is `XcmExecutor`, which will be used in unit tests located in xcm-executor. - type RuntimeEvent = RuntimeEvent; - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; - type UniversalLocation = UniversalLocation; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; - type Weigher = xcm_builder::FixedWeightBounds; - type XcmRouter = xcm_config::DoNothingRouter; - type XcmExecuteFilter = Everything; - type XcmExecutor = xcm_executor::XcmExecutor; - type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Everything; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = (); - type MaxLockers = frame_support::traits::ConstU32<8>; - type WeightInfo = pallet_xcm::TestWeightInfo; -} - impl parachains_hrmp::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeEvent = RuntimeEvent; diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 992b116e98ea..2f850cf75976 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -20,14 +20,18 @@ use frame_support::{ weights::Weight, }; use xcm::latest::prelude::*; -use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32}; +use xcm_builder::{ + AllowUnpaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, SignedAccountId32AsNative, + SignedToAccountId32, +}; use xcm_executor::{ traits::{TransactAsset, WeightTrader}, Assets, }; parameter_types! { - pub const OurNetwork: NetworkId = NetworkId::Polkadot; + pub const BaseXcmWeight: xcm::latest::Weight = Weight::from_parts(1_000, 1_000); + pub const AnyNetwork: Option = None; pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 16; pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; @@ -37,7 +41,7 @@ parameter_types! { /// of this chain. pub type LocalOriginToLocation = ( // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); pub struct DoNothingRouter; @@ -80,17 +84,22 @@ impl WeightTrader for DummyWeightTrader { } } +type OriginConverter = ( + pallet_xcm::XcmPassthrough, + SignedAccountId32AsNative, +); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = super::RuntimeCall; type XcmSender = DoNothingRouter; type AssetTransactor = DummyAssetTransactor; - type OriginConverter = pallet_xcm::XcmPassthrough; + type OriginConverter = OriginConverter; type IsReserve = (); type IsTeleporter = (); type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = DummyWeightTrader; type ResponseHandler = super::Xcm; type AssetTrap = super::Xcm; @@ -105,3 +114,28 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = super::RuntimeCall; } + +impl pallet_xcm::Config for crate::Runtime { + // The config types here are entirely configurable, since the only one that is sorely needed + // is `XcmExecutor`, which will be used in unit tests located in xcm-executor. + type RuntimeEvent = crate::RuntimeEvent; + type ExecuteXcmOrigin = EnsureXcmOrigin; + type UniversalLocation = UniversalLocation; + type SendXcmOrigin = EnsureXcmOrigin; + type Weigher = FixedWeightBounds; + type XcmRouter = DoNothingRouter; + type XcmExecuteFilter = Everything; + type XcmExecutor = xcm_executor::XcmExecutor; + type XcmTeleportFilter = Everything; + type XcmReserveTransferFilter = Everything; + type RuntimeOrigin = crate::RuntimeOrigin; + type RuntimeCall = crate::RuntimeCall; + const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = crate::Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = (); + type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; +} diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 4325eb272d19..eb5dd37cbc6c 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -150,6 +150,8 @@ pub enum Error { Barrier, /// The weight of an XCM message is not computable ahead of execution. WeightNotComputable, + /// Recursion stack limit reached + ExceedsStackLimit, } impl MaxEncodedLen for Error { diff --git a/xcm/xcm-executor/Cargo.toml b/xcm/xcm-executor/Cargo.toml index b96b5b2f0ec7..a83379a91703 100644 --- a/xcm/xcm-executor/Cargo.toml +++ b/xcm/xcm-executor/Cargo.toml @@ -7,6 +7,7 @@ version = "0.9.33" [dependencies] impl-trait-for-tuples = "0.2.2" +environmental = { version = "1.1.4", default-features = false } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } xcm = { path = "..", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } diff --git a/xcm/xcm-executor/integration-tests/src/lib.rs b/xcm/xcm-executor/integration-tests/src/lib.rs index 0f23a375b99f..a3212c798dab 100644 --- a/xcm/xcm-executor/integration-tests/src/lib.rs +++ b/xcm/xcm-executor/integration-tests/src/lib.rs @@ -17,16 +17,17 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg(test)] -use frame_support::weights::Weight; +use frame_support::{codec::Encode, dispatch::GetDispatchInfo, weights::Weight}; use polkadot_test_client::{ BlockBuilderExt, ClientBlockImportExt, DefaultTestClientBuilderExt, ExecutionStrategy, InitPolkadotBlockBuilder, TestClientBuilder, TestClientBuilderExt, }; -use polkadot_test_runtime::pallet_test_notifier; +use polkadot_test_runtime::{pallet_test_notifier, xcm_config::XcmConfig}; use polkadot_test_service::construct_extrinsic; use sp_runtime::traits::Block; use sp_state_machine::InspectState; use xcm::{latest::prelude::*, VersionedResponse, VersionedXcm}; +use xcm_executor::traits::WeightBounds; #[test] fn basic_buy_fees_message_executes() { @@ -71,6 +72,59 @@ fn basic_buy_fees_message_executes() { }); } +#[test] +fn transact_recursion_limit_works() { + sp_tracing::try_init_simple(); + let mut client = TestClientBuilder::new() + .set_execution_strategy(ExecutionStrategy::AlwaysWasm) + .build(); + + let mut msg = Xcm(vec![ClearOrigin]); + let max_weight = ::Weigher::weight(&mut msg).unwrap(); + let mut call = polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute { + message: Box::new(VersionedXcm::from(msg)), + max_weight, + }); + + for _ in 0..11 { + let mut msg = Xcm(vec![ + WithdrawAsset((Parent, 1_000).into()), + BuyExecution { fees: (Parent, 1).into(), weight_limit: Unlimited }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: call.get_dispatch_info().weight, + call: call.encode().into(), + }, + ]); + let max_weight = ::Weigher::weight(&mut msg).unwrap(); + call = polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute { + message: Box::new(VersionedXcm::from(msg)), + max_weight, + }); + } + + let mut block_builder = client.init_polkadot_block_builder(); + + let execute = construct_extrinsic(&client, call, sp_keyring::Sr25519Keyring::Alice, 0); + + block_builder.push_polkadot_extrinsic(execute).expect("pushes extrinsic"); + + let block = block_builder.build().expect("Finalizes the block").block; + let block_hash = block.hash(); + + futures::executor::block_on(client.import(sp_consensus::BlockOrigin::Own, block)) + .expect("imports the block"); + + client.state_at(block_hash).expect("state should exist").inspect_state(|| { + assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!( + r.event, + polkadot_test_runtime::RuntimeEvent::Xcm(pallet_xcm::Event::Attempted( + Outcome::Incomplete(_, XcmError::ExceedsStackLimit) + )), + ))); + }); +} + #[test] fn query_response_fires() { use pallet_test_notifier::Event::*; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 07e6c063c486..5906b2eef9c5 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -22,6 +22,7 @@ use frame_support::{ traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, }; use parity_scale_codec::{Decode, Encode}; +use sp_core::defer; use sp_io::hashing::blake2_128; use sp_std::{marker::PhantomData, prelude::*}; use sp_weights::Weight; @@ -44,6 +45,10 @@ pub struct FeesMode { pub jit_withdraw: bool, } +const RECURSION_LIMIT: u8 = 10; + +environmental::environmental!(recursion_count: u8); + /// The XCM executor. pub struct XcmExecutor { holding: Assets, @@ -302,15 +307,39 @@ impl XcmExecutor { let mut result = Ok(()); for (i, instr) in xcm.0.into_iter().enumerate() { match &mut result { - r @ Ok(()) => - if let Err(e) = self.process_instruction(instr) { + r @ Ok(()) => { + // Initialize the recursion count only the first time we hit this code in our + // potential recursive execution. + let inst_res = recursion_count::using_once(&mut 1, || { + recursion_count::with(|count| { + if *count > RECURSION_LIMIT { + return Err(XcmError::ExceedsStackLimit) + } + *count = count.saturating_add(1); + Ok(()) + }) + // This should always return `Some`, but let's play it safe. + .unwrap_or(Ok(()))?; + + // Ensure that we always decrement the counter whenever we finish processing + // the instruction. + defer! { + recursion_count::with(|count| { + *count = count.saturating_sub(1); + }); + } + + self.process_instruction(instr) + }); + if let Err(e) = inst_res { log::trace!(target: "xcm::execute", "!!! ERROR: {:?}", e); *r = Err(ExecutorError { index: i as u32, xcm_error: e, weight: Weight::zero(), }); - }, + } + }, Err(ref mut error) => if let Ok(x) = Config::Weigher::instr_weight(&instr) { error.weight.saturating_accrue(x) From 31d5410c40a8160af940121efc19bb796c0d2558 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 2 Dec 2022 18:26:06 +0900 Subject: [PATCH 136/231] Add upper limit on the number of overweight messages in the queue (#6298) * Add upper limit on the number of ovwerweight messages in the queue * Add newline --- runtime/kusama/src/lib.rs | 1 + runtime/parachains/src/ump.rs | 10 ++++-- runtime/parachains/src/ump/migration.rs | 48 +++++++++++++++++++++++++ runtime/polkadot/src/lib.rs | 1 + runtime/rococo/src/lib.rs | 1 + runtime/westend/src/lib.rs | 1 + 6 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 runtime/parachains/src/ump/migration.rs diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 41891bfc5892..b3de693424ed 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1456,6 +1456,7 @@ pub type Executive = frame_executive::Executive< ( // "Use 2D weights in XCM v3" pallet_xcm::migration::v1::MigrateToV1, + parachains_ump::migration::v1::MigrateToV1, ), >; /// The payload being signed in the transactions. diff --git a/runtime/parachains/src/ump.rs b/runtime/parachains/src/ump.rs index cefa73c5ec52..0c4898466cdd 100644 --- a/runtime/parachains/src/ump.rs +++ b/runtime/parachains/src/ump.rs @@ -31,9 +31,12 @@ pub use pallet::*; /// This is used for benchmarking sanely bounding relevant storate items. It is expected from the `configurations` /// pallet to check these values before setting. pub const MAX_UPWARD_MESSAGE_SIZE_BOUND: u32 = 50 * 1024; +/// Maximum amount of overweight messages that can exist in the queue at any given time. +pub const MAX_OVERWEIGHT_MESSAGES: u32 = 1000; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +pub mod migration; #[cfg(test)] pub(crate) mod tests; @@ -213,6 +216,7 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] #[pallet::without_storage_info] + #[pallet::storage_version(migration::STORAGE_VERSION)] pub struct Pallet(_); #[pallet::config] @@ -326,7 +330,7 @@ pub mod pallet { /// These messages stay there until manually dispatched. #[pallet::storage] pub type Overweight = - StorageMap<_, Twox64Concat, OverweightIndex, (ParaId, Vec), OptionQuery>; + CountedStorageMap<_, Twox64Concat, OverweightIndex, (ParaId, Vec), OptionQuery>; /// The number of overweight messages ever recorded in `Overweight` (and thus the lowest free /// index). @@ -540,7 +544,9 @@ impl Pallet { let _ = queue_cache.consume_front::(dispatchee); }, Err((id, required)) => { - if required.any_gt(config.ump_max_individual_weight) { + let is_under_limit = Overweight::::count() < MAX_OVERWEIGHT_MESSAGES; + weight_used.saturating_accrue(T::DbWeight::get().reads(1)); + if required.any_gt(config.ump_max_individual_weight) && is_under_limit { // overweight - add to overweight queue and continue with message // execution consuming the message. let upward_message = queue_cache.consume_front::(dispatchee).expect( diff --git a/runtime/parachains/src/ump/migration.rs b/runtime/parachains/src/ump/migration.rs new file mode 100644 index 000000000000..d791aa863f61 --- /dev/null +++ b/runtime/parachains/src/ump/migration.rs @@ -0,0 +1,48 @@ +// Copyright 2022 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 . + +use crate::ump::{Config, Overweight, Pallet}; +use frame_support::{ + pallet_prelude::*, + traits::{OnRuntimeUpgrade, StorageVersion}, + weights::Weight, +}; + +pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + +pub mod v1 { + use super::*; + + pub struct MigrateToV1(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for MigrateToV1 { + fn on_runtime_upgrade() -> Weight { + if StorageVersion::get::>() == 0 { + let mut weight = T::DbWeight::get().reads(1); + + let overweight_messages = Overweight::::initialize_counter() as u64; + + weight.saturating_accrue(T::DbWeight::get().reads_writes(overweight_messages, 1)); + + StorageVersion::new(1).put::>(); + + weight.saturating_add(T::DbWeight::get().writes(1)) + } else { + log::warn!("skipping v1, should be removed"); + T::DbWeight::get().reads(1) + } + } + } +} diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 6345360e3241..ef1ed46eb2f1 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1612,6 +1612,7 @@ pub type Executive = frame_executive::Executive< ( // "Use 2D weights in XCM v3" pallet_xcm::migration::v1::MigrateToV1, + parachains_ump::migration::v1::MigrateToV1, ), >; diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 933d3dd484f8..fa4006c06535 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1459,6 +1459,7 @@ pub type Executive = frame_executive::Executive< ( // "Use 2D weights in XCM v3" pallet_xcm::migration::v1::MigrateToV1, + parachains_ump::migration::v1::MigrateToV1, ), >; /// The payload being signed in transactions. diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index a10cadc492cd..f9c5aba1e934 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1225,6 +1225,7 @@ pub type Executive = frame_executive::Executive< ( // "Use 2D weights in XCM v3" pallet_xcm::migration::v1::MigrateToV1, + parachains_ump::migration::v1::MigrateToV1, ), >; /// The payload being signed in transactions. From 8aef2b98440b177b2e6c430cc769dc0bbfb5c6ee Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 2 Dec 2022 18:26:22 +0900 Subject: [PATCH 137/231] Introduce whitelist for Transact and limit UMP processing to 10 messages per block (#6280) * Add SafeCallFilter to XcmConfig * Limit UMP to receive 10 messages every block * Place 10 message limit on processing instead of receiving * Always increment the message_processed count whenever a message is processed * Add as_derivative to the Transact whitelist * cargo fmt * Fixes --- runtime/kusama/src/xcm_config.rs | 182 ++++++++++++++++++- runtime/parachains/src/ump.rs | 10 +- runtime/polkadot/src/xcm_config.rs | 149 ++++++++++++++- runtime/rococo/src/xcm_config.rs | 124 ++++++++++++- runtime/test-runtime/src/xcm_config.rs | 1 + runtime/westend/src/xcm_config.rs | 90 ++++++++- xcm/pallet-xcm/src/mock.rs | 1 + xcm/xcm-builder/src/tests/mock.rs | 3 +- xcm/xcm-builder/tests/mock/mod.rs | 1 + xcm/xcm-executor/src/config.rs | 6 + xcm/xcm-executor/src/lib.rs | 1 + xcm/xcm-simulator/example/src/parachain.rs | 1 + xcm/xcm-simulator/example/src/relay_chain.rs | 1 + xcm/xcm-simulator/fuzzer/src/parachain.rs | 1 + xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 1 + 15 files changed, 566 insertions(+), 6 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 7d69c1aad487..abc52f42c1be 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Everything, Nothing}, + traits::{Contains, Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -135,6 +135,185 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); +/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly +/// account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(t: &RuntimeCall) -> bool { + match t { + RuntimeCall::System( + frame_system::Call::fill_block { .. } | + frame_system::Call::kill_prefix { .. } | + frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::ConvictionVoting(..) | + RuntimeCall::Referenda( + pallet_referenda::Call::place_decision_deposit { .. } | + pallet_referenda::Call::refund_decision_deposit { .. } | + pallet_referenda::Call::cancel { .. } | + pallet_referenda::Call::kill { .. } | + pallet_referenda::Call::nudge_referendum { .. } | + pallet_referenda::Call::one_fewer_deciding { .. }, + ) | + RuntimeCall::FellowshipCollective(..) | + RuntimeCall::FellowshipReferenda( + pallet_referenda::Call::place_decision_deposit { .. } | + pallet_referenda::Call::refund_decision_deposit { .. } | + pallet_referenda::Call::cancel { .. } | + pallet_referenda::Call::kill { .. } | + pallet_referenda::Call::nudge_referendum { .. } | + pallet_referenda::Call::one_fewer_deciding { .. }, + ) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Society( + pallet_society::Call::bid { .. } | + pallet_society::Call::unbid { .. } | + pallet_society::Call::vouch { .. } | + pallet_society::Call::unvouch { .. } | + pallet_society::Call::vote { .. } | + pallet_society::Call::defender_vote { .. } | + pallet_society::Call::payout { .. } | + pallet_society::Call::unfound { .. } | + pallet_society::Call::judge_suspended_member { .. } | + pallet_society::Call::judge_suspended_candidate { .. } | + pallet_society::Call::set_max_members { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::Gilt(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ) => true, + _ => false, + } + } +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -166,6 +345,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = SafeCallFilter; } parameter_types! { diff --git a/runtime/parachains/src/ump.rs b/runtime/parachains/src/ump.rs index 0c4898466cdd..5bcdc6cd7bc7 100644 --- a/runtime/parachains/src/ump.rs +++ b/runtime/parachains/src/ump.rs @@ -509,6 +509,8 @@ impl Pallet { /// Devote some time into dispatching pending upward messages. pub(crate) fn process_pending_upward_messages() -> Weight { + const MAX_MESSAGES_PER_BLOCK: u8 = 10; + let mut messages_processed = 0; let mut weight_used = Weight::zero(); let config = >::config(); @@ -516,7 +518,12 @@ impl Pallet { let mut queue_cache = QueueCache::new(); while let Some(dispatchee) = cursor.peek() { - if weight_used.any_gte(config.ump_service_total_weight) { + if weight_used.any_gte(config.ump_service_total_weight) || + messages_processed >= MAX_MESSAGES_PER_BLOCK + { + // Temporarily allow for processing of a max of 10 messages per block, until we + // properly account for proof size weights. + // // Then check whether we've reached or overshoot the // preferred weight for the dispatching stage. // @@ -538,6 +545,7 @@ impl Pallet { // our remaining weight limit, then consume it. let maybe_next = queue_cache.peek_front::(dispatchee); if let Some(upward_message) = maybe_next { + messages_processed += 1; match T::UmpSink::process_upward_message(dispatchee, upward_message, max_weight) { Ok(used) => { weight_used += used; diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 286dedc02990..74fd731f0a77 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Everything, Nothing}, + traits::{Contains, Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -133,6 +133,152 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); +/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly +/// account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(t: &RuntimeCall) -> bool { + match t { + RuntimeCall::System( + frame_system::Call::fill_block { .. } | + frame_system::Call::kill_prefix { .. } | + frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ) => true, + _ => false, + } + } +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -161,6 +307,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = SafeCallFilter; } parameter_types! { diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 2b35d4e9a11f..bd550c97bff4 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Everything, Nothing}, + traits::{Contains, Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -133,6 +133,127 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); +/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly +/// account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(t: &RuntimeCall) -> bool { + match t { + RuntimeCall::System( + frame_system::Call::fill_block { .. } | + frame_system::Call::kill_prefix { .. } | + frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Society( + pallet_society::Call::bid { .. } | + pallet_society::Call::unbid { .. } | + pallet_society::Call::vouch { .. } | + pallet_society::Call::unvouch { .. } | + pallet_society::Call::vote { .. } | + pallet_society::Call::defender_vote { .. } | + pallet_society::Call::payout { .. } | + pallet_society::Call::unfound { .. } | + pallet_society::Call::judge_suspended_member { .. } | + pallet_society::Call::judge_suspended_candidate { .. } | + pallet_society::Call::set_max_members { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::Gilt(..) => true, + _ => false, + } + } +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -162,6 +283,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = SafeCallFilter; } parameter_types! { diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 2f850cf75976..594a91fdb139 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -113,6 +113,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = super::RuntimeCall; + type SafeCallFilter = Everything; } impl pallet_xcm::Config for crate::Runtime { diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 2ad4ede3e247..123dfbc9aa97 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ parameter_types, - traits::{Everything, Nothing}, + traits::{Contains, Everything, Nothing}, }; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; @@ -99,6 +99,93 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); +/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly +/// account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(t: &RuntimeCall) -> bool { + match t { + RuntimeCall::System( + frame_system::Call::fill_block { .. } | + frame_system::Call::kill_prefix { .. } | + frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ) => true, + _ => false, + } + } +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -125,6 +212,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = SafeCallFilter; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 9c0d34194ab0..11f343fd3cb3 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -301,6 +301,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index eb7fd9491c29..3662a4acf7b5 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -19,7 +19,7 @@ pub use crate::{ AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit, }; -use frame_support::traits::ContainsPair; +use frame_support::traits::{ContainsPair, Everything}; pub use frame_support::{ dispatch::{ DispatchError, DispatchInfo, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, @@ -642,6 +642,7 @@ impl Config for TestConfig { type UniversalAliases = TestUniversalAliases; type MessageExporter = TestMessageExporter; type CallDispatcher = TestCall; + type SafeCallFilter = Everything; } pub fn fungible_multi_asset(location: MultiLocation, amount: u128) -> MultiAsset { diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 99e7843f8dc1..a4b3439b3392 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -196,6 +196,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index bd8143adcb7b..9bb98055fb20 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -100,4 +100,10 @@ pub trait Config { /// XCM will use this to dispatch any calls. When no special call dispatcher is required, /// this can be set to the same type as `Self::Call`. type CallDispatcher: CallDispatcher; + + /// The safe call filter for `Transact`. + /// + /// Use this type to explicitly whitelist calls that cannot undergo recursion. This is a + /// temporary measure until we properly account for proof size weights for XCM instructions. + type SafeCallFilter: Contains; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 5906b2eef9c5..5d34068eb580 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -544,6 +544,7 @@ impl XcmExecutor { // TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain let message_call = call.take_decoded().map_err(|_| XcmError::FailedToDecode)?; + ensure!(Config::SafeCallFilter::contains(&message_call), XcmError::NoPermission); let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_kind) .map_err(|_| XcmError::BadOrigin)?; let weight = message_call.get_dispatch_info().weight; diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 023e1a41ac15..26dfd12de08c 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -242,6 +242,7 @@ impl Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index c4161c0770a1..c70307cf042f 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -182,6 +182,7 @@ impl Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 6598589f2b3e..2b6ab01e20ae 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -156,6 +156,7 @@ impl Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } #[frame_support::pallet] diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 4a464b64ec01..4fdcf51789ee 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -147,6 +147,7 @@ impl Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } pub type LocalOriginToLocation = SignedToAccountId32; From 76ffe03e337d16100a9f22eea3304022189edd5d Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 2 Dec 2022 17:36:21 +0800 Subject: [PATCH 138/231] Update xcm/xcm-builder/src/universal_exports.rs Co-authored-by: Branislav Kontur --- xcm/xcm-builder/src/universal_exports.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index f16b683a12c7..ae425a8598ed 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -52,7 +52,7 @@ fn ensure_is_remote( /// that the message sending cannot be abused in any way. /// /// This is only useful when the local chain has bridging capabilities. -pub struct LocalUnpaidExporter( +pub struct UnpaidLocalExporter( PhantomData<(Exporter, UniversalLocation)>, ); impl> SendXcm From 979c60a44505d433b10fe2c67bbd0275ade2227a Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 15:46:08 +0900 Subject: [PATCH 139/231] Fixes --- xcm/xcm-builder/src/lib.rs | 2 +- xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs | 2 +- xcm/xcm-builder/src/universal_exports.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 1cb7fba9f5cc..ff3a9b590918 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -80,6 +80,6 @@ pub use filter_asset_location::{Case, NativeAsset}; mod universal_exports; pub use universal_exports::{ BridgeBlobDispatcher, BridgeMessage, DispatchBlob, DispatchBlobError, ExporterFor, HaulBlob, - HaulBlobExporter, LocalUnpaidExporter, NetworkExportTable, SovereignPaidRemoteExporter, + HaulBlobExporter, UnpaidLocalExporter, NetworkExportTable, SovereignPaidRemoteExporter, UnpaidRemoteExporter, }; diff --git a/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs index 7fd5de2b2719..20b029526e9f 100644 --- a/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs +++ b/xcm/xcm-builder/src/tests/bridging/local_relay_relay.rs @@ -26,7 +26,7 @@ parameter_types! { } type TheBridge = TestBridge>; -type Router = LocalUnpaidExporter, UniversalLocation>; +type Router = UnpaidLocalExporter, UniversalLocation>; /// ```nocompile /// local | remote diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index ae425a8598ed..20fbec5e73b9 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -56,7 +56,7 @@ pub struct UnpaidLocalExporter( PhantomData<(Exporter, UniversalLocation)>, ); impl> SendXcm - for LocalUnpaidExporter + for UnpaidLocalExporter { type Ticket = Exporter::Ticket; From 799ef59f05d741ffd89ce25979045e1a17b5a96c Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 16:13:05 +0900 Subject: [PATCH 140/231] Fixes --- runtime/kusama/src/xcm_config.rs | 1 - runtime/polkadot/src/xcm_config.rs | 1 - runtime/rococo/src/xcm_config.rs | 1 - runtime/westend/src/xcm_config.rs | 1 - 4 files changed, 4 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index abc52f42c1be..a8677a0236fa 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -147,7 +147,6 @@ impl Contains for SafeCallFilter { fn contains(t: &RuntimeCall) -> bool { match t { RuntimeCall::System( - frame_system::Call::fill_block { .. } | frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, ) | diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 74fd731f0a77..5443eaf8ce6e 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -145,7 +145,6 @@ impl Contains for SafeCallFilter { fn contains(t: &RuntimeCall) -> bool { match t { RuntimeCall::System( - frame_system::Call::fill_block { .. } | frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, ) | diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index bd550c97bff4..a95121a968dd 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -145,7 +145,6 @@ impl Contains for SafeCallFilter { fn contains(t: &RuntimeCall) -> bool { match t { RuntimeCall::System( - frame_system::Call::fill_block { .. } | frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, ) | diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 123dfbc9aa97..d01b8f536bef 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -111,7 +111,6 @@ impl Contains for SafeCallFilter { fn contains(t: &RuntimeCall) -> bool { match t { RuntimeCall::System( - frame_system::Call::fill_block { .. } | frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, ) | From 4d6b75812a1a16deb4afc9e432ed571b4fd9f4d7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 16:17:25 +0900 Subject: [PATCH 141/231] Remove topic register and instead use the topic field in XcmContext --- xcm/xcm-executor/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 5d34068eb580..870ed037a7ca 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -71,7 +71,6 @@ pub struct XcmExecutor { appendix_weight: Weight, transact_status: MaybeErrorCode, fees_mode: FeesMode, - topic: Option<[u8; 32]>, _config: PhantomData, } @@ -162,10 +161,10 @@ impl XcmExecutor { self.fees_mode = v } pub fn topic(&self) -> &Option<[u8; 32]> { - &self.topic + &self.context.topic } pub fn set_topic(&mut self, v: Option<[u8; 32]>) { - self.topic = v; + self.context.topic = v; } } @@ -285,7 +284,6 @@ impl XcmExecutor { appendix_weight: Weight::zero(), transact_status: Default::default(), fees_mode: FeesMode { jit_withdraw: false }, - topic: None, _config: PhantomData, } } @@ -899,11 +897,11 @@ impl XcmExecutor { Ok(()) }, SetTopic(topic) => { - self.topic = Some(topic); + self.context.topic = Some(topic); Ok(()) }, ClearTopic => { - self.topic = None; + self.context.topic = None; Ok(()) }, AliasOrigin(_) => Err(XcmError::NoPermission), From 07937f5bac21e7ee842d6bb3c3dd284e90432270 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 16:21:45 +0900 Subject: [PATCH 142/231] Derive some common traits for DispatchBlobError --- xcm/xcm-builder/src/universal_exports.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index 20fbec5e73b9..4ff7668a8622 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -252,6 +252,7 @@ pub struct BridgeMessage { message: VersionedXcm<()>, } +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum DispatchBlobError { Unbridgable, InvalidEncoding, From e42883839dfb684b9ddb3137e1937f093e2b1125 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 17:29:21 +0900 Subject: [PATCH 143/231] Fixes --- xcm/xcm-builder/src/tests/bridging/local_para_para.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/tests/bridging/local_para_para.rs b/xcm/xcm-builder/src/tests/bridging/local_para_para.rs index 396aa81d792f..a2ab952b16d6 100644 --- a/xcm/xcm-builder/src/tests/bridging/local_para_para.rs +++ b/xcm/xcm-builder/src/tests/bridging/local_para_para.rs @@ -26,7 +26,7 @@ parameter_types! { } type TheBridge = TestBridge>; -type Router = LocalUnpaidExporter, UniversalLocation>; +type Router = UnpaidLocalExporter, UniversalLocation>; /// ```nocompile /// local | remote From 83f2fd3193d5f7ef0fc6ed045b5481a0748a42d4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 17:29:46 +0900 Subject: [PATCH 144/231] cargo fmt --- runtime/kusama/src/xcm_config.rs | 3 +-- runtime/polkadot/src/xcm_config.rs | 3 +-- runtime/rococo/src/xcm_config.rs | 3 +-- runtime/westend/src/xcm_config.rs | 3 +-- xcm/xcm-builder/src/lib.rs | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index a8677a0236fa..aa34d2dbb7e0 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -147,8 +147,7 @@ impl Contains for SafeCallFilter { fn contains(t: &RuntimeCall) -> bool { match t { RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | - frame_system::Call::set_heap_pages { .. }, + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, ) | RuntimeCall::Babe(..) | RuntimeCall::Timestamp(..) | diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 5443eaf8ce6e..0acb690d5f15 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -145,8 +145,7 @@ impl Contains for SafeCallFilter { fn contains(t: &RuntimeCall) -> bool { match t { RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | - frame_system::Call::set_heap_pages { .. }, + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, ) | RuntimeCall::Babe(..) | RuntimeCall::Timestamp(..) | diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index a95121a968dd..356806fbcf65 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -145,8 +145,7 @@ impl Contains for SafeCallFilter { fn contains(t: &RuntimeCall) -> bool { match t { RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | - frame_system::Call::set_heap_pages { .. }, + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, ) | RuntimeCall::Babe(..) | RuntimeCall::Timestamp(..) | diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index d01b8f536bef..f471f6c69b77 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -111,8 +111,7 @@ impl Contains for SafeCallFilter { fn contains(t: &RuntimeCall) -> bool { match t { RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | - frame_system::Call::set_heap_pages { .. }, + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, ) | RuntimeCall::Babe(..) | RuntimeCall::Timestamp(..) | diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index ff3a9b590918..8e3eab479e90 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -80,6 +80,6 @@ pub use filter_asset_location::{Case, NativeAsset}; mod universal_exports; pub use universal_exports::{ BridgeBlobDispatcher, BridgeMessage, DispatchBlob, DispatchBlobError, ExporterFor, HaulBlob, - HaulBlobExporter, UnpaidLocalExporter, NetworkExportTable, SovereignPaidRemoteExporter, + HaulBlobExporter, NetworkExportTable, SovereignPaidRemoteExporter, UnpaidLocalExporter, UnpaidRemoteExporter, }; From 57a9df8af5bf74594f1593b3f9cb71fc88c1572b Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 17:49:15 +0900 Subject: [PATCH 145/231] Fixes --- runtime/kusama/src/xcm_config.rs | 1 - runtime/polkadot/src/xcm_config.rs | 1 - runtime/westend/src/xcm_config.rs | 1 - 3 files changed, 3 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index aa34d2dbb7e0..d0e7844c8dca 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -171,7 +171,6 @@ impl Contains for SafeCallFilter { pallet_staking::Call::force_unstake { .. } | pallet_staking::Call::force_new_era_always { .. } | pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::unbond { .. } | pallet_staking::Call::reap_stash { .. } | pallet_staking::Call::set_staking_configs { .. } | pallet_staking::Call::chill_other { .. } | diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 0acb690d5f15..4863a4a553ae 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -169,7 +169,6 @@ impl Contains for SafeCallFilter { pallet_staking::Call::force_unstake { .. } | pallet_staking::Call::force_new_era_always { .. } | pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::unbond { .. } | pallet_staking::Call::reap_stash { .. } | pallet_staking::Call::set_staking_configs { .. } | pallet_staking::Call::chill_other { .. } | diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index f471f6c69b77..8a99e841d493 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -135,7 +135,6 @@ impl Contains for SafeCallFilter { pallet_staking::Call::force_unstake { .. } | pallet_staking::Call::force_new_era_always { .. } | pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::unbond { .. } | pallet_staking::Call::reap_stash { .. } | pallet_staking::Call::set_staking_configs { .. } | pallet_staking::Call::chill_other { .. } | From e761a845d272d111783ff9802638b9d9444c9e69 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 18:10:15 +0900 Subject: [PATCH 146/231] Fixes --- runtime/kusama/src/xcm_config.rs | 346 +++++++++--------- runtime/polkadot/src/xcm_config.rs | 280 +++++++------- runtime/rococo/src/xcm_config.rs | 232 ++++++------ runtime/westend/src/xcm_config.rs | 164 ++++----- .../src/fungible/mock.rs | 1 + xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 1 + 6 files changed, 505 insertions(+), 519 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index d0e7844c8dca..5c155cfbe5e7 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Contains, Everything, Nothing}, + traits::{Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -135,180 +135,176 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly -/// account for proof size weights. -/// -/// Calls that are allowed through this filter must: -/// 1. Have a fixed weight; -/// 2. Cannot lead to another call being made; -/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. -pub struct SafeCallFilter; -impl Contains for SafeCallFilter { - fn contains(t: &RuntimeCall) -> bool { - match t { - RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, - ) | - RuntimeCall::Babe(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Indices(..) | - RuntimeCall::Balances(..) | - RuntimeCall::Staking( - pallet_staking::Call::bond { .. } | - pallet_staking::Call::bond_extra { .. } | - pallet_staking::Call::unbond { .. } | - pallet_staking::Call::withdraw_unbonded { .. } | - pallet_staking::Call::validate { .. } | - pallet_staking::Call::chill { .. } | - pallet_staking::Call::set_payee { .. } | - pallet_staking::Call::set_controller { .. } | - pallet_staking::Call::set_validator_count { .. } | - pallet_staking::Call::increase_validator_count { .. } | - pallet_staking::Call::scale_validator_count { .. } | - pallet_staking::Call::force_no_eras { .. } | - pallet_staking::Call::force_new_era { .. } | - pallet_staking::Call::set_invulnerables { .. } | - pallet_staking::Call::force_unstake { .. } | - pallet_staking::Call::force_new_era_always { .. } | - pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::reap_stash { .. } | - pallet_staking::Call::set_staking_configs { .. } | - pallet_staking::Call::chill_other { .. } | - pallet_staking::Call::force_apply_min_commission { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::Grandpa(..) | - RuntimeCall::ImOnline(..) | - RuntimeCall::Democracy( - pallet_democracy::Call::second { .. } | - pallet_democracy::Call::vote { .. } | - pallet_democracy::Call::emergency_cancel { .. } | - pallet_democracy::Call::fast_track { .. } | - pallet_democracy::Call::veto_external { .. } | - pallet_democracy::Call::cancel_referendum { .. } | - pallet_democracy::Call::delegate { .. } | - pallet_democracy::Call::undelegate { .. } | - pallet_democracy::Call::clear_public_proposals { .. } | - pallet_democracy::Call::unlock { .. } | - pallet_democracy::Call::remove_vote { .. } | - pallet_democracy::Call::remove_other_vote { .. } | - pallet_democracy::Call::blacklist { .. } | - pallet_democracy::Call::cancel_proposal { .. }, - ) | - RuntimeCall::Council( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::TechnicalCommittee( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::PhragmenElection( - pallet_elections_phragmen::Call::remove_voter { .. } | - pallet_elections_phragmen::Call::submit_candidacy { .. } | - pallet_elections_phragmen::Call::renounce_candidacy { .. } | - pallet_elections_phragmen::Call::remove_member { .. } | - pallet_elections_phragmen::Call::clean_defunct_voters { .. }, - ) | - RuntimeCall::TechnicalMembership( - pallet_membership::Call::add_member { .. } | - pallet_membership::Call::remove_member { .. } | - pallet_membership::Call::swap_member { .. } | - pallet_membership::Call::change_key { .. } | - pallet_membership::Call::set_prime { .. } | - pallet_membership::Call::clear_prime { .. }, - ) | - RuntimeCall::Treasury(..) | - RuntimeCall::ConvictionVoting(..) | - RuntimeCall::Referenda( - pallet_referenda::Call::place_decision_deposit { .. } | - pallet_referenda::Call::refund_decision_deposit { .. } | - pallet_referenda::Call::cancel { .. } | - pallet_referenda::Call::kill { .. } | - pallet_referenda::Call::nudge_referendum { .. } | - pallet_referenda::Call::one_fewer_deciding { .. }, - ) | - RuntimeCall::FellowshipCollective(..) | - RuntimeCall::FellowshipReferenda( - pallet_referenda::Call::place_decision_deposit { .. } | - pallet_referenda::Call::refund_decision_deposit { .. } | - pallet_referenda::Call::cancel { .. } | - pallet_referenda::Call::kill { .. } | - pallet_referenda::Call::nudge_referendum { .. } | - pallet_referenda::Call::one_fewer_deciding { .. }, - ) | - RuntimeCall::Claims( - super::claims::Call::claim { .. } | - super::claims::Call::mint_claim { .. } | - super::claims::Call::move_claim { .. }, - ) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Identity( - pallet_identity::Call::add_registrar { .. } | - pallet_identity::Call::set_identity { .. } | - pallet_identity::Call::clear_identity { .. } | - pallet_identity::Call::request_judgement { .. } | - pallet_identity::Call::cancel_request { .. } | - pallet_identity::Call::set_fee { .. } | - pallet_identity::Call::set_account_id { .. } | - pallet_identity::Call::set_fields { .. } | - pallet_identity::Call::provide_judgement { .. } | - pallet_identity::Call::kill_identity { .. } | - pallet_identity::Call::add_sub { .. } | - pallet_identity::Call::rename_sub { .. } | - pallet_identity::Call::remove_sub { .. } | - pallet_identity::Call::quit_sub { .. }, - ) | - RuntimeCall::Society( - pallet_society::Call::bid { .. } | - pallet_society::Call::unbid { .. } | - pallet_society::Call::vouch { .. } | - pallet_society::Call::unvouch { .. } | - pallet_society::Call::vote { .. } | - pallet_society::Call::defender_vote { .. } | - pallet_society::Call::payout { .. } | - pallet_society::Call::unfound { .. } | - pallet_society::Call::judge_suspended_member { .. } | - pallet_society::Call::judge_suspended_candidate { .. } | - pallet_society::Call::set_max_members { .. }, - ) | - RuntimeCall::Recovery(..) | - RuntimeCall::Vesting(..) | - RuntimeCall::Bounties( - pallet_bounties::Call::propose_bounty { .. } | - pallet_bounties::Call::approve_bounty { .. } | - pallet_bounties::Call::propose_curator { .. } | - pallet_bounties::Call::unassign_curator { .. } | - pallet_bounties::Call::accept_curator { .. } | - pallet_bounties::Call::award_bounty { .. } | - pallet_bounties::Call::claim_bounty { .. } | - pallet_bounties::Call::close_bounty { .. }, - ) | - RuntimeCall::ChildBounties(..) | - RuntimeCall::ElectionProviderMultiPhase(..) | - RuntimeCall::Gilt(..) | - RuntimeCall::VoterList(..) | - RuntimeCall::NominationPools( - pallet_nomination_pools::Call::join { .. } | - pallet_nomination_pools::Call::bond_extra { .. } | - pallet_nomination_pools::Call::claim_payout { .. } | - pallet_nomination_pools::Call::unbond { .. } | - pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | - pallet_nomination_pools::Call::withdraw_unbonded { .. } | - pallet_nomination_pools::Call::create { .. } | - pallet_nomination_pools::Call::create_with_pool_id { .. } | - pallet_nomination_pools::Call::set_state { .. } | - pallet_nomination_pools::Call::set_configs { .. } | - pallet_nomination_pools::Call::update_roles { .. } | - pallet_nomination_pools::Call::chill { .. }, - ) => true, - _ => false, - } - } +match_types! { + /// A call filter for the XCM Transact instruction. This is a temporary measure until we + /// properly account for proof size weights. + /// + /// Calls that are allowed through this filter must: + /// 1. Have a fixed weight; + /// 2. Cannot lead to another call being made; + /// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. + pub type SafeCallFilter: impl Contains = { + RuntimeCall::System( + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::ConvictionVoting(..) | + RuntimeCall::Referenda( + pallet_referenda::Call::place_decision_deposit { .. } | + pallet_referenda::Call::refund_decision_deposit { .. } | + pallet_referenda::Call::cancel { .. } | + pallet_referenda::Call::kill { .. } | + pallet_referenda::Call::nudge_referendum { .. } | + pallet_referenda::Call::one_fewer_deciding { .. }, + ) | + RuntimeCall::FellowshipCollective(..) | + RuntimeCall::FellowshipReferenda( + pallet_referenda::Call::place_decision_deposit { .. } | + pallet_referenda::Call::refund_decision_deposit { .. } | + pallet_referenda::Call::cancel { .. } | + pallet_referenda::Call::kill { .. } | + pallet_referenda::Call::nudge_referendum { .. } | + pallet_referenda::Call::one_fewer_deciding { .. }, + ) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Society( + pallet_society::Call::bid { .. } | + pallet_society::Call::unbid { .. } | + pallet_society::Call::vouch { .. } | + pallet_society::Call::unvouch { .. } | + pallet_society::Call::vote { .. } | + pallet_society::Call::defender_vote { .. } | + pallet_society::Call::payout { .. } | + pallet_society::Call::unfound { .. } | + pallet_society::Call::judge_suspended_member { .. } | + pallet_society::Call::judge_suspended_candidate { .. } | + pallet_society::Call::set_max_members { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::Gilt(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ) + }; } pub struct XcmConfig; diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 4863a4a553ae..a6bef2f86816 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Contains, Everything, Nothing}, + traits::{Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -133,147 +133,143 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly -/// account for proof size weights. -/// -/// Calls that are allowed through this filter must: -/// 1. Have a fixed weight; -/// 2. Cannot lead to another call being made; -/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. -pub struct SafeCallFilter; -impl Contains for SafeCallFilter { - fn contains(t: &RuntimeCall) -> bool { - match t { - RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, - ) | - RuntimeCall::Babe(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Indices(..) | - RuntimeCall::Balances(..) | - RuntimeCall::Staking( - pallet_staking::Call::bond { .. } | - pallet_staking::Call::bond_extra { .. } | - pallet_staking::Call::unbond { .. } | - pallet_staking::Call::withdraw_unbonded { .. } | - pallet_staking::Call::validate { .. } | - pallet_staking::Call::chill { .. } | - pallet_staking::Call::set_payee { .. } | - pallet_staking::Call::set_controller { .. } | - pallet_staking::Call::set_validator_count { .. } | - pallet_staking::Call::increase_validator_count { .. } | - pallet_staking::Call::scale_validator_count { .. } | - pallet_staking::Call::force_no_eras { .. } | - pallet_staking::Call::force_new_era { .. } | - pallet_staking::Call::set_invulnerables { .. } | - pallet_staking::Call::force_unstake { .. } | - pallet_staking::Call::force_new_era_always { .. } | - pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::reap_stash { .. } | - pallet_staking::Call::set_staking_configs { .. } | - pallet_staking::Call::chill_other { .. } | - pallet_staking::Call::force_apply_min_commission { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::Grandpa(..) | - RuntimeCall::ImOnline(..) | - RuntimeCall::Democracy( - pallet_democracy::Call::second { .. } | - pallet_democracy::Call::vote { .. } | - pallet_democracy::Call::emergency_cancel { .. } | - pallet_democracy::Call::fast_track { .. } | - pallet_democracy::Call::veto_external { .. } | - pallet_democracy::Call::cancel_referendum { .. } | - pallet_democracy::Call::delegate { .. } | - pallet_democracy::Call::undelegate { .. } | - pallet_democracy::Call::clear_public_proposals { .. } | - pallet_democracy::Call::unlock { .. } | - pallet_democracy::Call::remove_vote { .. } | - pallet_democracy::Call::remove_other_vote { .. } | - pallet_democracy::Call::blacklist { .. } | - pallet_democracy::Call::cancel_proposal { .. }, - ) | - RuntimeCall::Council( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::TechnicalCommittee( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::PhragmenElection( - pallet_elections_phragmen::Call::remove_voter { .. } | - pallet_elections_phragmen::Call::submit_candidacy { .. } | - pallet_elections_phragmen::Call::renounce_candidacy { .. } | - pallet_elections_phragmen::Call::remove_member { .. } | - pallet_elections_phragmen::Call::clean_defunct_voters { .. }, - ) | - RuntimeCall::TechnicalMembership( - pallet_membership::Call::add_member { .. } | - pallet_membership::Call::remove_member { .. } | - pallet_membership::Call::swap_member { .. } | - pallet_membership::Call::change_key { .. } | - pallet_membership::Call::set_prime { .. } | - pallet_membership::Call::clear_prime { .. }, - ) | - RuntimeCall::Treasury(..) | - RuntimeCall::Claims( - super::claims::Call::claim { .. } | - super::claims::Call::mint_claim { .. } | - super::claims::Call::move_claim { .. }, - ) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Identity( - pallet_identity::Call::add_registrar { .. } | - pallet_identity::Call::set_identity { .. } | - pallet_identity::Call::clear_identity { .. } | - pallet_identity::Call::request_judgement { .. } | - pallet_identity::Call::cancel_request { .. } | - pallet_identity::Call::set_fee { .. } | - pallet_identity::Call::set_account_id { .. } | - pallet_identity::Call::set_fields { .. } | - pallet_identity::Call::provide_judgement { .. } | - pallet_identity::Call::kill_identity { .. } | - pallet_identity::Call::add_sub { .. } | - pallet_identity::Call::rename_sub { .. } | - pallet_identity::Call::remove_sub { .. } | - pallet_identity::Call::quit_sub { .. }, - ) | - RuntimeCall::Vesting(..) | - RuntimeCall::Bounties( - pallet_bounties::Call::propose_bounty { .. } | - pallet_bounties::Call::approve_bounty { .. } | - pallet_bounties::Call::propose_curator { .. } | - pallet_bounties::Call::unassign_curator { .. } | - pallet_bounties::Call::accept_curator { .. } | - pallet_bounties::Call::award_bounty { .. } | - pallet_bounties::Call::claim_bounty { .. } | - pallet_bounties::Call::close_bounty { .. }, - ) | - RuntimeCall::ChildBounties(..) | - RuntimeCall::ElectionProviderMultiPhase(..) | - RuntimeCall::VoterList(..) | - RuntimeCall::NominationPools( - pallet_nomination_pools::Call::join { .. } | - pallet_nomination_pools::Call::bond_extra { .. } | - pallet_nomination_pools::Call::claim_payout { .. } | - pallet_nomination_pools::Call::unbond { .. } | - pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | - pallet_nomination_pools::Call::withdraw_unbonded { .. } | - pallet_nomination_pools::Call::create { .. } | - pallet_nomination_pools::Call::create_with_pool_id { .. } | - pallet_nomination_pools::Call::set_state { .. } | - pallet_nomination_pools::Call::set_configs { .. } | - pallet_nomination_pools::Call::update_roles { .. } | - pallet_nomination_pools::Call::chill { .. }, - ) => true, - _ => false, - } - } +match_types! { + /// A call filter for the XCM Transact instruction. This is a temporary measure until we + /// properly account for proof size weights. + /// + /// Calls that are allowed through this filter must: + /// 1. Have a fixed weight; + /// 2. Cannot lead to another call being made; + /// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. + pub type SafeCallFilter: impl Contains = { + RuntimeCall::System( + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ) + }; } pub struct XcmConfig; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 356806fbcf65..1def41f62cd7 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Contains, Everything, Nothing}, + traits::{Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -133,123 +133,119 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly -/// account for proof size weights. -/// -/// Calls that are allowed through this filter must: -/// 1. Have a fixed weight; -/// 2. Cannot lead to another call being made; -/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. -pub struct SafeCallFilter; -impl Contains for SafeCallFilter { - fn contains(t: &RuntimeCall) -> bool { - match t { - RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, - ) | - RuntimeCall::Babe(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Indices(..) | - RuntimeCall::Balances(..) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::Grandpa(..) | - RuntimeCall::ImOnline(..) | - RuntimeCall::Democracy( - pallet_democracy::Call::second { .. } | - pallet_democracy::Call::vote { .. } | - pallet_democracy::Call::emergency_cancel { .. } | - pallet_democracy::Call::fast_track { .. } | - pallet_democracy::Call::veto_external { .. } | - pallet_democracy::Call::cancel_referendum { .. } | - pallet_democracy::Call::delegate { .. } | - pallet_democracy::Call::undelegate { .. } | - pallet_democracy::Call::clear_public_proposals { .. } | - pallet_democracy::Call::unlock { .. } | - pallet_democracy::Call::remove_vote { .. } | - pallet_democracy::Call::remove_other_vote { .. } | - pallet_democracy::Call::blacklist { .. } | - pallet_democracy::Call::cancel_proposal { .. }, - ) | - RuntimeCall::Council( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::TechnicalCommittee( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::PhragmenElection( - pallet_elections_phragmen::Call::remove_voter { .. } | - pallet_elections_phragmen::Call::submit_candidacy { .. } | - pallet_elections_phragmen::Call::renounce_candidacy { .. } | - pallet_elections_phragmen::Call::remove_member { .. } | - pallet_elections_phragmen::Call::clean_defunct_voters { .. }, - ) | - RuntimeCall::TechnicalMembership( - pallet_membership::Call::add_member { .. } | - pallet_membership::Call::remove_member { .. } | - pallet_membership::Call::swap_member { .. } | - pallet_membership::Call::change_key { .. } | - pallet_membership::Call::set_prime { .. } | - pallet_membership::Call::clear_prime { .. }, - ) | - RuntimeCall::Treasury(..) | - RuntimeCall::Claims( - super::claims::Call::claim { .. } | - super::claims::Call::mint_claim { .. } | - super::claims::Call::move_claim { .. }, - ) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Identity( - pallet_identity::Call::add_registrar { .. } | - pallet_identity::Call::set_identity { .. } | - pallet_identity::Call::clear_identity { .. } | - pallet_identity::Call::request_judgement { .. } | - pallet_identity::Call::cancel_request { .. } | - pallet_identity::Call::set_fee { .. } | - pallet_identity::Call::set_account_id { .. } | - pallet_identity::Call::set_fields { .. } | - pallet_identity::Call::provide_judgement { .. } | - pallet_identity::Call::kill_identity { .. } | - pallet_identity::Call::add_sub { .. } | - pallet_identity::Call::rename_sub { .. } | - pallet_identity::Call::remove_sub { .. } | - pallet_identity::Call::quit_sub { .. }, - ) | - RuntimeCall::Society( - pallet_society::Call::bid { .. } | - pallet_society::Call::unbid { .. } | - pallet_society::Call::vouch { .. } | - pallet_society::Call::unvouch { .. } | - pallet_society::Call::vote { .. } | - pallet_society::Call::defender_vote { .. } | - pallet_society::Call::payout { .. } | - pallet_society::Call::unfound { .. } | - pallet_society::Call::judge_suspended_member { .. } | - pallet_society::Call::judge_suspended_candidate { .. } | - pallet_society::Call::set_max_members { .. }, - ) | - RuntimeCall::Recovery(..) | - RuntimeCall::Vesting(..) | - RuntimeCall::Bounties( - pallet_bounties::Call::propose_bounty { .. } | - pallet_bounties::Call::approve_bounty { .. } | - pallet_bounties::Call::propose_curator { .. } | - pallet_bounties::Call::unassign_curator { .. } | - pallet_bounties::Call::accept_curator { .. } | - pallet_bounties::Call::award_bounty { .. } | - pallet_bounties::Call::claim_bounty { .. } | - pallet_bounties::Call::close_bounty { .. }, - ) | - RuntimeCall::ChildBounties(..) | - RuntimeCall::Gilt(..) => true, - _ => false, - } - } +match_types! { + /// A call filter for the XCM Transact instruction. This is a temporary measure until we + /// properly account for proof size weights. + /// + /// Calls that are allowed through this filter must: + /// 1. Have a fixed weight; + /// 2. Cannot lead to another call being made; + /// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. + pub type SafeCallFilter: impl Contains = { + RuntimeCall::System( + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Society( + pallet_society::Call::bid { .. } | + pallet_society::Call::unbid { .. } | + pallet_society::Call::vouch { .. } | + pallet_society::Call::unvouch { .. } | + pallet_society::Call::vote { .. } | + pallet_society::Call::defender_vote { .. } | + pallet_society::Call::payout { .. } | + pallet_society::Call::unfound { .. } | + pallet_society::Call::judge_suspended_member { .. } | + pallet_society::Call::judge_suspended_candidate { .. } | + pallet_society::Call::set_max_members { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::Gilt(..), + }; } pub struct XcmConfig; diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 8a99e841d493..6c9b1a4558c7 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -21,8 +21,8 @@ use super::{ RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, }; use frame_support::{ - parameter_types, - traits::{Contains, Everything, Nothing}, + match_types, parameter_types, + traits::{Everything, Nothing}, }; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; @@ -99,88 +99,84 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly -/// account for proof size weights. -/// -/// Calls that are allowed through this filter must: -/// 1. Have a fixed weight; -/// 2. Cannot lead to another call being made; -/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. -pub struct SafeCallFilter; -impl Contains for SafeCallFilter { - fn contains(t: &RuntimeCall) -> bool { - match t { - RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, - ) | - RuntimeCall::Babe(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Indices(..) | - RuntimeCall::Balances(..) | - RuntimeCall::Staking( - pallet_staking::Call::bond { .. } | - pallet_staking::Call::bond_extra { .. } | - pallet_staking::Call::unbond { .. } | - pallet_staking::Call::withdraw_unbonded { .. } | - pallet_staking::Call::validate { .. } | - pallet_staking::Call::chill { .. } | - pallet_staking::Call::set_payee { .. } | - pallet_staking::Call::set_controller { .. } | - pallet_staking::Call::set_validator_count { .. } | - pallet_staking::Call::increase_validator_count { .. } | - pallet_staking::Call::scale_validator_count { .. } | - pallet_staking::Call::force_no_eras { .. } | - pallet_staking::Call::force_new_era { .. } | - pallet_staking::Call::set_invulnerables { .. } | - pallet_staking::Call::force_unstake { .. } | - pallet_staking::Call::force_new_era_always { .. } | - pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::reap_stash { .. } | - pallet_staking::Call::set_staking_configs { .. } | - pallet_staking::Call::chill_other { .. } | - pallet_staking::Call::force_apply_min_commission { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::Grandpa(..) | - RuntimeCall::ImOnline(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Identity( - pallet_identity::Call::add_registrar { .. } | - pallet_identity::Call::set_identity { .. } | - pallet_identity::Call::clear_identity { .. } | - pallet_identity::Call::request_judgement { .. } | - pallet_identity::Call::cancel_request { .. } | - pallet_identity::Call::set_fee { .. } | - pallet_identity::Call::set_account_id { .. } | - pallet_identity::Call::set_fields { .. } | - pallet_identity::Call::provide_judgement { .. } | - pallet_identity::Call::kill_identity { .. } | - pallet_identity::Call::add_sub { .. } | - pallet_identity::Call::rename_sub { .. } | - pallet_identity::Call::remove_sub { .. } | - pallet_identity::Call::quit_sub { .. }, - ) | - RuntimeCall::Recovery(..) | - RuntimeCall::Vesting(..) | - RuntimeCall::ElectionProviderMultiPhase(..) | - RuntimeCall::VoterList(..) | - RuntimeCall::NominationPools( - pallet_nomination_pools::Call::join { .. } | - pallet_nomination_pools::Call::bond_extra { .. } | - pallet_nomination_pools::Call::claim_payout { .. } | - pallet_nomination_pools::Call::unbond { .. } | - pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | - pallet_nomination_pools::Call::withdraw_unbonded { .. } | - pallet_nomination_pools::Call::create { .. } | - pallet_nomination_pools::Call::create_with_pool_id { .. } | - pallet_nomination_pools::Call::set_state { .. } | - pallet_nomination_pools::Call::set_configs { .. } | - pallet_nomination_pools::Call::update_roles { .. } | - pallet_nomination_pools::Call::chill { .. }, - ) => true, - _ => false, - } - } +match_types! { + /// A call filter for the XCM Transact instruction. This is a temporary measure until we + /// properly account for proof size weights. + /// + /// Calls that are allowed through this filter must: + /// 1. Have a fixed weight; + /// 2. Cannot lead to another call being made; + /// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. + pub type SafeCallFilter: impl Contains = { + RuntimeCall::System( + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ), + }; } pub struct XcmConfig; diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 6f36c2c883f7..e3a02a9bcf94 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -155,6 +155,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } impl crate::Config for Test { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 595bf3aea65b..d7f3e5b8bd5a 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -131,6 +131,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = TestUniversalAliases; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } impl crate::Config for Test { From a374c9c923d24e5d76fcb7a7c935190615bca0e3 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 18:19:32 +0900 Subject: [PATCH 147/231] Fix comments --- runtime/kusama/src/xcm_config.rs | 14 +++++++------- runtime/polkadot/src/xcm_config.rs | 14 +++++++------- runtime/rococo/src/xcm_config.rs | 14 +++++++------- runtime/westend/src/xcm_config.rs | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 5c155cfbe5e7..47a65391b7c3 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -136,13 +136,13 @@ pub type Barrier = ( ); match_types! { - /// A call filter for the XCM Transact instruction. This is a temporary measure until we - /// properly account for proof size weights. - /// - /// Calls that are allowed through this filter must: - /// 1. Have a fixed weight; - /// 2. Cannot lead to another call being made; - /// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. + // A call filter for the XCM Transact instruction. This is a temporary measure until we + // properly account for proof size weights. + // + // Calls that are allowed through this filter must: + // 1. Have a fixed weight; + // 2. Cannot lead to another call being made; + // 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. pub type SafeCallFilter: impl Contains = { RuntimeCall::System( frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index a6bef2f86816..7559ad62c027 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -134,13 +134,13 @@ pub type Barrier = ( ); match_types! { - /// A call filter for the XCM Transact instruction. This is a temporary measure until we - /// properly account for proof size weights. - /// - /// Calls that are allowed through this filter must: - /// 1. Have a fixed weight; - /// 2. Cannot lead to another call being made; - /// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. + // A call filter for the XCM Transact instruction. This is a temporary measure until we + // properly account for proof size weights. + // + // Calls that are allowed through this filter must: + // 1. Have a fixed weight; + // 2. Cannot lead to another call being made; + // 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. pub type SafeCallFilter: impl Contains = { RuntimeCall::System( frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 1def41f62cd7..38c00346d93c 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -134,13 +134,13 @@ pub type Barrier = ( ); match_types! { - /// A call filter for the XCM Transact instruction. This is a temporary measure until we - /// properly account for proof size weights. - /// - /// Calls that are allowed through this filter must: - /// 1. Have a fixed weight; - /// 2. Cannot lead to another call being made; - /// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. + // A call filter for the XCM Transact instruction. This is a temporary measure until we + // properly account for proof size weights. + // + // Calls that are allowed through this filter must: + // 1. Have a fixed weight; + // 2. Cannot lead to another call being made; + // 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. pub type SafeCallFilter: impl Contains = { RuntimeCall::System( frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 6c9b1a4558c7..209512a7032c 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -100,13 +100,13 @@ pub type Barrier = ( ); match_types! { - /// A call filter for the XCM Transact instruction. This is a temporary measure until we - /// properly account for proof size weights. - /// - /// Calls that are allowed through this filter must: - /// 1. Have a fixed weight; - /// 2. Cannot lead to another call being made; - /// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. + // A call filter for the XCM Transact instruction. This is a temporary measure until we + // properly account for proof size weights. + // + // Calls that are allowed through this filter must: + // 1. Have a fixed weight; + // 2. Cannot lead to another call being made; + // 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. pub type SafeCallFilter: impl Contains = { RuntimeCall::System( frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, From 0801bc5edf025ea3196813b2078fadd8373b452b Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 18:33:14 +0900 Subject: [PATCH 148/231] Fixes --- runtime/rococo/src/xcm_config.rs | 2 +- runtime/westend/src/xcm_config.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 38c00346d93c..c5422879c73a 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -244,7 +244,7 @@ match_types! { pallet_bounties::Call::close_bounty { .. }, ) | RuntimeCall::ChildBounties(..) | - RuntimeCall::Gilt(..), + RuntimeCall::Gilt(..) }; } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 209512a7032c..2eeb4bdec785 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -175,7 +175,7 @@ match_types! { pallet_nomination_pools::Call::set_configs { .. } | pallet_nomination_pools::Call::update_roles { .. } | pallet_nomination_pools::Call::chill { .. }, - ), + ) }; } From ded3655ec6689a30b7fb1a5dafed1f9e9252281d Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 3 Dec 2022 22:41:49 +0900 Subject: [PATCH 149/231] Introduce WithOriginFilter and apply it as the CallDispatcher for runtimes --- runtime/kusama/src/xcm_config.rs | 8 ++++++-- runtime/polkadot/src/xcm_config.rs | 8 ++++++-- runtime/rococo/src/xcm_config.rs | 7 ++++--- runtime/westend/src/xcm_config.rs | 9 ++++++--- xcm/xcm-executor/src/traits/conversion.rs | 23 ++++++++++++++++++++++- xcm/xcm-executor/src/traits/mod.rs | 6 ++++-- 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 47a65391b7c3..edfe9969e706 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -35,6 +35,7 @@ use xcm_builder::{ MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; +use xcm_executor::traits::WithOriginFilter; parameter_types! { /// The location of the KSM token, from the context of this chain. Since this token is native to this @@ -157,6 +158,7 @@ match_types! { pallet_staking::Call::unbond { .. } | pallet_staking::Call::withdraw_unbonded { .. } | pallet_staking::Call::validate { .. } | + pallet_staking::Call::nominate { .. } | pallet_staking::Call::chill { .. } | pallet_staking::Call::set_payee { .. } | pallet_staking::Call::set_controller { .. } | @@ -169,6 +171,7 @@ match_types! { pallet_staking::Call::force_unstake { .. } | pallet_staking::Call::force_new_era_always { .. } | pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::rebond { .. } | pallet_staking::Call::reap_stash { .. } | pallet_staking::Call::set_staking_configs { .. } | pallet_staking::Call::chill_other { .. } | @@ -303,7 +306,8 @@ match_types! { pallet_nomination_pools::Call::set_configs { .. } | pallet_nomination_pools::Call::update_roles { .. } | pallet_nomination_pools::Call::chill { .. }, - ) + ) | + RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) }; } @@ -337,7 +341,7 @@ impl xcm_executor::Config for XcmConfig { // No bridges yet... type MessageExporter = (); type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; + type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; } diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 7559ad62c027..4d9dd60d473b 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -34,6 +34,7 @@ use xcm_builder::{ IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; +use xcm_executor::traits::WithOriginFilter; parameter_types! { /// The location of the DOT token, from the context of this chain. Since this token is native to this @@ -155,6 +156,7 @@ match_types! { pallet_staking::Call::unbond { .. } | pallet_staking::Call::withdraw_unbonded { .. } | pallet_staking::Call::validate { .. } | + pallet_staking::Call::nominate { .. } | pallet_staking::Call::chill { .. } | pallet_staking::Call::set_payee { .. } | pallet_staking::Call::set_controller { .. } | @@ -167,6 +169,7 @@ match_types! { pallet_staking::Call::force_unstake { .. } | pallet_staking::Call::force_new_era_always { .. } | pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::rebond { .. } | pallet_staking::Call::reap_stash { .. } | pallet_staking::Call::set_staking_configs { .. } | pallet_staking::Call::chill_other { .. } | @@ -268,7 +271,8 @@ match_types! { pallet_nomination_pools::Call::set_configs { .. } | pallet_nomination_pools::Call::update_roles { .. } | pallet_nomination_pools::Call::chill { .. }, - ) + ) | + RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) }; } @@ -299,7 +303,7 @@ impl xcm_executor::Config for XcmConfig { // No bridges yet... type MessageExporter = (); type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; + type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index c5422879c73a..11f24d7936f0 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -35,7 +35,7 @@ use xcm_builder::{ MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; -use xcm_executor::XcmExecutor; +use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); @@ -244,7 +244,8 @@ match_types! { pallet_bounties::Call::close_bounty { .. }, ) | RuntimeCall::ChildBounties(..) | - RuntimeCall::Gilt(..) + RuntimeCall::Gilt(..) | + RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) }; } @@ -276,7 +277,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; + type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 2eeb4bdec785..5371afb527bd 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -34,7 +34,7 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; -use xcm_executor::XcmExecutor; +use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); @@ -121,6 +121,7 @@ match_types! { pallet_staking::Call::unbond { .. } | pallet_staking::Call::withdraw_unbonded { .. } | pallet_staking::Call::validate { .. } | + pallet_staking::Call::nominate { .. } | pallet_staking::Call::chill { .. } | pallet_staking::Call::set_payee { .. } | pallet_staking::Call::set_controller { .. } | @@ -133,6 +134,7 @@ match_types! { pallet_staking::Call::force_unstake { .. } | pallet_staking::Call::force_new_era_always { .. } | pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::rebond { .. } | pallet_staking::Call::reap_stash { .. } | pallet_staking::Call::set_staking_configs { .. } | pallet_staking::Call::chill_other { .. } | @@ -175,7 +177,8 @@ match_types! { pallet_nomination_pools::Call::set_configs { .. } | pallet_nomination_pools::Call::update_roles { .. } | pallet_nomination_pools::Call::chill { .. }, - ) + ) | + RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) }; } @@ -204,7 +207,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; + type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; } diff --git a/xcm/xcm-executor/src/traits/conversion.rs b/xcm/xcm-executor/src/traits/conversion.rs index 7b5ce42a7aa1..73b02bfe0adc 100644 --- a/xcm/xcm-executor/src/traits/conversion.rs +++ b/xcm/xcm-executor/src/traits/conversion.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use frame_support::traits::{Contains, OriginTrait}; use parity_scale_codec::{Decode, Encode}; use sp_runtime::{traits::Dispatchable, DispatchErrorWithPostInfo}; -use sp_std::{borrow::Borrow, prelude::*, result::Result}; +use sp_std::{borrow::Borrow, marker::PhantomData, prelude::*, result::Result}; use xcm::latest::prelude::*; /// Generic third-party conversion trait. Use this when you don't want to force the user to use default @@ -215,6 +216,26 @@ pub trait CallDispatcher { ) -> Result>; } +pub struct WithOriginFilter(PhantomData); +impl CallDispatcher for WithOriginFilter +where + Call: Dispatchable, + Call::RuntimeOrigin: OriginTrait, + <::RuntimeOrigin as OriginTrait>::Call: 'static, + Filter: Contains<<::RuntimeOrigin as OriginTrait>::Call> + 'static, +{ + fn dispatch( + call: Call, + mut origin: ::RuntimeOrigin, + ) -> Result< + ::PostInfo, + DispatchErrorWithPostInfo<::PostInfo>, + > { + origin.add_filter(Filter::contains); + call.dispatch(origin) + } +} + // We implement it for every calls so they can dispatch themselves // (without any change). impl CallDispatcher for Call { diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index 989c9d4e0006..94fe7e98a7db 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -17,7 +17,9 @@ //! Various traits used in configuring the executor. mod conversion; -pub use conversion::{CallDispatcher, Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry}; +pub use conversion::{ + CallDispatcher, Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry, WithOriginFilter, +}; mod drop_assets; pub use drop_assets::{ClaimAssets, DropAssets}; mod asset_lock; @@ -50,6 +52,6 @@ pub mod prelude { Decoded, DropAssets, Enact, Encoded, Error, ExportXcm, FeeManager, FeeReason, Identity, JustTry, LockError, MatchesFungible, MatchesFungibles, MatchesNonFungible, MatchesNonFungibles, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, - WeightBounds, WeightTrader, + WeightBounds, WeightTrader, WithOriginFilter, }; } From 5f8ffbbc5e26f6f4c80e5e9ee6cea513f5ff28a9 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 6 Dec 2022 17:08:07 +0900 Subject: [PATCH 150/231] Fixes --- runtime/kusama/src/xcm_config.rs | 1 - xcm/src/v3/junctions.rs | 6 +++--- xcm/src/v3/multiasset.rs | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index edfe9969e706..a036cc959a5f 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -291,7 +291,6 @@ match_types! { ) | RuntimeCall::ChildBounties(..) | RuntimeCall::ElectionProviderMultiPhase(..) | - RuntimeCall::Gilt(..) | RuntimeCall::VoterList(..) | RuntimeCall::NominationPools( pallet_nomination_pools::Call::join { .. } | diff --git a/xcm/src/v3/junctions.rs b/xcm/src/v3/junctions.rs index 9bf7905a86a3..d596489b209e 100644 --- a/xcm/src/v3/junctions.rs +++ b/xcm/src/v3/junctions.rs @@ -214,8 +214,8 @@ impl Junctions { /// This will return an `Err` if the first item is not a `GlobalConsensus`, which would indicate /// that this value is not a universal location. pub fn global_consensus(&self) -> Result { - if let Some(Junction::GlobalConsensus(ref network)) = self.first() { - Ok(network.clone()) + if let Some(Junction::GlobalConsensus(network)) = self.first() { + Ok(*network) } else { Err(()) } @@ -503,7 +503,7 @@ impl Junctions { /// Returns a mutable reference to the junction at index `i`, or `None` if the location doesn't contain that many /// elements. - pub fn at_mut<'a>(&'a mut self, i: usize) -> Option<&'a mut Junction> { + pub fn at_mut(&mut self, i: usize) -> Option<&mut Junction> { Some(match (i, self) { (0, Junctions::X1(ref mut a)) => a, (0, Junctions::X2(ref mut a, ..)) => a, diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index bbd26b9e2dcd..493d7bcfe76c 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -345,7 +345,7 @@ impl AssetId { /// Prepend a `MultiLocation` to a concrete asset, giving it a new root location. pub fn prepend_with(&mut self, prepend: &MultiLocation) -> Result<(), ()> { if let AssetId::Concrete(ref mut l) = self { - l.prepend_with(prepend.clone()).map_err(|_| ())?; + l.prepend_with(*prepend).map_err(|_| ())?; } Ok(()) } @@ -640,7 +640,7 @@ impl MultiAssets { target: &MultiLocation, context: InteriorMultiLocation, ) -> Result<(), ()> { - self.0.iter_mut().try_for_each(|i| i.reanchor(target, context.clone())) + self.0.iter_mut().try_for_each(|i| i.reanchor(target, context)) } /// Return a reference to an item at a specific index or `None` if it doesn't exist. From f5fde97e5e6e11b30d38cfa757481d34ace93b90 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 7 Dec 2022 02:49:31 +0900 Subject: [PATCH 151/231] Appease clippy and fixes --- runtime/kusama/src/xcm_config.rs | 6 ++- runtime/polkadot/src/xcm_config.rs | 6 ++- runtime/rococo/src/xcm_config.rs | 5 ++- runtime/westend/src/xcm_config.rs | 5 ++- xcm/xcm-executor/src/assets.rs | 36 ++++++++-------- xcm/xcm-executor/src/lib.rs | 43 ++++++++----------- xcm/xcm-executor/src/traits/asset_exchange.rs | 2 +- 7 files changed, 52 insertions(+), 51 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index a036cc959a5f..3e191c198492 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -49,7 +49,9 @@ parameter_types! { /// Since Kusama is a top-level relay-chain with its own consensus, it's just our network ID. pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); /// The check account, which holds any native assets that have been teleported out and not back in (yet). - pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); + pub CheckAccount: AccountId = XcmPallet::check_account(); + /// The check account that is allowed to mint assets locally. + pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); } /// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine @@ -75,7 +77,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, // We track our teleports in/out to keep total issuance correct. - CheckAccount, + LocalCheckAccount, >; /// The means that we convert the XCM message origin location into a local dispatch origin. diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 4d9dd60d473b..fe0e5d6b94fb 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -46,7 +46,9 @@ parameter_types! { /// Our location in the universe of consensus systems. pub const UniversalLocation: InteriorMultiLocation = X1(GlobalConsensus(ThisNetwork::get())); /// The check account, which holds any native assets that have been teleported out and not back in (yet). - pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); + pub CheckAccount: AccountId = XcmPallet::check_account(); + /// The check account that is allowed to mint assets locally. + pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); } /// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine @@ -72,7 +74,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, // We track our teleports in/out to keep total issuance correct. - CheckAccount, + LocalCheckAccount, >; /// The means that we convert an XCM origin `MultiLocation` into the runtime's `Origin` type for diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 11f24d7936f0..74c8c4b929fc 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -41,7 +41,8 @@ parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub const ThisNetwork: NetworkId = NetworkId::Rococo; pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); - pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); + pub CheckAccount: AccountId = XcmPallet::check_account(); + pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); } pub type LocationConverter = @@ -61,7 +62,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, // We track our teleports in/out to keep total issuance correct. - CheckAccount, + LocalCheckAccount, >; /// The means that we convert an the XCM message origin location into a local dispatch origin. diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 5371afb527bd..a43bc16155f5 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -40,7 +40,8 @@ parameter_types! { pub const TokenLocation: MultiLocation = Here.into_location(); pub const ThisNetwork: NetworkId = Westend; pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); - pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); + pub CheckAccount: AccountId = XcmPallet::check_account(); + pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); } pub type LocationConverter = @@ -56,7 +57,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, // It's a native asset so we keep track of the teleports to maintain total issuance. - CheckAccount, + LocalCheckAccount, >; type LocalOriginConverter = ( diff --git a/xcm/xcm-executor/src/assets.rs b/xcm/xcm-executor/src/assets.rs index 9c6c57c05326..9d5d94722aa8 100644 --- a/xcm/xcm-executor/src/assets.rs +++ b/xcm/xcm-executor/src/assets.rs @@ -103,14 +103,14 @@ impl Assets { pub fn fungible_assets_iter(&self) -> impl Iterator + '_ { self.fungible .iter() - .map(|(id, &amount)| MultiAsset { fun: Fungible(amount), id: id.clone() }) + .map(|(id, &amount)| MultiAsset { fun: Fungible(amount), id: *id }) } /// A borrowing iterator over the non-fungible assets. pub fn non_fungible_assets_iter(&self) -> impl Iterator + '_ { self.non_fungible .iter() - .map(|(id, instance)| MultiAsset { fun: NonFungible(instance.clone()), id: id.clone() }) + .map(|(id, instance)| MultiAsset { fun: NonFungible(*instance), id: *id }) } /// A consuming iterator over all assets. @@ -248,10 +248,10 @@ impl Assets { /// Returns `true` if `asset` is contained within `self`. pub fn contains_asset(&self, asset: &MultiAsset) -> bool { match asset { - MultiAsset { fun: Fungible(ref amount), ref id } => + MultiAsset { fun: Fungible(amount), id } => self.fungible.get(id).map_or(false, |a| a >= amount), - MultiAsset { fun: NonFungible(ref instance), ref id } => - self.non_fungible.contains(&(id.clone(), instance.clone())), + MultiAsset { fun: NonFungible(instance), id } => + self.non_fungible.contains(&(*id, *instance)), } } @@ -274,13 +274,13 @@ impl Assets { pub fn ensure_contains(&self, assets: &MultiAssets) -> Result<(), TakeError> { for asset in assets.inner().iter() { match asset { - MultiAsset { fun: Fungible(ref amount), ref id } => { + MultiAsset { fun: Fungible(amount), id } => { if self.fungible.get(id).map_or(true, |a| a < amount) { - return Err(TakeError::AssetUnderflow((id.clone(), *amount).into())) + return Err(TakeError::AssetUnderflow((*id, *amount).into())) } }, - MultiAsset { fun: NonFungible(ref instance), ref id } => { - let id_instance = (id.clone(), instance.clone()); + MultiAsset { fun: NonFungible(instance), id } => { + let id_instance = (*id, *instance); if !self.non_fungible.contains(&id_instance) { return Err(TakeError::AssetUnderflow(id_instance.into())) } @@ -460,14 +460,14 @@ impl Assets { if maybe_limit.map_or(true, |l| self.len() <= l) { return self.clone() } else { - for (c, &amount) in self.fungible.iter() { - masked.fungible.insert(c.clone(), amount); + for (&c, &amount) in self.fungible.iter() { + masked.fungible.insert(c, amount); if maybe_limit.map_or(false, |l| masked.len() >= l) { return masked } } for (c, instance) in self.non_fungible.iter() { - masked.non_fungible.insert((c.clone(), instance.clone())); + masked.non_fungible.insert((*c, *instance)); if maybe_limit.map_or(false, |l| masked.len() >= l) { return masked } @@ -477,13 +477,13 @@ impl Assets { MultiAssetFilter::Wild(AllOfCounted { fun: WildFungible, id, .. }) | MultiAssetFilter::Wild(AllOf { fun: WildFungible, id }) => if let Some(&amount) = self.fungible.get(&id) { - masked.fungible.insert(id.clone(), amount); + masked.fungible.insert(*id, amount); }, MultiAssetFilter::Wild(AllOfCounted { fun: WildNonFungible, id, .. }) | MultiAssetFilter::Wild(AllOf { fun: WildNonFungible, id }) => for (c, instance) in self.non_fungible.iter() { if c == id { - masked.non_fungible.insert((c.clone(), instance.clone())); + masked.non_fungible.insert((*c, *instance)); if maybe_limit.map_or(false, |l| masked.len() >= l) { return masked } @@ -492,13 +492,13 @@ impl Assets { MultiAssetFilter::Definite(assets) => for asset in assets.inner().iter() { match asset { - MultiAsset { fun: Fungible(ref amount), ref id } => { + MultiAsset { fun: Fungible(amount), id } => { if let Some(m) = self.fungible.get(id) { - masked.subsume((id.clone(), Fungible(*amount.min(m))).into()); + masked.subsume((*id, Fungible(*amount.min(m))).into()); } }, - MultiAsset { fun: NonFungible(ref instance), ref id } => { - let id_instance = (id.clone(), instance.clone()); + MultiAsset { fun: NonFungible(instance), id } => { + let id_instance = (*id, *instance); if self.non_fungible.contains(&id_instance) { masked.subsume(id_instance.into()); } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 870ed037a7ca..bc8ec4e16027 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -272,7 +272,7 @@ impl XcmExecutor { Self { holding: Assets::new(), holding_limit: Config::MaxAssetsIntoHolding::get() as usize, - context: XcmContext { origin: Some(origin.clone()), message_hash, topic: None }, + context: XcmContext { origin: Some(origin), message_hash, topic: None }, original_origin: origin, trader: Config::Trader::new(), error: None, @@ -385,7 +385,7 @@ impl XcmExecutor { } fn cloned_origin(&self) -> Option { - self.context.origin.clone() + self.context.origin } /// Send an XCM, charging fees from Holding as needed. @@ -428,7 +428,7 @@ impl XcmExecutor { fn subsume_asset(&mut self, asset: MultiAsset) -> Result<(), XcmError> { // worst-case, holding.len becomes 2 * holding_limit. - ensure!(self.holding.len() + 1 <= self.holding_limit * 2, XcmError::HoldingWouldOverflow); + ensure!(self.holding.len() < self.holding_limit * 2, XcmError::HoldingWouldOverflow); self.holding.subsume(asset); Ok(()) } @@ -469,7 +469,7 @@ impl XcmExecutor { match instr { WithdrawAsset(assets) => { // Take `assets` from the origin account (on-chain) and place in holding. - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; for asset in assets.into_inner().into_iter() { Config::AssetTransactor::withdraw_asset(&asset, &origin, Some(&self.context))?; self.subsume_asset(asset)?; @@ -478,7 +478,7 @@ impl XcmExecutor { }, ReserveAssetDeposited(assets) => { // check whether we trust origin to be our reserve location for this asset. - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; for asset in assets.into_inner().into_iter() { // Must ensure that we recognise the asset as being managed by the origin. ensure!( @@ -516,7 +516,7 @@ impl XcmExecutor { Ok(()) }, ReceiveTeleportedAsset(assets) => { - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; // check whether we trust origin to teleport this asset to us via config trait. for asset in assets.inner() { // We only trust the origin to send us assets that they identify as their @@ -538,7 +538,7 @@ impl XcmExecutor { }, Transact { origin_kind, require_weight_at_most, mut call } => { // We assume that the Relay-chain is allowed to use transact on this parachain. - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; // TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain let message_call = call.take_decoded().map_err(|_| XcmError::FailedToDecode)?; @@ -800,7 +800,7 @@ impl XcmExecutor { UniversalOrigin(new_global) => { let universal_location = Config::UniversalLocation::get(); ensure!(universal_location.first() != Some(&new_global), XcmError::InvalidLocation); - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; let origin_xform = (origin, new_global); let ok = Config::UniversalAliases::contains(&origin_xform); ensure!(ok, XcmError::InvalidLocation); @@ -817,7 +817,7 @@ impl XcmExecutor { // // This only works because the remote chain empowers the bridge // to speak for the local network. - let origin = self.context.origin.as_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.context.origin.as_ref().ok_or(XcmError::BadOrigin)?; let universal_source = Config::UniversalLocation::get() .within_global(origin) .map_err(|()| XcmError::Unanchored)?; @@ -838,10 +838,9 @@ impl XcmExecutor { Ok(()) }, LockAsset { asset, unlocker } => { - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; let (remote_asset, context) = Self::try_reanchor(asset.clone(), &unlocker)?; - let lock_ticket = - Config::AssetLocker::prepare_lock(unlocker.clone(), asset, origin.clone())?; + let lock_ticket = Config::AssetLocker::prepare_lock(unlocker, asset, origin)?; let owner = origin.reanchored(&unlocker, context).map_err(|_| XcmError::ReanchorFailed)?; let msg = Xcm::<()>(vec![NoteUnlockable { asset: remote_asset, owner }]); @@ -852,25 +851,21 @@ impl XcmExecutor { Ok(()) }, UnlockAsset { asset, target } => { - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); - Config::AssetLocker::prepare_unlock(origin.clone(), asset, target)?.enact()?; + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + Config::AssetLocker::prepare_unlock(origin, asset, target)?.enact()?; Ok(()) }, NoteUnlockable { asset, owner } => { - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; Config::AssetLocker::note_unlockable(origin, asset, owner)?; Ok(()) }, RequestUnlock { asset, locker } => { - let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?.clone(); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; let remote_asset = Self::try_reanchor(asset.clone(), &locker)?.0; - let reduce_ticket = Config::AssetLocker::prepare_reduce_unlockable( - locker.clone(), - asset, - origin.clone(), - )?; - let msg = - Xcm::<()>(vec![UnlockAsset { asset: remote_asset, target: origin.clone() }]); + let reduce_ticket = + Config::AssetLocker::prepare_reduce_unlockable(locker, asset, origin)?; + let msg = Xcm::<()>(vec![UnlockAsset { asset: remote_asset, target: origin }]); let (ticket, price) = validate_send::(locker, msg)?; self.take_fee(price, FeeReason::RequestUnlock)?; reduce_ticket.enact()?; @@ -977,7 +972,7 @@ impl XcmExecutor { ) -> Result<(MultiAsset, InteriorMultiLocation), XcmError> { let reanchor_context = Config::UniversalLocation::get(); let asset = asset - .reanchored(&destination, reanchor_context.clone()) + .reanchored(&destination, reanchor_context) .map_err(|()| XcmError::ReanchorFailed)?; Ok((asset, reanchor_context)) } diff --git a/xcm/xcm-executor/src/traits/asset_exchange.rs b/xcm/xcm-executor/src/traits/asset_exchange.rs index 2d12606777c4..dd2eae23f8a2 100644 --- a/xcm/xcm-executor/src/traits/asset_exchange.rs +++ b/xcm/xcm-executor/src/traits/asset_exchange.rs @@ -48,7 +48,7 @@ impl AssetExchange for Tuple { maximal: bool, ) -> Result { for_tuples!( #( - let give = match Tuple::exchange_asset(origin.clone(), give, want, maximal) { + let give = match Tuple::exchange_asset(origin, give, want, maximal) { Ok(r) => return Ok(r), Err(a) => a, }; From 229bc003ab0c6a130c08ebc511c05d1ae15e789f Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 7 Dec 2022 03:02:45 +0900 Subject: [PATCH 152/231] Fixes --- runtime/rococo/src/xcm_config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 74c8c4b929fc..1b059fb54abb 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -245,7 +245,6 @@ match_types! { pallet_bounties::Call::close_bounty { .. }, ) | RuntimeCall::ChildBounties(..) | - RuntimeCall::Gilt(..) | RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) }; } From 0987294835c3e8595ba07de9727147e0c41af0cc Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 7 Dec 2022 03:18:19 +0900 Subject: [PATCH 153/231] Fix more clippy issues --- xcm/pallet-xcm/src/lib.rs | 69 +++++++++--------------- xcm/xcm-builder/src/barriers.rs | 6 +-- xcm/xcm-builder/src/matches_token.rs | 6 +-- xcm/xcm-builder/src/test_utils.rs | 6 +-- xcm/xcm-builder/src/universal_exports.rs | 6 +-- xcm/xcm-executor/src/lib.rs | 2 +- 6 files changed, 37 insertions(+), 58 deletions(-) diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 061864651236..e355eb19c3ea 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -721,11 +721,11 @@ pub mod pallet { ) -> DispatchResult { let origin_location = T::SendXcmOrigin::ensure_origin(origin)?; let interior: Junctions = - origin_location.clone().try_into().map_err(|_| Error::::InvalidOrigin)?; + origin_location.try_into().map_err(|_| Error::::InvalidOrigin)?; let dest = MultiLocation::try_from(*dest).map_err(|()| Error::::BadVersion)?; let message: Xcm<()> = (*message).try_into().map_err(|()| Error::::BadVersion)?; - Self::send_xcm(interior, dest.clone(), message.clone()).map_err(Error::::from)?; + Self::send_xcm(interior, dest, message.clone()).map_err(Error::::from)?; Self::deposit_event(Event::Sent(origin_location, dest, message)); Ok(()) } @@ -1076,7 +1076,6 @@ impl Pallet { let weight_limit = match maybe_weight_limit { Some(weight_limit) => weight_limit, None => { - let beneficiary = beneficiary.clone(); let fees = fees.clone(); let mut remote_message = Xcm(vec![ ReserveAssetDeposited(assets.clone()), @@ -1134,7 +1133,6 @@ impl Pallet { let weight_limit = match maybe_weight_limit { Some(weight_limit) => weight_limit, None => { - let beneficiary = beneficiary.clone(); let fees = fees.clone(); let mut remote_message = Xcm(vec![ ReceiveTeleportedAsset(assets.clone()), @@ -1234,7 +1232,7 @@ impl Pallet { let response = Response::Version(xcm_version); let message = Xcm(vec![QueryResponse { query_id, response, max_weight, querier: None }]); - let event = match send_xcm::(new_key.clone(), message) { + let event = match send_xcm::(new_key, message) { Ok((_hash, cost)) => { let value = (query_id, max_weight, xcm_version); VersionNotifyTargets::::insert(XCM_VERSION, key, value); @@ -1283,7 +1281,7 @@ impl Pallet { max_weight, querier: None, }]); - let event = match send_xcm::(new_key.clone(), message) { + let event = match send_xcm::(new_key, message) { Ok((_hash, cost)) => { VersionNotifyTargets::::insert( XCM_VERSION, @@ -1309,7 +1307,7 @@ impl Pallet { /// Request that `dest` informs us of its version. pub fn request_version_notify(dest: impl Into) -> XcmResult { let dest = dest.into(); - let versioned_dest = VersionedMultiLocation::from(dest.clone()); + let versioned_dest = VersionedMultiLocation::from(dest); let already = VersionNotifiers::::contains_key(XCM_VERSION, &versioned_dest); ensure!(!already, XcmError::InvalidLocation); let query_id = QueryCounter::::mutate(|q| { @@ -1319,7 +1317,7 @@ impl Pallet { }); // TODO #3735: Correct weight. let instruction = SubscribeVersion { query_id, max_response_weight: Weight::zero() }; - let (_hash, cost) = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; + let (_hash, cost) = send_xcm::(dest, Xcm(vec![instruction]))?; Self::deposit_event(Event::VersionNotifyRequested(dest, cost)); VersionNotifiers::::insert(XCM_VERSION, &versioned_dest, query_id); let query_status = @@ -1334,7 +1332,7 @@ impl Pallet { let versioned_dest = LatestVersionedMultiLocation(&dest); let query_id = VersionNotifiers::::take(XCM_VERSION, versioned_dest) .ok_or(XcmError::InvalidLocation)?; - let (_hash, cost) = send_xcm::(dest.clone(), Xcm(vec![UnsubscribeVersion]))?; + let (_hash, cost) = send_xcm::(dest, Xcm(vec![UnsubscribeVersion]))?; Self::deposit_event(Event::VersionNotifyUnrequested(dest, cost)); Queries::::remove(query_id); Ok(()) @@ -1351,7 +1349,7 @@ impl Pallet { let interior = interior.into(); let dest = dest.into(); let maybe_fee_payer = if interior != Junctions::Here { - message.0.insert(0, DescendOrigin(interior.clone())); + message.0.insert(0, DescendOrigin(interior)); Some(interior.into()) } else { None @@ -1508,7 +1506,7 @@ impl Pallet { "XCM version is unknown for destination: {:?}", dest, ); - let versioned_dest = VersionedMultiLocation::from(dest.clone()); + let versioned_dest = VersionedMultiLocation::from(*dest); VersionDiscoveryQueue::::mutate(|q| { if let Some(index) = q.iter().position(|i| &i.0 == &versioned_dest) { // exists - just bump the count. @@ -1525,7 +1523,7 @@ impl Pallet { /// - the `assets` are not known on this chain; /// - the `assets` cannot be withdrawn with that location as the Origin. fn charge_fees(location: MultiLocation, assets: MultiAssets) -> DispatchResult { - T::XcmExecutor::charge_fees(location.clone(), assets.clone()) + T::XcmExecutor::charge_fees(location, assets.clone()) .map_err(|_| Error::::FeesNotMet)?; Self::deposit_event(Event::FeesPaid(location, assets)); Ok(()) @@ -1551,7 +1549,7 @@ impl xcm_executor::traits::Enact for LockTicket { }, None => { locks - .try_push((self.amount, self.unlocker.clone().into())) + .try_push((self.amount, self.unlocker.into())) .map_err(|(_balance, _location)| UnexpectedState)?; }, } @@ -1760,8 +1758,8 @@ impl VersionChangeNotifier for Pallet { let xcm_version = T::AdvertisedXcmVersion::get(); let response = Response::Version(xcm_version); let instruction = QueryResponse { query_id, response, max_weight, querier: None }; - let (_hash, cost) = send_xcm::(dest.clone(), Xcm(vec![instruction]))?; - Self::deposit_event(Event::::VersionNotifyStarted(dest.clone(), cost)); + let (_hash, cost) = send_xcm::(*dest, Xcm(vec![instruction]))?; + Self::deposit_event(Event::::VersionNotifyStarted(*dest, cost)); let value = (query_id, max_weight, xcm_version); VersionNotifyTargets::::insert(XCM_VERSION, versioned_dest, value); @@ -1790,7 +1788,7 @@ impl DropAssets for Pallet { let versioned = VersionedMultiAssets::from(MultiAssets::from(assets)); let hash = BlakeTwo256::hash_of(&(&origin, &versioned)); AssetTraps::::mutate(hash, |n| *n += 1); - Self::deposit_event(Event::AssetsTrapped(hash, origin.clone(), versioned)); + Self::deposit_event(Event::AssetsTrapped(hash, *origin, versioned)); // TODO #3735: Put the real weight in there. Weight::zero() } @@ -1819,7 +1817,7 @@ impl ClaimAssets for Pallet { 1 => AssetTraps::::remove(hash), n => AssetTraps::::insert(hash, n - 1), } - Self::deposit_event(Event::AssetsClaimed(hash, origin.clone(), versioned)); + Self::deposit_event(Event::AssetsClaimed(hash, *origin, versioned)); return true } } @@ -1860,19 +1858,11 @@ impl OnResponse for Pallet { let origin: MultiLocation = match expected_origin.try_into() { Ok(o) if &o == origin => o, Ok(o) => { - Self::deposit_event(Event::InvalidResponder( - origin.clone(), - query_id, - Some(o), - )); + Self::deposit_event(Event::InvalidResponder(*origin, query_id, Some(o))); return Weight::zero() }, _ => { - Self::deposit_event(Event::InvalidResponder( - origin.clone(), - query_id, - None, - )); + Self::deposit_event(Event::InvalidResponder(*origin, query_id, None)); // TODO #3735: Correct weight for this. return Weight::zero() }, @@ -1881,10 +1871,7 @@ impl OnResponse for Pallet { if !is_active { Queries::::insert( query_id, - QueryStatus::VersionNotifier { - origin: origin.clone().into(), - is_active: true, - }, + QueryStatus::VersionNotifier { origin: origin.into(), is_active: true }, ); } // We're being notified of a version change. @@ -1904,16 +1891,13 @@ impl OnResponse for Pallet { let match_querier = match MultiLocation::try_from(match_querier) { Ok(mq) => mq, Err(_) => { - Self::deposit_event(Event::InvalidQuerierVersion( - origin.clone(), - query_id, - )); + Self::deposit_event(Event::InvalidQuerierVersion(*origin, query_id)); return Weight::zero() }, }; if querier.map_or(true, |q| q != &match_querier) { Self::deposit_event(Event::InvalidQuerier( - origin.clone(), + *origin, query_id, match_querier, querier.cloned(), @@ -1924,16 +1908,13 @@ impl OnResponse for Pallet { let responder = match MultiLocation::try_from(responder) { Ok(r) => r, Err(_) => { - Self::deposit_event(Event::InvalidResponderVersion( - origin.clone(), - query_id, - )); + Self::deposit_event(Event::InvalidResponderVersion(*origin, query_id)); return Weight::zero() }, }; if origin != &responder { Self::deposit_event(Event::InvalidResponder( - origin.clone(), + *origin, query_id, Some(responder), )); @@ -1961,7 +1942,7 @@ impl OnResponse for Pallet { Self::deposit_event(e); return Weight::zero() } - let dispatch_origin = Origin::Response(origin.clone()).into(); + let dispatch_origin = Origin::Response(*origin).into(); match call.dispatch(dispatch_origin) { Ok(post_info) => { let e = Event::Notified(query_id, pallet_index, call_index); @@ -1998,8 +1979,8 @@ impl OnResponse for Pallet { } }, _ => { - Self::deposit_event(Event::UnexpectedResponse(origin.clone(), query_id)); - return Weight::zero() + Self::deposit_event(Event::UnexpectedResponse(*origin, query_id)); + Weight::zero() }, } } diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index e23065c09c83..96f012cc55e4 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -171,7 +171,7 @@ impl< "WithComputedOrigin origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", origin, instructions, max_weight, weight_credit, ); - let mut actual_origin = origin.clone(); + let mut actual_origin = *origin; let mut skipped = 0; // NOTE: We do not check the validity of `UniversalOrigin` here, meaning that a malicious // origin could place a `UniversalOrigin` in order to spoof some location which gets free @@ -183,10 +183,10 @@ impl< Some(UniversalOrigin(new_global)) => { // Note the origin is *relative to local consensus*! So we need to escape local // consensus with the `parents` before diving in into the `universal_location`. - actual_origin = X1(new_global.clone()).relative_to(&LocalUniversal::get()); + actual_origin = X1(*new_global).relative_to(&LocalUniversal::get()); }, Some(DescendOrigin(j)) => { - actual_origin.append_with(j.clone()).map_err(|_| ())?; + actual_origin.append_with(*j).map_err(|_| ())?; }, _ => break, } diff --git a/xcm/xcm-builder/src/matches_token.rs b/xcm/xcm-builder/src/matches_token.rs index 391eb061fa10..53b844c75764 100644 --- a/xcm/xcm-builder/src/matches_token.rs +++ b/xcm/xcm-builder/src/matches_token.rs @@ -59,8 +59,7 @@ impl, B: TryFrom> MatchesFungible for IsConcrete< impl, I: TryFrom> MatchesNonFungible for IsConcrete { fn matches_nonfungible(a: &MultiAsset) -> Option { match (&a.id, &a.fun) { - (Concrete(ref id), NonFungible(ref instance)) if id == &T::get() => - instance.clone().try_into().ok(), + (Concrete(id), NonFungible(instance)) if id == &T::get() => (*instance).try_into().ok(), _ => None, } } @@ -103,8 +102,7 @@ impl, B: TryFrom> MatchesFungible for IsAbstract { impl, B: TryFrom> MatchesNonFungible for IsAbstract { fn matches_nonfungible(a: &MultiAsset) -> Option { match (&a.id, &a.fun) { - (Abstract(ref id), NonFungible(ref instance)) if id == &T::get() => - instance.clone().try_into().ok(), + (Abstract(id), NonFungible(instance)) if id == &T::get() => (*instance).try_into().ok(), _ => None, } } diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index 97b76a2eda06..958d6a8a4a3a 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -45,14 +45,14 @@ impl VersionChangeNotifier for TestSubscriptionService { _context: &XcmContext, ) -> XcmResult { let mut r = SubscriptionRequests::get(); - r.push((location.clone(), Some((query_id, max_weight)))); + r.push((*location, Some((query_id, max_weight)))); SubscriptionRequests::set(r); Ok(()) } fn stop(location: &MultiLocation, _context: &XcmContext) -> XcmResult { let mut r = SubscriptionRequests::get(); r.retain(|(l, _q)| l != location); - r.push((location.clone(), None)); + r.push((*location, None)); SubscriptionRequests::set(r); Ok(()) } @@ -71,7 +71,7 @@ pub struct TestAssetTrap; impl DropAssets for TestAssetTrap { fn drop_assets(origin: &MultiLocation, assets: Assets, _context: &XcmContext) -> Weight { let mut t: Vec<(MultiLocation, MultiAssets)> = TrappedAssets::get(); - t.push((origin.clone(), assets.into())); + t.push((*origin, assets.into())); TrappedAssets::set(t); Weight::from_parts(5, 5) } diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index 4ff7668a8622..51372b7e1cc3 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -35,7 +35,7 @@ fn ensure_is_remote( }; let universal_destination: InteriorMultiLocation = universal_local .into_location() - .appended_with(dest.clone()) + .appended_with(dest) .map_err(|x| x.1)? .try_into()?; let (remote_dest, remote_net) = match universal_destination.split_first() { @@ -147,7 +147,7 @@ impl, xcm: &mut Option>, ) -> SendResult { - let d = dest.as_ref().ok_or(MissingArgument)?.clone(); + let d = dest.ok_or(MissingArgument)?; let devolved = ensure_is_remote(UniversalLocation::get(), d).map_err(|_| NotApplicable)?; let (remote_network, remote_location) = devolved; let xcm = xcm.take().ok_or(MissingArgument)?; @@ -189,7 +189,7 @@ impl, xcm: &mut Option>, ) -> SendResult { - let d = dest.as_ref().ok_or(MissingArgument)?.clone(); + let d = *dest.as_ref().ok_or(MissingArgument)?; let devolved = ensure_is_remote(UniversalLocation::get(), d).map_err(|_| NotApplicable)?; let (remote_network, remote_location) = devolved; diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index bc8ec4e16027..e4692058fda9 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -817,7 +817,7 @@ impl XcmExecutor { // // This only works because the remote chain empowers the bridge // to speak for the local network. - let origin = *self.context.origin.as_ref().ok_or(XcmError::BadOrigin)?; + let origin = self.context.origin.ok_or(XcmError::BadOrigin)?; let universal_source = Config::UniversalLocation::get() .within_global(origin) .map_err(|()| XcmError::Unanchored)?; From 456ad93e16e38ded79033a82f103012cc1d54c5c Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 7 Dec 2022 03:22:40 +0900 Subject: [PATCH 154/231] Fixes --- runtime/kusama/src/lib.rs | 6 ++++-- runtime/rococo/src/lib.rs | 6 ++++-- runtime/westend/src/lib.rs | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 98dfd88502b1..0af5a15e8427 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1969,7 +1969,9 @@ sp_api::impl_runtime_apis! { use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench; use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; - use xcm_config::{CheckAccount, SovereignAccountOf, Statemine, TokenLocation, XcmConfig}; + use xcm_config::{ + LocalCheckAccount, SovereignAccountOf, Statemine, TokenLocation, XcmConfig, + }; impl pallet_session_benchmarking::Config for Runtime {} impl pallet_offences_benchmarking::Config for Runtime {} @@ -2003,7 +2005,7 @@ sp_api::impl_runtime_apis! { impl pallet_xcm_benchmarks::fungible::Config for Runtime { type TransactAsset = Balances; - type CheckedAccount = CheckAccount; + type CheckedAccount = LocalCheckAccount; type TrustedTeleporter = TrustedTeleporter; fn get_multi_asset() -> MultiAsset { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index f117daec3e3e..339296e007f9 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1955,7 +1955,9 @@ sp_api::impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; - use xcm_config::{CheckAccount, LocationConverter, Statemine, TokenLocation, XcmConfig}; + use xcm_config::{ + LocalCheckAccount, LocationConverter, Statemine, TokenLocation, XcmConfig, + }; impl frame_system_benchmarking::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {} @@ -1988,7 +1990,7 @@ sp_api::impl_runtime_apis! { impl pallet_xcm_benchmarks::fungible::Config for Runtime { type TransactAsset = Balances; - type CheckedAccount = CheckAccount; + type CheckedAccount = LocalCheckAccount; type TrustedTeleporter = TrustedTeleporter; fn get_multi_asset() -> MultiAsset { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index b5cdda54763d..34454dfeb621 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1730,7 +1730,7 @@ sp_api::impl_runtime_apis! { impl pallet_xcm_benchmarks::fungible::Config for Runtime { type TransactAsset = Balances; - type CheckedAccount = xcm_config::CheckAccount; + type CheckedAccount = xcm_config::LocalCheckAccount; type TrustedTeleporter = TrustedTeleporter; fn get_multi_asset() -> MultiAsset { From d9ee95b41e797542c0aca19ba2d6d6c66932b0e9 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 6 Dec 2022 19:41:03 +0000 Subject: [PATCH 155/231] ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm --- runtime/polkadot/src/weights/pallet_xcm.rs | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/runtime/polkadot/src/weights/pallet_xcm.rs b/runtime/polkadot/src/weights/pallet_xcm.rs index b96f19029f04..5f47a21a67f5 100644 --- a/runtime/polkadot/src/weights/pallet_xcm.rs +++ b/runtime/polkadot/src/weights/pallet_xcm.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-12-06, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 @@ -53,35 +53,35 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn send() -> Weight { - // Minimum execution time: 32_774 nanoseconds. - Weight::from_ref_time(33_997_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Minimum execution time: 33_342 nanoseconds. + Weight::from_ref_time(34_378_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) } fn teleport_assets() -> Weight { - // Minimum execution time: 28_642 nanoseconds. - Weight::from_ref_time(28_983_000 as u64) + // Minimum execution time: 29_082 nanoseconds. + Weight::from_ref_time(29_445_000) } fn reserve_transfer_assets() -> Weight { - // Minimum execution time: 27_163 nanoseconds. - Weight::from_ref_time(28_021_000 as u64) + // Minimum execution time: 27_698 nanoseconds. + Weight::from_ref_time(28_811_000) } // Storage: Benchmark Override (r:0 w:0) fn execute() -> Weight { // Minimum execution time: 18_446_744_073_709_551 nanoseconds. - Weight::from_ref_time(18_446_744_073_709_551_000 as u64) + Weight::from_ref_time(18_446_744_073_709_551_000) } // Storage: XcmPallet SupportedVersion (r:0 w:1) fn force_xcm_version() -> Weight { - // Minimum execution time: 13_985 nanoseconds. - Weight::from_ref_time(14_726_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 14_670 nanoseconds. + Weight::from_ref_time(15_073_000) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet SafeXcmVersion (r:0 w:1) fn force_default_xcm_version() -> Weight { - // Minimum execution time: 3_783 nanoseconds. - Weight::from_ref_time(3_948_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 4_072 nanoseconds. + Weight::from_ref_time(4_258_000) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) // Storage: XcmPallet QueryCounter (r:1 w:1) @@ -93,10 +93,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueues (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_subscribe_version_notify() -> Weight { - // Minimum execution time: 37_360 nanoseconds. - Weight::from_ref_time(37_845_000 as u64) - .saturating_add(T::DbWeight::get().reads(8 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + // Minimum execution time: 38_016 nanoseconds. + Weight::from_ref_time(39_062_000) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) @@ -107,9 +107,9 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueues (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_unsubscribe_version_notify() -> Weight { - // Minimum execution time: 40_002 nanoseconds. - Weight::from_ref_time(40_985_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Minimum execution time: 44_887 nanoseconds. + Weight::from_ref_time(45_471_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } } From 59dea69fc39c2a9a4691e3449ea7ead2010534c1 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 6 Dec 2022 20:05:38 +0000 Subject: [PATCH 156/231] ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_xcm --- runtime/westend/src/weights/pallet_xcm.rs | 48 +++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/runtime/westend/src/weights/pallet_xcm.rs b/runtime/westend/src/weights/pallet_xcm.rs index 5ff074c99432..36d3e00b9778 100644 --- a/runtime/westend/src/weights/pallet_xcm.rs +++ b/runtime/westend/src/weights/pallet_xcm.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-12-06, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 @@ -52,35 +52,35 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn send() -> Weight { - // Minimum execution time: 33_543 nanoseconds. - Weight::from_ref_time(33_958_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Minimum execution time: 35_676 nanoseconds. + Weight::from_ref_time(36_193_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } fn teleport_assets() -> Weight { - // Minimum execution time: 27_780 nanoseconds. - Weight::from_ref_time(28_311_000 as u64) + // Minimum execution time: 28_636 nanoseconds. + Weight::from_ref_time(29_065_000) } fn reserve_transfer_assets() -> Weight { - // Minimum execution time: 26_135 nanoseconds. - Weight::from_ref_time(26_932_000 as u64) + // Minimum execution time: 28_232 nanoseconds. + Weight::from_ref_time(28_938_000) } // Storage: Benchmark Override (r:0 w:0) fn execute() -> Weight { // Minimum execution time: 18_446_744_073_709_551 nanoseconds. - Weight::from_ref_time(18_446_744_073_709_551_000 as u64) + Weight::from_ref_time(18_446_744_073_709_551_000) } // Storage: XcmPallet SupportedVersion (r:0 w:1) fn force_xcm_version() -> Weight { - // Minimum execution time: 14_738 nanoseconds. - Weight::from_ref_time(15_217_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 15_233 nanoseconds. + Weight::from_ref_time(15_623_000) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet SafeXcmVersion (r:0 w:1) fn force_default_xcm_version() -> Weight { - // Minimum execution time: 4_327 nanoseconds. - Weight::from_ref_time(4_527_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 4_570 nanoseconds. + Weight::from_ref_time(4_816_000) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) // Storage: XcmPallet QueryCounter (r:1 w:1) @@ -91,10 +91,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueues (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_subscribe_version_notify() -> Weight { - // Minimum execution time: 38_724 nanoseconds. - Weight::from_ref_time(39_594_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + // Minimum execution time: 40_319 nanoseconds. + Weight::from_ref_time(40_778_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -104,9 +104,9 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueues (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_unsubscribe_version_notify() -> Weight { - // Minimum execution time: 40_663 nanoseconds. - Weight::from_ref_time(42_347_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Minimum execution time: 43_293 nanoseconds. + Weight::from_ref_time(43_713_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } } From 67104c425e8f12241c431d88ba58944f6cda5cf3 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 6 Dec 2022 20:34:09 +0000 Subject: [PATCH 157/231] ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_xcm --- runtime/westend/src/weights/pallet_xcm.rs | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/runtime/westend/src/weights/pallet_xcm.rs b/runtime/westend/src/weights/pallet_xcm.rs index 36d3e00b9778..92e5302a8dba 100644 --- a/runtime/westend/src/weights/pallet_xcm.rs +++ b/runtime/westend/src/weights/pallet_xcm.rs @@ -52,18 +52,18 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn send() -> Weight { - // Minimum execution time: 35_676 nanoseconds. - Weight::from_ref_time(36_193_000) + // Minimum execution time: 34_038 nanoseconds. + Weight::from_ref_time(34_919_000) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } fn teleport_assets() -> Weight { - // Minimum execution time: 28_636 nanoseconds. - Weight::from_ref_time(29_065_000) + // Minimum execution time: 27_962 nanoseconds. + Weight::from_ref_time(28_514_000) } fn reserve_transfer_assets() -> Weight { - // Minimum execution time: 28_232 nanoseconds. - Weight::from_ref_time(28_938_000) + // Minimum execution time: 27_771 nanoseconds. + Weight::from_ref_time(28_642_000) } // Storage: Benchmark Override (r:0 w:0) fn execute() -> Weight { @@ -72,14 +72,14 @@ impl pallet_xcm::WeightInfo for WeightInfo { } // Storage: XcmPallet SupportedVersion (r:0 w:1) fn force_xcm_version() -> Weight { - // Minimum execution time: 15_233 nanoseconds. - Weight::from_ref_time(15_623_000) + // Minimum execution time: 14_821 nanoseconds. + Weight::from_ref_time(15_342_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet SafeXcmVersion (r:0 w:1) fn force_default_xcm_version() -> Weight { - // Minimum execution time: 4_570 nanoseconds. - Weight::from_ref_time(4_816_000) + // Minimum execution time: 4_501 nanoseconds. + Weight::from_ref_time(4_628_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) @@ -91,8 +91,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueues (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_subscribe_version_notify() -> Weight { - // Minimum execution time: 40_319 nanoseconds. - Weight::from_ref_time(40_778_000) + // Minimum execution time: 39_480 nanoseconds. + Weight::from_ref_time(40_278_000) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -104,8 +104,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: Dmp DownwardMessageQueues (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_unsubscribe_version_notify() -> Weight { - // Minimum execution time: 43_293 nanoseconds. - Weight::from_ref_time(43_713_000) + // Minimum execution time: 42_607 nanoseconds. + Weight::from_ref_time(43_430_000) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(5)) } From f24731373bdd0f3068d7c9b99f416d4c1be1752c Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 7 Dec 2022 23:52:15 +0900 Subject: [PATCH 158/231] Add benchmark function for ExportMessage --- .../src/generic/benchmarking.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index e9914f2e7c0d..636f69628efb 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -499,6 +499,21 @@ benchmarks! { assert_eq!(executor.fees_mode(), &FeesMode { jit_withdraw: true }); } + export_message { + let mut executor = new_executor::(Default::default()); + + let instruction = Instruction::ExportMessage { + network: Polkadot, + destination: Here, + xcm: Xcm(vec![Instruction::Trap(10)]), + }; + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } verify { + // TODO: Figure out a way to verify that the XCM has been exported + } + lock_asset { let (unlocker, owner, asset) = T::unlockable_asset()?; From 4b26181909fcf7002dca85c7be2b30eef2d59318 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 7 Dec 2022 23:53:56 +0900 Subject: [PATCH 159/231] Fix comment --- xcm/xcm-builder/src/universal_exports.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index 51372b7e1cc3..41c65ad1de64 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -219,8 +219,7 @@ impl(bridge, message)?; if let Some(bridge_payment) = maybe_payment { cost.push(bridge_payment); From 947c4a9752a200c43d20bf08f704066c45f38758 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 01:42:49 +0900 Subject: [PATCH 160/231] Add upper limit to DownwardMessageQueues size --- runtime/parachains/src/dmp.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime/parachains/src/dmp.rs b/runtime/parachains/src/dmp.rs index 206c82f190c4..ef9c947a30fb 100644 --- a/runtime/parachains/src/dmp.rs +++ b/runtime/parachains/src/dmp.rs @@ -29,6 +29,8 @@ pub use pallet::*; #[cfg(test)] mod tests; +pub const MAX_MESSAGE_QUEUE_SIZE: usize = 1024; + /// An error sending a downward message. #[cfg_attr(test, derive(Debug))] pub enum QueueDownwardMessageError { @@ -170,6 +172,12 @@ impl Pallet { return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) } + if ::DownwardMessageQueues::decode_len(para).unwrap_or(0) > + MAX_MESSAGE_QUEUE_SIZE + { + return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) + } + let inbound = InboundDownwardMessage { msg, sent_at: >::block_number() }; From e6f8cd71531b2921910de729e7ddf7bbff7d13fb Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 01:47:35 +0900 Subject: [PATCH 161/231] Add max size check for queue in can_queue_downward_message --- runtime/parachains/src/dmp.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runtime/parachains/src/dmp.rs b/runtime/parachains/src/dmp.rs index ef9c947a30fb..142c1a65951e 100644 --- a/runtime/parachains/src/dmp.rs +++ b/runtime/parachains/src/dmp.rs @@ -151,6 +151,13 @@ impl Pallet { if serialized_len > config.max_downward_message_size { return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) } + + if ::DownwardMessageQueues::decode_len(para).unwrap_or(0) > + MAX_MESSAGE_QUEUE_SIZE + { + return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) + } + Ok(()) } From 233d95aded427a76e18ade6b77a68ddff5212678 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 01:47:54 +0900 Subject: [PATCH 162/231] Fixes --- runtime/parachains/src/dmp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/parachains/src/dmp.rs b/runtime/parachains/src/dmp.rs index 142c1a65951e..e481f1c1dba5 100644 --- a/runtime/parachains/src/dmp.rs +++ b/runtime/parachains/src/dmp.rs @@ -144,7 +144,7 @@ impl Pallet { /// `queue_downward_message` with the same parameters will be successful. pub fn can_queue_downward_message( config: &HostConfiguration, - _para: &ParaId, + para: &ParaId, msg: &DownwardMessage, ) -> Result<(), QueueDownwardMessageError> { let serialized_len = msg.len() as u32; From 3b402dc5b49ec6cb83132b8e5e942566349160c4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 15:47:10 +0900 Subject: [PATCH 163/231] Make Transact runtime call configurable --- runtime/kusama/src/lib.rs | 4 ++-- runtime/rococo/src/lib.rs | 4 ++-- runtime/westend/src/lib.rs | 4 ++-- xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 5 +---- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 5 +++-- xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 8 +++++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 3bdb8f3e0130..00511bdb90d1 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2038,8 +2038,8 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn transact_origin() -> Result { - Ok(Statemine::get()) + fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { + Ok((Statemine::get(), pallet_session::Call::purge_keys {}.into())) } fn subscribe_origin() -> Result { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 339296e007f9..c1ad0733d9b1 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -2018,8 +2018,8 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn transact_origin() -> Result { - Ok(Statemine::get()) + fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { + Ok((Statemine::get(), pallet_session::Call::purge_keys {}.into())) } fn subscribe_origin() -> Result { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 34454dfeb621..6cc984db5cfe 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1758,8 +1758,8 @@ sp_api::impl_runtime_apis! { Err(BenchmarkError::Skip) } - fn transact_origin() -> Result { - Ok(Westmint::get()) + fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { + Ok((Westmint::get(), pallet_session::Call::purge_keys {}.into())) } fn subscribe_origin() -> Result { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 636f69628efb..998b21d4545e 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -90,11 +90,8 @@ benchmarks! { // and included in the final weight calculation. So this is just the overhead of submitting // a noop call. transact { - let origin = T::transact_origin()?; + let (origin, noop_call) = T::transact_origin_and_runtime_call()?; let mut executor = new_executor::(origin); - let noop_call: ::RuntimeCall = frame_system::Call::remark_with_event { - remark: Default::default() - }.into(); let double_encoded_noop_call: DoubleEncoded<_> = noop_call.encode().into(); let instruction = Instruction::Transact { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index d7f3e5b8bd5a..79f9f28e32f5 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -167,8 +167,9 @@ impl generic::Config for Test { Ok(GlobalConsensus(ByGenesis([0; 32]))) } - fn transact_origin() -> Result { - Ok(Default::default()) + fn transact_origin_and_runtime_call( + ) -> Result<(MultiLocation, ::RuntimeCall), BenchmarkError> { + Ok((Default::default(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index cff8d626a347..1f1dbf51a92f 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -38,10 +38,12 @@ pub mod pallet { /// If set to `None`, benchmarks which rely on a universal alias will be skipped. fn universal_alias() -> Result; - /// The `MultiLocation` used for successful transaction XCMs. + /// The `MultiLocation` and `RuntimeCall` used for successful transaction XCMs. /// - /// If set to `None`, benchmarks which rely on a `transact_origin` will be skipped. - fn transact_origin() -> Result; + /// If set to `None`, benchmarks which rely on a `transact_origin_and_runtime_call` will be + /// skipped. + fn transact_origin_and_runtime_call( + ) -> Result<(MultiLocation, >::RuntimeCall), BenchmarkError>; /// A valid `MultiLocation` we can successfully subscribe to. /// From b1e6b47b8031f6ea752ceb83a4cdf634e0059cf4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 15:50:57 +0900 Subject: [PATCH 164/231] Return Weight::MAX when there is no successful send XCM origin --- xcm/pallet-xcm/src/benchmarking.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs index 6c5ddabca40a..e38080c0cda2 100644 --- a/xcm/pallet-xcm/src/benchmarking.rs +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -26,6 +26,9 @@ type RuntimeOrigin = ::RuntimeOrigin; benchmarks! { send { let send_origin = T::SendXcmOrigin::successful_origin(); + if T::SendXcmOrigin::try_origin(send_origin.clone()).is_err() { + return BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)) + } let msg = Xcm(vec![ClearOrigin]); let versioned_dest: VersionedMultiLocation = Parachain(2000).into(); let versioned_msg = VersionedXcm::from(msg); From a6b089662aef5bc7562933b023aa6a04020339d4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 16:14:06 +0900 Subject: [PATCH 165/231] Update substrate --- Cargo.lock | 389 +++++++++++++++++++++++++---------------------------- 1 file changed, 184 insertions(+), 205 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2742b7fe7445..f7a2f27db4d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,7 +412,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "async-trait", @@ -449,7 +449,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "beefy-gadget", "futures", @@ -469,7 +469,7 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "sp-api", "sp-beefy", @@ -1997,7 +1997,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", ] @@ -2020,7 +2020,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -2043,7 +2043,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "Inflector", "array-bytes", @@ -2095,7 +2095,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2122,7 +2122,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -2151,7 +2151,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "env_logger", "log", @@ -2168,7 +2168,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "bitflags", "frame-metadata", @@ -2200,7 +2200,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "Inflector", "cfg-expr", @@ -2214,7 +2214,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2226,7 +2226,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "proc-macro2", "quote", @@ -2236,7 +2236,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2259,7 +2259,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -2270,7 +2270,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "log", @@ -2288,7 +2288,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "sp-api", @@ -2312,7 +2312,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "parity-scale-codec", @@ -2483,7 +2483,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "chrono", "frame-election-provider-support", @@ -4111,7 +4111,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "log", @@ -4131,7 +4131,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "anyhow", "jsonrpsee", @@ -4654,7 +4654,7 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -4668,7 +4668,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -4684,7 +4684,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -4699,7 +4699,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -4723,7 +4723,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4743,7 +4743,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-election-provider-support", "frame-remote-externalities", @@ -4762,7 +4762,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -4777,7 +4777,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -4793,7 +4793,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "beefy-merkle-tree", @@ -4816,7 +4816,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -4834,7 +4834,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -4853,7 +4853,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -4870,7 +4870,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "assert_matches", "frame-benchmarking", @@ -4887,7 +4887,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -4905,7 +4905,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4929,7 +4929,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4942,7 +4942,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -4960,13 +4960,14 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", + "pallet-staking", "parity-scale-codec", "scale-info", "sp-io", @@ -4978,7 +4979,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5001,7 +5002,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5017,7 +5018,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5037,7 +5038,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5054,7 +5055,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5071,7 +5072,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5088,7 +5089,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5104,7 +5105,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5120,7 +5121,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -5137,7 +5138,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5157,7 +5158,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "sp-api", @@ -5167,7 +5168,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -5184,7 +5185,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5207,7 +5208,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5224,7 +5225,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5239,7 +5240,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5257,7 +5258,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5272,12 +5273,13 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "assert_matches", "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "serde", @@ -5290,7 +5292,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5306,7 +5308,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -5327,7 +5329,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5343,7 +5345,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -5357,7 +5359,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5365,6 +5367,7 @@ dependencies = [ "frame-system", "log", "pallet-authorship", + "pallet-bags-list", "pallet-session", "parity-scale-codec", "rand_chacha 0.2.2", @@ -5380,7 +5383,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5391,7 +5394,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "log", "sp-arithmetic", @@ -5400,7 +5403,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5417,7 +5420,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -5431,7 +5434,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5449,7 +5452,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5468,7 +5471,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-support", "frame-system", @@ -5484,7 +5487,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -5500,7 +5503,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5512,7 +5515,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5529,7 +5532,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5544,7 +5547,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5560,7 +5563,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -5575,7 +5578,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-benchmarking", "frame-support", @@ -8353,7 +8356,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "log", "sp-core", @@ -8364,7 +8367,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "futures", @@ -8391,7 +8394,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "futures-timer", @@ -8414,7 +8417,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8430,7 +8433,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "impl-trait-for-tuples", "memmap2", @@ -8447,7 +8450,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8458,7 +8461,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "chrono", @@ -8498,7 +8501,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "fnv", "futures", @@ -8526,7 +8529,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "hash-db", "kvdb", @@ -8551,7 +8554,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "futures", @@ -8575,7 +8578,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "fork-tree", @@ -8616,7 +8619,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "jsonrpsee", @@ -8638,7 +8641,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8651,7 +8654,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "futures", @@ -8675,9 +8678,8 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ - "lazy_static", "lru", "parity-scale-codec", "parking_lot 0.12.1", @@ -8686,7 +8688,6 @@ dependencies = [ "sc-executor-wasmtime", "sp-api", "sp-core", - "sp-core-hashing-proc-macro", "sp-externalities", "sp-io", "sp-panic-handler", @@ -8701,13 +8702,10 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ - "environmental", - "parity-scale-codec", "sc-allocator", "sp-maybe-compressed-blob", - "sp-sandbox", "sp-wasm-interface", "thiserror", "wasm-instrument", @@ -8717,14 +8715,12 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "log", - "parity-scale-codec", "sc-allocator", "sc-executor-common", "sp-runtime-interface", - "sp-sandbox", "sp-wasm-interface", "wasmi", ] @@ -8732,19 +8728,16 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "cfg-if", "libc", "log", "once_cell", - "parity-scale-codec", - "parity-wasm", "rustix", "sc-allocator", "sc-executor-common", "sp-runtime-interface", - "sp-sandbox", "sp-wasm-interface", "wasmtime", ] @@ -8752,7 +8745,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "ahash", "array-bytes", @@ -8793,7 +8786,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "finality-grandpa", "futures", @@ -8814,7 +8807,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "ansi_term", "futures", @@ -8830,7 +8823,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "async-trait", @@ -8845,7 +8838,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "async-trait", @@ -8892,7 +8885,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "cid", "futures", @@ -8912,7 +8905,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "bitflags", @@ -8938,7 +8931,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "ahash", "futures", @@ -8956,7 +8949,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "futures", @@ -8977,7 +8970,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "async-trait", @@ -9008,7 +9001,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "futures", @@ -9027,7 +9020,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "bytes", @@ -9057,7 +9050,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "libp2p", @@ -9070,7 +9063,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9079,7 +9072,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "hash-db", @@ -9109,7 +9102,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "jsonrpsee", @@ -9132,7 +9125,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "jsonrpsee", @@ -9145,7 +9138,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "hex", @@ -9164,7 +9157,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "directories", @@ -9234,7 +9227,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "log", "parity-scale-codec", @@ -9246,7 +9239,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9265,7 +9258,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "libc", @@ -9284,7 +9277,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "chrono", "futures", @@ -9302,7 +9295,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "ansi_term", "atty", @@ -9333,7 +9326,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9344,7 +9337,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "futures", @@ -9370,7 +9363,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "futures", @@ -9384,7 +9377,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "futures-timer", @@ -9867,7 +9860,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "hash-db", "log", @@ -9885,7 +9878,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "blake2", "proc-macro-crate", @@ -9897,7 +9890,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "scale-info", @@ -9910,7 +9903,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "integer-sqrt", "num-traits", @@ -9925,7 +9918,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "scale-info", @@ -9938,7 +9931,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "parity-scale-codec", @@ -9950,7 +9943,7 @@ dependencies = [ [[package]] name = "sp-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "scale-info", @@ -9967,7 +9960,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "sp-api", @@ -9979,7 +9972,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "log", @@ -9997,7 +9990,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "futures", @@ -10016,7 +10009,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "merlin", @@ -10039,7 +10032,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "scale-info", @@ -10053,7 +10046,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "scale-info", @@ -10066,7 +10059,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "base58", @@ -10111,7 +10104,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "blake2", "byteorder", @@ -10125,7 +10118,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "proc-macro2", "quote", @@ -10136,7 +10129,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10145,7 +10138,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "proc-macro2", "quote", @@ -10155,7 +10148,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "environmental", "parity-scale-codec", @@ -10166,7 +10159,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "finality-grandpa", "log", @@ -10184,7 +10177,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10198,7 +10191,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "bytes", "ed25519-dalek", @@ -10225,7 +10218,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "lazy_static", "sp-core", @@ -10236,7 +10229,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "futures", @@ -10253,7 +10246,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "thiserror", "zstd", @@ -10262,7 +10255,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -10280,7 +10273,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "scale-info", @@ -10294,7 +10287,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "sp-api", "sp-core", @@ -10304,7 +10297,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "backtrace", "lazy_static", @@ -10314,7 +10307,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "rustc-hash", "serde", @@ -10324,7 +10317,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "either", "hash256-std-hasher", @@ -10346,7 +10339,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10364,7 +10357,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "Inflector", "proc-macro-crate", @@ -10373,24 +10366,10 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-sandbox" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" -dependencies = [ - "log", - "parity-scale-codec", - "sp-core", - "sp-io", - "sp-std", - "sp-wasm-interface", - "wasmi", -] - [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "scale-info", @@ -10404,7 +10383,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "scale-info", @@ -10415,7 +10394,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "hash-db", "log", @@ -10437,12 +10416,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10455,7 +10434,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "futures-timer", @@ -10471,7 +10450,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "sp-std", @@ -10483,7 +10462,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "sp-api", "sp-runtime", @@ -10492,7 +10471,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "log", @@ -10508,7 +10487,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "ahash", "hash-db", @@ -10531,7 +10510,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10548,7 +10527,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10559,7 +10538,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "impl-trait-for-tuples", "log", @@ -10572,7 +10551,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10787,7 +10766,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "platforms", ] @@ -10795,7 +10774,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -10816,7 +10795,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures-util", "hyper", @@ -10829,7 +10808,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "async-trait", "jsonrpsee", @@ -10842,7 +10821,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "jsonrpsee", "log", @@ -10863,7 +10842,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "array-bytes", "async-trait", @@ -10889,7 +10868,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "futures", "substrate-test-utils-derive", @@ -10899,7 +10878,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10910,7 +10889,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "ansi_term", "build-helper", @@ -11606,7 +11585,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#11c50578549969979121577cde987ad3f9d95bd8" +source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" dependencies = [ "clap", "frame-remote-externalities", From 6128e3f22a571efe48b1a99b451f61bb7eda10b6 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 16:23:38 +0900 Subject: [PATCH 166/231] Fixes --- xcm/pallet-xcm/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs index e38080c0cda2..576c85c7cfac 100644 --- a/xcm/pallet-xcm/src/benchmarking.rs +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -27,7 +27,7 @@ benchmarks! { send { let send_origin = T::SendXcmOrigin::successful_origin(); if T::SendXcmOrigin::try_origin(send_origin.clone()).is_err() { - return BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)) + return Err(BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX))) } let msg = Xcm(vec![ClearOrigin]); let versioned_dest: VersionedMultiLocation = Parachain(2000).into(); From 07de17c6f32a7cb7b4fee8efed4651cbdcbfeb06 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 17:56:40 +0900 Subject: [PATCH 167/231] Fixes --- xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 998b21d4545e..b135521294b6 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -261,7 +261,7 @@ benchmarks! { unsubscribe_version { use xcm_executor::traits::VersionChangeNotifier; // First we need to subscribe to notifications. - let origin = T::transact_origin()?; + let (origin, _) = T::transact_origin_and_runtime_call()?; let query_id = Default::default(); let max_response_weight = Default::default(); ::SubscriptionService::start( From 65bffb847191ae2facdeef6b8f26ea44d4544240 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 22:05:45 +0900 Subject: [PATCH 168/231] Remove ExportMessage benchmark --- .../src/generic/benchmarking.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index b135521294b6..9dae79e71d44 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -496,21 +496,6 @@ benchmarks! { assert_eq!(executor.fees_mode(), &FeesMode { jit_withdraw: true }); } - export_message { - let mut executor = new_executor::(Default::default()); - - let instruction = Instruction::ExportMessage { - network: Polkadot, - destination: Here, - xcm: Xcm(vec![Instruction::Trap(10)]), - }; - let xcm = Xcm(vec![instruction]); - }: { - executor.bench_process(xcm)?; - } verify { - // TODO: Figure out a way to verify that the XCM has been exported - } - lock_asset { let (unlocker, owner, asset) = T::unlockable_asset()?; From 843c8b0ef8dcd15841f1a5a07b30722dbac1db63 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 23:07:17 +0900 Subject: [PATCH 169/231] Remove assertion on Transact instruction benchmark --- xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 9dae79e71d44..3c1e6ad4b8cf 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -105,9 +105,7 @@ benchmarks! { }: { executor.bench_process(xcm)?; } verify { - // TODO make better assertion? #4426 - let num_events2 = frame_system::Pallet::::events().len(); - assert_eq!(num_events + 1, num_events2); + // TODO Make the assertion configurable? } refund_surplus { From 8923c9f2e7f73df2741933e2ac2cc780511e34b7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 23:26:38 +0900 Subject: [PATCH 170/231] Make reachable destination configurable in XCM pallet benchmarks --- runtime/kusama/src/xcm_config.rs | 2 ++ runtime/polkadot/src/xcm_config.rs | 2 ++ runtime/rococo/src/xcm_config.rs | 2 ++ runtime/test-runtime/src/xcm_config.rs | 2 ++ runtime/westend/src/xcm_config.rs | 2 ++ xcm/pallet-xcm/src/benchmarking.rs | 15 ++++++++++++--- xcm/pallet-xcm/src/lib.rs | 6 ++++++ 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 3e191c198492..dc324175c0d8 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -396,4 +396,6 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = Parachain(1000).into(); } diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index fe0e5d6b94fb..414be9c2cf68 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -354,4 +354,6 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = Parachain(1000).into(); } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 1b059fb54abb..99380a791624 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -329,4 +329,6 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationConverter; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = Parachain(1000).into(); } diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 594a91fdb139..0f575cff6ef5 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -139,4 +139,6 @@ impl pallet_xcm::Config for crate::Runtime { type SovereignAccountOf = (); type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = xcm::latest::Junctions::Here.into(); } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index a43bc16155f5..d6a376d845ef 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -243,4 +243,6 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationConverter; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = Parachain(1000).into(); } diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs index 576c85c7cfac..670c635346a1 100644 --- a/xcm/pallet-xcm/src/benchmarking.rs +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -30,13 +30,19 @@ benchmarks! { return Err(BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX))) } let msg = Xcm(vec![ClearOrigin]); - let versioned_dest: VersionedMultiLocation = Parachain(2000).into(); + let versioned_dest: VersionedMultiLocation = T::ReachableDest.ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), + ) + .into(); let versioned_msg = VersionedXcm::from(msg); }: _>(send_origin, Box::new(versioned_dest), Box::new(versioned_msg)) teleport_assets { let recipient = [0u8; 32]; - let versioned_dest: VersionedMultiLocation = Parachain(2000).into(); + let versioned_dest: VersionedMultiLocation = T::ReachableDest.ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), + ) + .into(); let versioned_beneficiary: VersionedMultiLocation = AccountId32 { network: None, id: recipient.into() }.into(); let versioned_assets: VersionedMultiAssets = (Here, 10).into(); @@ -44,7 +50,10 @@ benchmarks! { reserve_transfer_assets { let recipient = [0u8; 32]; - let versioned_dest: VersionedMultiLocation = Parachain(2000).into(); + let versioned_dest: VersionedMultiLocation = T::ReachableDest.ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), + ) + .into(); let versioned_beneficiary: VersionedMultiLocation = AccountId32 { network: None, id: recipient.into() }.into(); let versioned_assets: VersionedMultiAssets = (Here, 10).into(); diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index e355eb19c3ea..5ef078f8f71a 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -209,6 +209,12 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; + + /// A `MultiLocation` that can be reached via `XcmRouter`. Used only in benchmarks. + /// + /// If `None`, the benchmarks that depend on a reachable destination will be skipped. + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest: Option; } #[pallet::event] From c533401fa3eb448a4379af68723a1f99f2c88909 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 23:44:03 +0900 Subject: [PATCH 171/231] Fixes --- runtime/kusama/src/xcm_config.rs | 7 ++++++- runtime/polkadot/src/xcm_config.rs | 7 ++++++- runtime/rococo/src/xcm_config.rs | 7 ++++++- runtime/test-runtime/src/xcm_config.rs | 7 ++++++- runtime/westend/src/xcm_config.rs | 8 +++++++- xcm/pallet-xcm/src/benchmarking.rs | 12 ++++++------ xcm/pallet-xcm/src/lib.rs | 2 +- xcm/pallet-xcm/src/mock.rs | 3 +++ 8 files changed, 41 insertions(+), 12 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index dc324175c0d8..17511fd75572 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -350,6 +350,11 @@ parameter_types! { pub const CouncilBodyId: BodyId = BodyId::Executive; } +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parachain(1000).into()); +} + /// Type to convert the council origin to a Plurality `MultiLocation` value. pub type CouncilToPlurality = BackingToPlurality< RuntimeOrigin, @@ -397,5 +402,5 @@ impl pallet_xcm::Config for Runtime { type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = Parachain(1000).into(); + type ReachableDest = ReachableDest; } diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 414be9c2cf68..c4dc9ecb70bd 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -313,6 +313,11 @@ parameter_types! { pub const CouncilBodyId: BodyId = BodyId::Executive; } +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parachain(1000).into()); +} + /// Type to convert a council origin to a Plurality `MultiLocation` value. pub type CouncilToPlurality = BackingToPlurality< RuntimeOrigin, @@ -355,5 +360,5 @@ impl pallet_xcm::Config for Runtime { type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = Parachain(1000).into(); + type ReachableDest = ReachableDest; } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 99380a791624..a57f73c13f76 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -289,6 +289,11 @@ parameter_types! { pub const CouncilBodyId: BodyId = BodyId::Executive; } +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parachain(1000).into()); +} + /// Type to convert the council origin to a Plurality `MultiLocation` value. pub type CouncilToPlurality = BackingToPlurality< RuntimeOrigin, @@ -330,5 +335,5 @@ impl pallet_xcm::Config for Runtime { type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = Parachain(1000).into(); + type ReachableDest = ReachableDest; } diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 0f575cff6ef5..d27d241260db 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -37,6 +37,11 @@ parameter_types! { pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; } +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(xcm::latest::Junctions::Here.into()); +} + /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location /// of this chain. pub type LocalOriginToLocation = ( @@ -140,5 +145,5 @@ impl pallet_xcm::Config for crate::Runtime { type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = xcm::latest::Junctions::Here.into(); + type ReachableDest = ReachableDest; } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index d6a376d845ef..069dfeb5fca1 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -83,6 +83,12 @@ parameter_types! { pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } + +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parachain(1000).into()); +} + pub type TrustedTeleporters = (xcm_builder::Case, xcm_builder::Case); @@ -244,5 +250,5 @@ impl pallet_xcm::Config for Runtime { type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = Parachain(1000).into(); + type ReachableDest = ReachableDest; } diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs index 670c635346a1..dbd477697c7a 100644 --- a/xcm/pallet-xcm/src/benchmarking.rs +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -30,18 +30,18 @@ benchmarks! { return Err(BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX))) } let msg = Xcm(vec![ClearOrigin]); - let versioned_dest: VersionedMultiLocation = T::ReachableDest.ok_or( + let versioned_dest: VersionedMultiLocation = T::ReachableDest::get().ok_or( BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), - ) + )? .into(); let versioned_msg = VersionedXcm::from(msg); }: _>(send_origin, Box::new(versioned_dest), Box::new(versioned_msg)) teleport_assets { let recipient = [0u8; 32]; - let versioned_dest: VersionedMultiLocation = T::ReachableDest.ok_or( + let versioned_dest: VersionedMultiLocation = T::ReachableDest::get().ok_or( BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), - ) + )? .into(); let versioned_beneficiary: VersionedMultiLocation = AccountId32 { network: None, id: recipient.into() }.into(); @@ -50,9 +50,9 @@ benchmarks! { reserve_transfer_assets { let recipient = [0u8; 32]; - let versioned_dest: VersionedMultiLocation = T::ReachableDest.ok_or( + let versioned_dest: VersionedMultiLocation = T::ReachableDest::get().ok_or( BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), - ) + )? .into(); let versioned_beneficiary: VersionedMultiLocation = AccountId32 { network: None, id: recipient.into() }.into(); diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 5ef078f8f71a..63ec311edd20 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -214,7 +214,7 @@ pub mod pallet { /// /// If `None`, the benchmarks that depend on a reachable destination will be skipped. #[cfg(feature = "runtime-benchmarks")] - type ReachableDest: Option; + type ReachableDest: Get>; } #[pallet::event] diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 11f343fd3cb3..e3d518525ba2 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -308,6 +308,7 @@ pub type LocalOriginToLocation = SignedToAccountId32 = Some(Parachain(1000).into()); } impl pallet_xcm::Config for Test { @@ -331,6 +332,8 @@ impl pallet_xcm::Config for Test { type CurrencyMatcher = IsConcrete; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } impl origin::Config for Test {} From 8a0398d4dbd204adaf556746e7ed5a54381e1c13 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 8 Dec 2022 23:57:52 +0900 Subject: [PATCH 172/231] Fixes --- runtime/test-runtime/src/xcm_config.rs | 10 +++++----- xcm/pallet-xcm/src/mock.rs | 4 ++++ xcm/xcm-builder/tests/mock/mod.rs | 8 ++++++++ xcm/xcm-simulator/example/src/parachain.rs | 7 +++++++ xcm/xcm-simulator/example/src/relay_chain.rs | 7 +++++++ xcm/xcm-simulator/fuzzer/src/parachain.rs | 7 +++++++ xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 7 +++++++ 7 files changed, 45 insertions(+), 5 deletions(-) diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index d27d241260db..bfe9c6ad1ad8 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -37,11 +37,6 @@ parameter_types! { pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; } -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = Some(xcm::latest::Junctions::Here.into()); -} - /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location /// of this chain. pub type LocalOriginToLocation = ( @@ -121,6 +116,11 @@ impl xcm_executor::Config for XcmConfig { type SafeCallFilter = Everything; } +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(xcm::latest::Junctions::Here.into()); +} + impl pallet_xcm::Config for crate::Runtime { // The config types here are entirely configurable, since the only one that is sorely needed // is `XcmExecutor`, which will be used in unit tests located in xcm-executor. diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index e3d518525ba2..559bdadaace4 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -308,6 +308,10 @@ pub type LocalOriginToLocation = SignedToAccountId32 = Some(Parachain(1000).into()); } diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index a4b3439b3392..68018808e906 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -170,6 +170,7 @@ parameter_types! { pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 4; } + pub type TrustedTeleporters = (xcm_builder::Case,); pub struct XcmConfig; @@ -201,6 +202,11 @@ impl xcm_executor::Config for XcmConfig { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Here.into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type UniversalLocation = UniversalLocation; @@ -223,6 +229,8 @@ impl pallet_xcm::Config for Runtime { type CurrencyMatcher = IsConcrete; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } impl origin::Config for Runtime {} diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 26dfd12de08c..58a4b93e8527 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -393,6 +393,11 @@ impl mock_msg_queue::Config for Runtime { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -414,6 +419,8 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index c70307cf042f..0b1cd30e11c2 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -187,6 +187,11 @@ impl Config for XcmConfig { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parachain(1).into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; @@ -209,6 +214,8 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } parameter_types! { diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 2b6ab01e20ae..e80f7462adeb 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -308,6 +308,11 @@ impl mock_msg_queue::Config for Runtime { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -329,6 +334,8 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 4fdcf51789ee..f41d202477af 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -123,6 +123,11 @@ parameter_types! { pub type XcmRouter = super::RelayChainXcmRouter; pub type Barrier = AllowUnpaidExecutionFrom; +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parachain(1).into()); +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -174,6 +179,8 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } parameter_types! { From 8e74d79a389e6dc4059da04d37061d94de6ec508 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 00:08:00 +0900 Subject: [PATCH 173/231] Remove cfg attribute in fuzzer --- xcm/xcm-simulator/fuzzer/src/parachain.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index e80f7462adeb..e397c6bc08f8 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -308,7 +308,6 @@ impl mock_msg_queue::Config for Runtime { pub type LocalOriginToLocation = SignedToAccountId32; -#[cfg(feature = "runtime-benchmarks")] parameter_types! { pub ReachableDest: Option = Some(Parent.into()); } @@ -334,7 +333,6 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; } From 536183255612f784fea853e18ae698654ffa3802 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 00:16:35 +0900 Subject: [PATCH 174/231] Fixes --- xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index f41d202477af..b94e1d967f60 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -123,11 +123,6 @@ parameter_types! { pub type XcmRouter = super::RelayChainXcmRouter; pub type Barrier = AllowUnpaidExecutionFrom; -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = Some(Parachain(1).into()); -} - pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -157,6 +152,10 @@ impl Config for XcmConfig { pub type LocalOriginToLocation = SignedToAccountId32; +parameter_types! { + pub ReachableDest: Option = Some(Parachain(1).into()); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; @@ -179,7 +178,6 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; } From a37b93a83da20ff51f99c878604e44f08504c246 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 00:31:26 +0900 Subject: [PATCH 175/231] Remove cfg attribute for XCM pallet in test runtime --- runtime/test-runtime/src/xcm_config.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index bfe9c6ad1ad8..4f1f80b3b7e9 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -116,7 +116,6 @@ impl xcm_executor::Config for XcmConfig { type SafeCallFilter = Everything; } -#[cfg(feature = "runtime-benchmarks")] parameter_types! { pub ReachableDest: Option = Some(xcm::latest::Junctions::Here.into()); } @@ -144,6 +143,5 @@ impl pallet_xcm::Config for crate::Runtime { type SovereignAccountOf = (); type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; } From d9bfc89744bdc6f89fdc7c7c8b914fbcb51de15a Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 00:43:45 +0900 Subject: [PATCH 176/231] Fixes --- runtime/test-runtime/Cargo.toml | 4 ++++ runtime/test-runtime/src/xcm_config.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/runtime/test-runtime/Cargo.toml b/runtime/test-runtime/Cargo.toml index f8695b07c88f..9b35b4988938 100644 --- a/runtime/test-runtime/Cargo.toml +++ b/runtime/test-runtime/Cargo.toml @@ -129,3 +129,7 @@ std = [ "frame-election-provider-support/std", "pallet-sudo/std", ] + +runtime-benchmarks = [ + "pallet-xcm/runtime-benchmarks", +] diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 4f1f80b3b7e9..bfe9c6ad1ad8 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -116,6 +116,7 @@ impl xcm_executor::Config for XcmConfig { type SafeCallFilter = Everything; } +#[cfg(feature = "runtime-benchmarks")] parameter_types! { pub ReachableDest: Option = Some(xcm::latest::Junctions::Here.into()); } @@ -143,5 +144,6 @@ impl pallet_xcm::Config for crate::Runtime { type SovereignAccountOf = (); type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; } From 420be3e5174e7d7ea166a110d4dc05686b570f5b Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 02:05:07 +0900 Subject: [PATCH 177/231] Use ReachableDest where possible --- xcm/pallet-xcm/src/benchmarking.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs index dbd477697c7a..4f604a654976 100644 --- a/xcm/pallet-xcm/src/benchmarking.rs +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -78,12 +78,18 @@ benchmarks! { force_default_xcm_version {}: _(RawOrigin::Root, Some(2)) force_subscribe_version_notify { - let versioned_loc: VersionedMultiLocation = Parachain(2000).into(); + let versioned_loc: VersionedMultiLocation = T::ReachableDest::get().ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), + )? + .into(); }: _(RawOrigin::Root, Box::new(versioned_loc)) force_unsubscribe_version_notify { - let versioned_loc: VersionedMultiLocation = Parachain(2000).into(); - let _ = Pallet::::request_version_notify(Parachain(2000)); + let loc = T::ReachableDest::get().ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), + )?; + let versioned_loc: VersionedMultiLocation = loc.into(); + let _ = Pallet::::request_version_notify(loc); }: _(RawOrigin::Root, Box::new(versioned_loc)) impl_benchmark_test_suite!( From 1e3e9ade49a20cde8fbc472c25a850da51fbc2f1 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 02:05:58 +0900 Subject: [PATCH 178/231] Fixes --- xcm/pallet-xcm/src/benchmarking.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs index 4f604a654976..bdcc5a96d256 100644 --- a/xcm/pallet-xcm/src/benchmarking.rs +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -71,7 +71,9 @@ benchmarks! { }: _>(execute_origin, Box::new(versioned_msg), Weight::zero()) force_xcm_version { - let loc = Parachain(2000).into_location(); + let loc = T::ReachableDest::get().ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), + )?; let xcm_version = 2; }: _(RawOrigin::Root, Box::new(loc), xcm_version) From 937c4b7fd30490cd548bef0d5965eba285272836 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 02:23:02 +0900 Subject: [PATCH 179/231] Add benchmark for UnpaidExecution --- .../src/generic/benchmarking.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 3c1e6ad4b8cf..797238babe20 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -585,6 +585,20 @@ benchmarks! { // TODO: Potentially add new trait to XcmSender to detect a queued outgoing message. #4426 } + unpaid_execution { + let mut executor = new_executor::(Default::default()); + executor.set_origin(Some(Here.into())); + + let instruction = Instruction::>::UnpaidExecution { + weight_limit: WeightLimit::Unlimited, + check_origin: Some(Here.into()), + }; + + let xcm = Xcm(vec![instruction]); + }: { + executor.bench_process(xcm)?; + } + impl_benchmark_test_suite!( Pallet, crate::generic::mock::new_test_ext(), From fd388e05331cf6a1bdf34d20f5de971b9aa7eb3f Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 02:46:32 +0900 Subject: [PATCH 180/231] Update substrate --- Cargo.lock | 362 ++++++++++++++++++++++++++--------------------------- 1 file changed, 181 insertions(+), 181 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9f39a134afa..eed7be477cc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,7 +412,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "async-trait", @@ -449,7 +449,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "beefy-gadget", "futures", @@ -469,7 +469,7 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "sp-api", "sp-beefy", @@ -1997,7 +1997,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", ] @@ -2020,7 +2020,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -2043,7 +2043,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "Inflector", "array-bytes", @@ -2095,7 +2095,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2122,7 +2122,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -2151,7 +2151,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "env_logger", "log", @@ -2168,7 +2168,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "bitflags", "frame-metadata", @@ -2200,7 +2200,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "Inflector", "cfg-expr", @@ -2214,7 +2214,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2226,7 +2226,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "proc-macro2", "quote", @@ -2236,7 +2236,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2259,7 +2259,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -2270,7 +2270,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "log", @@ -2288,7 +2288,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -2303,7 +2303,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "sp-api", @@ -2312,7 +2312,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "parity-scale-codec", @@ -2483,7 +2483,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "chrono", "frame-election-provider-support", @@ -4113,7 +4113,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "log", @@ -4133,7 +4133,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "anyhow", "jsonrpsee", @@ -4656,7 +4656,7 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4670,7 +4670,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -4686,7 +4686,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -4701,7 +4701,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4725,7 +4725,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4745,7 +4745,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-election-provider-support", "frame-remote-externalities", @@ -4764,7 +4764,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4779,7 +4779,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -4795,7 +4795,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "beefy-merkle-tree", @@ -4818,7 +4818,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4836,7 +4836,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4855,7 +4855,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4872,7 +4872,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "assert_matches", "frame-benchmarking", @@ -4889,7 +4889,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4907,7 +4907,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4931,7 +4931,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4944,7 +4944,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4962,7 +4962,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4981,7 +4981,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5004,7 +5004,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5020,7 +5020,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5040,7 +5040,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5057,7 +5057,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5074,7 +5074,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5091,7 +5091,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5107,7 +5107,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5123,7 +5123,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -5140,7 +5140,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5160,7 +5160,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "sp-api", @@ -5170,7 +5170,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -5187,7 +5187,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5210,7 +5210,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5227,7 +5227,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5242,7 +5242,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5260,7 +5260,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5275,7 +5275,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5294,7 +5294,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5310,7 +5310,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -5331,7 +5331,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5347,7 +5347,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -5361,7 +5361,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5385,7 +5385,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5396,7 +5396,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "log", "sp-arithmetic", @@ -5405,7 +5405,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5422,7 +5422,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -5436,7 +5436,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5454,7 +5454,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5473,7 +5473,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-support", "frame-system", @@ -5489,7 +5489,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -5505,7 +5505,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5517,7 +5517,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5534,7 +5534,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5549,7 +5549,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5565,7 +5565,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -5580,7 +5580,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8362,7 +8362,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "log", "sp-core", @@ -8373,7 +8373,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "futures", @@ -8400,7 +8400,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "futures-timer", @@ -8423,7 +8423,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8439,7 +8439,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "impl-trait-for-tuples", "memmap2", @@ -8456,7 +8456,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8467,7 +8467,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "chrono", @@ -8507,7 +8507,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "fnv", "futures", @@ -8535,7 +8535,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "hash-db", "kvdb", @@ -8560,7 +8560,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "futures", @@ -8584,7 +8584,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "fork-tree", @@ -8625,7 +8625,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "jsonrpsee", @@ -8647,7 +8647,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8660,7 +8660,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "futures", @@ -8684,7 +8684,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "lru", "parity-scale-codec", @@ -8708,7 +8708,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -8721,7 +8721,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "log", "sc-allocator", @@ -8734,7 +8734,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "cfg-if", "libc", @@ -8751,7 +8751,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "ahash", "array-bytes", @@ -8792,7 +8792,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "finality-grandpa", "futures", @@ -8813,7 +8813,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "ansi_term", "futures", @@ -8829,7 +8829,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "async-trait", @@ -8844,7 +8844,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "async-trait", @@ -8891,7 +8891,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "cid", "futures", @@ -8911,7 +8911,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "bitflags", @@ -8937,7 +8937,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "ahash", "futures", @@ -8955,7 +8955,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "futures", @@ -8976,7 +8976,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "async-trait", @@ -9007,7 +9007,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "futures", @@ -9026,7 +9026,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "bytes", @@ -9056,7 +9056,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "libp2p", @@ -9069,7 +9069,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9078,7 +9078,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "hash-db", @@ -9108,7 +9108,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "jsonrpsee", @@ -9131,7 +9131,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "jsonrpsee", @@ -9144,7 +9144,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "hex", @@ -9163,7 +9163,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "directories", @@ -9233,7 +9233,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "log", "parity-scale-codec", @@ -9245,7 +9245,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9264,7 +9264,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "libc", @@ -9283,7 +9283,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "chrono", "futures", @@ -9301,7 +9301,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "ansi_term", "atty", @@ -9332,7 +9332,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9343,7 +9343,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "futures", @@ -9369,7 +9369,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "futures", @@ -9383,7 +9383,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "futures-timer", @@ -9866,7 +9866,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "hash-db", "log", @@ -9884,7 +9884,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "blake2", "proc-macro-crate", @@ -9896,7 +9896,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "scale-info", @@ -9909,7 +9909,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "integer-sqrt", "num-traits", @@ -9924,7 +9924,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "scale-info", @@ -9937,7 +9937,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "parity-scale-codec", @@ -9949,7 +9949,7 @@ dependencies = [ [[package]] name = "sp-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "scale-info", @@ -9966,7 +9966,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "sp-api", @@ -9978,7 +9978,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "log", @@ -9996,7 +9996,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "futures", @@ -10015,7 +10015,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "merlin", @@ -10038,7 +10038,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "scale-info", @@ -10052,7 +10052,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "scale-info", @@ -10065,7 +10065,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "base58", @@ -10110,7 +10110,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "blake2", "byteorder", @@ -10124,7 +10124,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "proc-macro2", "quote", @@ -10135,7 +10135,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10144,7 +10144,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "proc-macro2", "quote", @@ -10154,7 +10154,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "environmental", "parity-scale-codec", @@ -10165,7 +10165,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "finality-grandpa", "log", @@ -10183,7 +10183,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10197,7 +10197,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "bytes", "ed25519-dalek", @@ -10224,7 +10224,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "lazy_static", "sp-core", @@ -10235,7 +10235,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "futures", @@ -10252,7 +10252,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "thiserror", "zstd", @@ -10261,7 +10261,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -10279,7 +10279,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "scale-info", @@ -10293,7 +10293,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "sp-api", "sp-core", @@ -10303,7 +10303,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "backtrace", "lazy_static", @@ -10313,7 +10313,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "rustc-hash", "serde", @@ -10323,7 +10323,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "either", "hash256-std-hasher", @@ -10345,7 +10345,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10363,7 +10363,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "Inflector", "proc-macro-crate", @@ -10375,7 +10375,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "scale-info", @@ -10389,7 +10389,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "scale-info", @@ -10400,7 +10400,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "hash-db", "log", @@ -10422,12 +10422,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10440,7 +10440,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "futures-timer", @@ -10456,7 +10456,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "sp-std", @@ -10468,7 +10468,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "sp-api", "sp-runtime", @@ -10477,7 +10477,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "log", @@ -10493,7 +10493,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "ahash", "hash-db", @@ -10516,7 +10516,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10533,7 +10533,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10544,7 +10544,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "impl-trait-for-tuples", "log", @@ -10557,7 +10557,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10772,7 +10772,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "platforms", ] @@ -10780,7 +10780,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -10801,7 +10801,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures-util", "hyper", @@ -10814,7 +10814,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "async-trait", "jsonrpsee", @@ -10827,7 +10827,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "jsonrpsee", "log", @@ -10848,7 +10848,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "array-bytes", "async-trait", @@ -10874,7 +10874,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "futures", "substrate-test-utils-derive", @@ -10884,7 +10884,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10895,7 +10895,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "ansi_term", "build-helper", @@ -11593,7 +11593,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#6e73c85b7ddbc2ec2a9f6629ddc06aca2f83bcf3" +source = "git+https://github.com/paritytech/substrate?branch=master#d0540a79967cb06cd7598a4965c7c06afc788b0c" dependencies = [ "clap", "frame-remote-externalities", From 7f437a5783cce57e686fbc22e4b109f40eadf7eb Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 15:10:12 +0900 Subject: [PATCH 181/231] Ensure benchmark functions pass filters --- xcm/pallet-xcm/src/benchmarking.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs index bdcc5a96d256..f61b4934ddce 100644 --- a/xcm/pallet-xcm/src/benchmarking.rs +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -38,6 +38,14 @@ benchmarks! { }: _>(send_origin, Box::new(versioned_dest), Box::new(versioned_msg)) teleport_assets { + let asset: MultiAsset = (Here, 10).into(); + let send_origin = T::ExecuteXcmOrigin::successful_origin(); + let origin_location = T::ExecuteXcmOrigin::try_origin(send_origin.clone()) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?; + if !T::XcmTeleportFilter::contains(&(origin_location, vec![asset.clone()])) { + return Err(BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX))) + } + let recipient = [0u8; 32]; let versioned_dest: VersionedMultiLocation = T::ReachableDest::get().ok_or( BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), @@ -45,10 +53,18 @@ benchmarks! { .into(); let versioned_beneficiary: VersionedMultiLocation = AccountId32 { network: None, id: recipient.into() }.into(); - let versioned_assets: VersionedMultiAssets = (Here, 10).into(); - }: _(RawOrigin::Root, Box::new(versioned_dest), Box::new(versioned_beneficiary), Box::new(versioned_assets), 0) + let versioned_assets: VersionedMultiAssets = asset.into(); + }: _>(send_origin, Box::new(versioned_dest), Box::new(versioned_beneficiary), Box::new(versioned_assets), 0) reserve_transfer_assets { + let asset: MultiAsset = (Here, 10).into(); + let send_origin = T::ExecuteXcmOrigin::successful_origin(); + let origin_location = T::ExecuteXcmOrigin::try_origin(send_origin.clone()) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?; + if !T::XcmReserveTransferFilter::contains(&(origin_location, vec![asset.clone()])) { + return Err(BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX))) + } + let recipient = [0u8; 32]; let versioned_dest: VersionedMultiLocation = T::ReachableDest::get().ok_or( BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)), @@ -56,8 +72,8 @@ benchmarks! { .into(); let versioned_beneficiary: VersionedMultiLocation = AccountId32 { network: None, id: recipient.into() }.into(); - let versioned_assets: VersionedMultiAssets = (Here, 10).into(); - }: _(RawOrigin::Root, Box::new(versioned_dest), Box::new(versioned_beneficiary), Box::new(versioned_assets), 0) + let versioned_assets: VersionedMultiAssets = asset.into(); + }: _>(send_origin, Box::new(versioned_dest), Box::new(versioned_beneficiary), Box::new(versioned_assets), 0) execute { let execute_origin = T::ExecuteXcmOrigin::successful_origin(); From 30a57603cd9ab4874bdb95a716a64da586c356ed Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 9 Dec 2022 17:20:32 +0900 Subject: [PATCH 182/231] Add runtime-benchmarks feature to fuzzer --- xcm/xcm-simulator/fuzzer/Cargo.toml | 5 +++++ xcm/xcm-simulator/fuzzer/src/parachain.rs | 2 ++ xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 2 ++ 3 files changed, 9 insertions(+) diff --git a/xcm/xcm-simulator/fuzzer/Cargo.toml b/xcm/xcm-simulator/fuzzer/Cargo.toml index 5a24c34f2b30..25767fb429b0 100644 --- a/xcm/xcm-simulator/fuzzer/Cargo.toml +++ b/xcm/xcm-simulator/fuzzer/Cargo.toml @@ -27,6 +27,11 @@ polkadot-core-primitives = { path = "../../../core-primitives" } polkadot-runtime-parachains = { path = "../../../runtime/parachains" } polkadot-parachain = { path = "../../../parachain" } +[features] +runtime-benchmarks = [ + "pallet-xcm/runtime-benchmarks", +] + [[bin]] path = "src/fuzz.rs" name = "xcm-fuzzer" diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index ee2b9b2804d4..d5e1ed7d2d88 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -308,6 +308,7 @@ impl mock_msg_queue::Config for Runtime { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] parameter_types! { pub ReachableDest: Option = Some(Parent.into()); } @@ -333,6 +334,7 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = LocationToAccountId; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; } diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index b94e1d967f60..99a6f9154f42 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -152,6 +152,7 @@ impl Config for XcmConfig { pub type LocalOriginToLocation = SignedToAccountId32; +#[cfg(feature = "runtime-benchmarks")] parameter_types! { pub ReachableDest: Option = Some(Parachain(1).into()); } @@ -178,6 +179,7 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; } From 5801648bf3566f9f982e8464da4455ba3f1866ad Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 10 Dec 2022 03:37:54 +0900 Subject: [PATCH 183/231] Ensure FixedRateOfFungible accounts for proof size weights --- xcm/pallet-xcm-benchmarks/src/mock.rs | 2 +- xcm/pallet-xcm/src/mock.rs | 4 +- xcm/xcm-builder/src/tests/assets.rs | 6 +-- xcm/xcm-builder/src/tests/bridging/mod.rs | 2 +- .../tests/bridging/paid_remote_relay_relay.rs | 18 ++++---- xcm/xcm-builder/src/tests/mock.rs | 6 ++- xcm/xcm-builder/src/tests/mod.rs | 2 +- xcm/xcm-builder/src/tests/transacting.rs | 10 ++-- xcm/xcm-builder/src/tests/weight.rs | 46 ++++++++++++++++--- xcm/xcm-builder/src/weight.rs | 25 ++++++---- xcm/xcm-builder/tests/mock/mod.rs | 6 +-- xcm/xcm-simulator/example/src/parachain.rs | 4 +- xcm/xcm-simulator/example/src/relay_chain.rs | 5 +- xcm/xcm-simulator/fuzzer/src/parachain.rs | 4 +- xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 4 +- 15 files changed, 92 insertions(+), 52 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/mock.rs b/xcm/pallet-xcm-benchmarks/src/mock.rs index e8cff81c635d..905a9af36fc4 100644 --- a/xcm/pallet-xcm-benchmarks/src/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/mock.rs @@ -64,7 +64,7 @@ impl xcm_executor::traits::Convert for AccountIdConverter { parameter_types! { pub UniversalLocation: InteriorMultiLocation = Junction::Parachain(101).into(); pub UnitWeightCost: Weight = Weight::from_parts(10, 10); - pub WeightPrice: (AssetId, u128) = (Concrete(Here.into()), 1_000_000); + pub WeightPrice: (AssetId, u128, u128) = (Concrete(Here.into()), 1_000_000, 1024); } pub struct AllAssetLocationsPass; diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 559bdadaace4..0681f77ba314 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -264,7 +264,7 @@ type LocalOriginConverter = ( parameter_types! { pub const BaseXcmWeight: Weight = Weight::from_parts(1_000, 1_000); - pub CurrencyPerSecond: (AssetId, u128) = (Concrete(RelayLocation::get()), 1); + pub CurrencyPerSecondPerByte: (AssetId, u128, u128) = (Concrete(RelayLocation::get()), 1, 1); pub TrustedAssets: (MultiAssetFilter, MultiLocation) = (All.into(), Here.into()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -288,7 +288,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = FixedRateOfFungible; + type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; type AssetLocker = (); diff --git a/xcm/xcm-builder/src/tests/assets.rs b/xcm/xcm-builder/src/tests/assets.rs index b5b54cb6e9a5..57eacf00183b 100644 --- a/xcm/xcm-builder/src/tests/assets.rs +++ b/xcm/xcm-builder/src/tests/assets.rs @@ -92,9 +92,9 @@ fn exchange_asset_should_fail_when_no_deal_possible() { fn paying_reserve_deposit_should_work() { AllowPaidFrom::set(vec![Parent.into()]); add_reserve(Parent.into(), (Parent, WildFungible).into()); - WeightPrice::set((Parent.into(), 1_000_000_000_000)); + WeightPrice::set((Parent.into(), 1_000_000_000_000, 1024 * 1024)); - let fees = (Parent, 30u128).into(); + let fees = (Parent, 60u128).into(); let message = Xcm(vec![ ReserveAssetDeposited((Parent, 100u128).into()), BuyExecution { fees, weight_limit: Limited(Weight::from_parts(30, 30)) }, @@ -104,7 +104,7 @@ fn paying_reserve_deposit_should_work() { let weight_limit = Weight::from_parts(50, 50); let r = XcmExecutor::::execute_xcm(Parent, message, hash, weight_limit); assert_eq!(r, Outcome::Complete(Weight::from_parts(30, 30))); - assert_eq!(asset_list(Here), vec![(Parent, 70u128).into()]); + assert_eq!(asset_list(Here), vec![(Parent, 40u128).into()]); } #[test] diff --git a/xcm/xcm-builder/src/tests/bridging/mod.rs b/xcm/xcm-builder/src/tests/bridging/mod.rs index c06e5afceb13..77014c76d9e3 100644 --- a/xcm/xcm-builder/src/tests/bridging/mod.rs +++ b/xcm/xcm-builder/src/tests/bridging/mod.rs @@ -176,7 +176,7 @@ impl, Remote: Get, RemoteExporter: ExportXcm> S let origin = Local::get().relative_to(&Remote::get()); AllowPaidFrom::set(vec![origin.clone()]); set_exporter_override(price::, deliver::); - // The we execute it: + // Then we execute it: let hash = fake_message_hash(&message); let outcome = XcmExecutor::::execute_xcm( origin, diff --git a/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs b/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs index 86cea75e7300..d31c46c734fb 100644 --- a/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs +++ b/xcm/xcm-builder/src/tests/bridging/paid_remote_relay_relay.rs @@ -28,9 +28,9 @@ parameter_types! { pub RelayUniversalLocation: Junctions = X1(GlobalConsensus(Local::get())); pub RemoteUniversalLocation: Junctions = X1(GlobalConsensus(Remote::get())); pub static BridgeTable: Vec<(NetworkId, MultiLocation, Option)> - = vec![(Remote::get(), MultiLocation::parent(), Some((Parent, 150u128).into()))]; - // ^^^ 100 to use the bridge (export) and 50 for the remote execution weight (5 instuctions - // x 10 weight each). + = vec![(Remote::get(), MultiLocation::parent(), Some((Parent, 200u128).into()))]; + // ^^^ 100 to use the bridge (export) and 100 for the remote execution weight (5 instructions + // x (10 + 10) weight each). } type TheBridge = TestBridge>; @@ -66,7 +66,7 @@ fn sending_to_bridged_chain_works() { add_asset(Parachain(100), (Here, 1000u128)); let msg = Xcm(vec![Trap(1)]); - assert_eq!(send_xcm::(dest, msg).unwrap().1, (Parent, 150u128).into()); + assert_eq!(send_xcm::(dest, msg).unwrap().1, (Parent, 200u128).into()); assert_eq!(TheBridge::service(), 1); assert_eq!( take_received_remote_messages(), @@ -80,8 +80,8 @@ fn sending_to_bridged_chain_works() { )] ); - // The export cost 50 weight units (and thus 50 units of balance). - assert_eq!(asset_list(Parachain(100)), vec![(Here, 850u128).into()]); + // The export cost 50 ref time and 50 proof size weight units (and thus 100 units of balance). + assert_eq!(asset_list(Parachain(100)), vec![(Here, 800u128).into()]); } /// ```nocompile @@ -107,7 +107,7 @@ fn sending_to_parachain_of_bridged_chain_works() { add_asset(Parachain(100), (Here, 1000u128)); let msg = Xcm(vec![Trap(1)]); - assert_eq!(send_xcm::(dest, msg).unwrap().1, (Parent, 150u128).into()); + assert_eq!(send_xcm::(dest, msg).unwrap().1, (Parent, 200u128).into()); assert_eq!(TheBridge::service(), 1); let expected = vec![( Parachain(100).into(), @@ -119,6 +119,6 @@ fn sending_to_parachain_of_bridged_chain_works() { )]; assert_eq!(take_received_remote_messages(), expected); - // The export cost 50 weight units (and thus 50 units of balance). - assert_eq!(asset_list(Parachain(100)), vec![(Here, 850u128).into()]); + // The export cost 50 ref time and 50 proof size weight units (and thus 100 units of balance). + assert_eq!(asset_list(Parachain(100)), vec![(Here, 800u128).into()]); } diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index 3662a4acf7b5..fa85d09a443e 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -412,8 +412,10 @@ parameter_types! { pub static AllowUnpaidFrom: Vec = vec![]; pub static AllowPaidFrom: Vec = vec![]; pub static AllowSubsFrom: Vec = vec![]; - // 1_000_000_000_000 => 1 unit of asset for 1 unit of Weight. - pub static WeightPrice: (AssetId, u128) = (From::from(Here), 1_000_000_000_000); + // 1_000_000_000_000 => 1 unit of asset for 1 unit of ref time weight. + // 1024 * 1024 => 1 unit of asset for 1 unit of proof size weight. + pub static WeightPrice: (AssetId, u128, u128) = + (From::from(Here), 1_000_000_000_000, 1024 * 1024); pub static MaxInstructions: u32 = 100; } diff --git a/xcm/xcm-builder/src/tests/mod.rs b/xcm/xcm-builder/src/tests/mod.rs index 3f850134711f..cc83d9d5ac98 100644 --- a/xcm/xcm-builder/src/tests/mod.rs +++ b/xcm/xcm-builder/src/tests/mod.rs @@ -19,7 +19,7 @@ use core::convert::TryInto; use frame_support::{ assert_err, traits::{ConstU32, ContainsPair}, - weights::constants::WEIGHT_REF_TIME_PER_SECOND, + weights::constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND}, }; use xcm_executor::{traits::prelude::*, Config, XcmExecutor}; diff --git a/xcm/xcm-builder/src/tests/transacting.rs b/xcm/xcm-builder/src/tests/transacting.rs index 972ce61a78c2..bcff05f35d66 100644 --- a/xcm/xcm-builder/src/tests/transacting.rs +++ b/xcm/xcm-builder/src/tests/transacting.rs @@ -67,13 +67,13 @@ fn transacting_should_refund_weight() { fn paid_transacting_should_refund_payment_for_unused_weight() { let one: MultiLocation = AccountIndex64 { index: 1, network: None }.into(); AllowPaidFrom::set(vec![one.clone()]); - add_asset(AccountIndex64 { index: 1, network: None }, (Parent, 100u128)); - WeightPrice::set((Parent.into(), 1_000_000_000_000)); + add_asset(AccountIndex64 { index: 1, network: None }, (Parent, 200u128)); + WeightPrice::set((Parent.into(), 1_000_000_000_000, 1024 * 1024)); let origin = one.clone(); - let fees = (Parent, 100u128).into(); + let fees = (Parent, 200u128).into(); let message = Xcm::(vec![ - WithdrawAsset((Parent, 100u128).into()), // enough for 100 units of weight. + WithdrawAsset((Parent, 200u128).into()), // enough for 200 units of weight. BuyExecution { fees, weight_limit: Limited(Weight::from_parts(100, 100)) }, Transact { origin_kind: OriginKind::Native, @@ -92,7 +92,7 @@ fn paid_transacting_should_refund_payment_for_unused_weight() { assert_eq!(r, Outcome::Complete(Weight::from_parts(60, 60))); assert_eq!( asset_list(AccountIndex64 { index: 1, network: None }), - vec![(Parent, 40u128).into()] + vec![(Parent, 80u128).into()] ); } diff --git a/xcm/xcm-builder/src/tests/weight.rs b/xcm/xcm-builder/src/tests/weight.rs index 67390a030c6a..09982bd84fe0 100644 --- a/xcm/xcm-builder/src/tests/weight.rs +++ b/xcm/xcm-builder/src/tests/weight.rs @@ -16,6 +16,36 @@ use super::*; +#[test] +fn fixed_rate_of_fungible_should_work() { + parameter_types! { + pub static WeightPrice: (AssetId, u128, u128) = + (Here.into(), WEIGHT_REF_TIME_PER_SECOND.into(), WEIGHT_PROOF_SIZE_PER_MB.into()); + } + + let mut trader = FixedRateOfFungible::::new(); + // supplies 100 unit of asset, 80 still remains after purchasing weight + assert_eq!( + trader.buy_weight(Weight::from_parts(10, 10), fungible_multi_asset(Here.into(), 100).into()), + Ok(fungible_multi_asset(Here.into(), 80).into()), + ); + // should have nothing left, as 5 + 5 = 10, and we supplied 10 units of asset. + assert_eq!( + trader.buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(Here.into(), 10).into()), + Ok(vec![].into()), + ); + // should have 5 left, as there are no proof size components + assert_eq!( + trader.buy_weight(Weight::from_parts(5, 0), fungible_multi_asset(Here.into(), 10).into()), + Ok(fungible_multi_asset(Here.into(), 5).into()), + ); + // not enough to purchase the combined weights + assert_err!( + trader.buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(Here.into(), 5).into()), + XcmError::TooExpensive, + ); +} + #[test] fn errors_should_return_unused_weight() { // we'll let them have message execution for free. @@ -104,8 +134,10 @@ fn weight_trader_tuple_should_work() { let para_2: MultiLocation = Parachain(2).into(); parameter_types! { - pub static HereWeightPrice: (AssetId, u128) = (Here.into(), WEIGHT_REF_TIME_PER_SECOND.into()); - pub static Para1WeightPrice: (AssetId, u128) = (Parachain(1).into(), WEIGHT_REF_TIME_PER_SECOND.into()); + pub static HereWeightPrice: (AssetId, u128, u128) = + (Here.into(), WEIGHT_REF_TIME_PER_SECOND.into(), WEIGHT_PROOF_SIZE_PER_MB.into()); + pub static Para1WeightPrice: (AssetId, u128, u128) = + (Parachain(1).into(), WEIGHT_REF_TIME_PER_SECOND.into(), WEIGHT_PROOF_SIZE_PER_MB.into()); } type Traders = ( @@ -119,25 +151,25 @@ fn weight_trader_tuple_should_work() { // trader one buys weight assert_eq!( traders.buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(Here.into(), 10).into()), - Ok(fungible_multi_asset(Here.into(), 5).into()), + Ok(vec![].into()), ); // trader one refunds assert_eq!( traders.refund_weight(Weight::from_parts(2, 2)), - Some(fungible_multi_asset(Here.into(), 2)) + Some(fungible_multi_asset(Here.into(), 4)) ); let mut traders = Traders::new(); // trader one failed; trader two buys weight assert_eq!( traders - .buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(para_1.clone(), 10).into()), - Ok(fungible_multi_asset(para_1.clone(), 5).into()), + .buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(para_1, 10).into()), + Ok(vec![].into()), ); // trader two refunds assert_eq!( traders.refund_weight(Weight::from_parts(2, 2)), - Some(fungible_multi_asset(para_1, 2)) + Some(fungible_multi_asset(para_1, 4)) ); let mut traders = Traders::new(); diff --git a/xcm/xcm-builder/src/weight.rs b/xcm/xcm-builder/src/weight.rs index 7d1299b6a6dc..f518b5072897 100644 --- a/xcm/xcm-builder/src/weight.rs +++ b/xcm/xcm-builder/src/weight.rs @@ -17,7 +17,10 @@ use frame_support::{ dispatch::GetDispatchInfo, traits::{tokens::currency::Currency as CurrencyT, Get, OnUnbalanced as OnUnbalancedT}, - weights::{constants::WEIGHT_REF_TIME_PER_SECOND, WeightToFee as WeightToFeeT}, + weights::{ + constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND}, + WeightToFee as WeightToFeeT, + }, }; use parity_scale_codec::Decode; use sp_runtime::traits::{SaturatedConversion, Saturating, Zero}; @@ -125,14 +128,14 @@ impl TakeRevenue for () { /// Simple fee calculator that requires payment in a single fungible at a fixed rate. /// -/// The constant `Get` type parameter should be the fungible ID and the amount of it required for -/// one second of weight. -pub struct FixedRateOfFungible, R: TakeRevenue>( +/// The constant `Get` type parameter should be the fungible ID, the amount of it required for one +/// second of weight and the amount required for 1 MB of proof. +pub struct FixedRateOfFungible, R: TakeRevenue>( Weight, u128, PhantomData<(T, R)>, ); -impl, R: TakeRevenue> WeightTrader for FixedRateOfFungible { +impl, R: TakeRevenue> WeightTrader for FixedRateOfFungible { fn new() -> Self { Self(Weight::zero(), 0, PhantomData) } @@ -143,9 +146,10 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOfFungib "FixedRateOfFungible::buy_weight weight: {:?}, payment: {:?}", weight, payment, ); - let (id, units_per_second) = T::get(); + let (id, units_per_second, units_per_mb) = T::get(); let amount = - units_per_second * (weight.ref_time() as u128) / (WEIGHT_REF_TIME_PER_SECOND as u128); + (units_per_second * (weight.ref_time() as u128) / (WEIGHT_REF_TIME_PER_SECOND as u128)) + + (units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)); if amount == 0 { return Ok(payment) } @@ -158,10 +162,11 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOfFungib fn refund_weight(&mut self, weight: Weight) -> Option { log::trace!(target: "xcm::weight", "FixedRateOfFungible::refund_weight weight: {:?}", weight); - let (id, units_per_second) = T::get(); + let (id, units_per_second, units_per_mb) = T::get(); let weight = weight.min(self.0); let amount = - units_per_second * (weight.ref_time() as u128) / (WEIGHT_REF_TIME_PER_SECOND as u128); + (units_per_second * (weight.ref_time() as u128) / (WEIGHT_REF_TIME_PER_SECOND as u128)) + + (units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)); self.0 -= weight; self.1 = self.1.saturating_sub(amount); if amount > 0 { @@ -172,7 +177,7 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOfFungib } } -impl, R: TakeRevenue> Drop for FixedRateOfFungible { +impl, R: TakeRevenue> Drop for FixedRateOfFungible { fn drop(&mut self) { if self.1 > 0 { R::take_revenue((T::get().0, self.1).into()); diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 68018808e906..79cecfbdcb9a 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -153,8 +153,8 @@ type LocalOriginConverter = ( ); parameter_types! { - pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000_000); - pub KsmPerSecond: (AssetId, u128) = (KsmLocation::get().into(), 1); + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 1024); + pub KsmPerSecondPerByte: (AssetId, u128, u128) = (KsmLocation::get().into(), 1, 1); } pub type Barrier = ( @@ -184,7 +184,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = FixedRateOfFungible; + type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; type AssetLocker = (); diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 2d6838bbb485..3ef6c4b9d651 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -188,7 +188,7 @@ pub type XcmOriginToCallOrigin = ( parameter_types! { pub const UnitWeightCost: Weight = Weight::from_parts(1, 1); - pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); + pub KsmPerSecondPerByte: (AssetId, u128, u128) = (Concrete(Parent.into()), 1, 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; pub ForeignPrefix: MultiLocation = (Parent,).into(); @@ -229,7 +229,7 @@ impl Config for XcmConfig { type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = FixedRateOfFungible; + type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); type AssetLocker = (); diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 0b1cd30e11c2..9e095270e673 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -150,7 +150,8 @@ type LocalOriginConverter = ( parameter_types! { pub const BaseXcmWeight: Weight = Weight::from_parts(1_000, 1_000); - pub TokensPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1_000_000_000_000); + pub TokensPerSecondPerByte: (AssetId, u128, u128) = + (Concrete(TokenLocation::get()), 1_000_000_000_000, 1024 * 1024); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -169,7 +170,7 @@ impl Config for XcmConfig { type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = FixedRateOfFungible; + type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); type AssetLocker = XcmPallet; diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index d5e1ed7d2d88..c2940ef3c513 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -121,7 +121,7 @@ pub type XcmOriginToCallOrigin = ( parameter_types! { pub const UnitWeightCost: Weight = Weight::from_parts(1, 1); - pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); + pub KsmPerSecondPerByte: (AssetId, u128, u128) = (Concrete(Parent.into()), 1, 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -143,7 +143,7 @@ impl Config for XcmConfig { type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = FixedRateOfFungible; + type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); type AssetLocker = (); diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 99a6f9154f42..fe08a056cdc1 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -115,7 +115,7 @@ type LocalOriginConverter = ( parameter_types! { pub const BaseXcmWeight: Weight = Weight::from_parts(1_000, 1_000); - pub KsmPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1); + pub KsmPerSecondPerByte: (AssetId, u128, u128) = (Concrete(TokenLocation::get()), 1, 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -134,7 +134,7 @@ impl Config for XcmConfig { type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = FixedRateOfFungible; + type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); type AssetLocker = (); From 15d7413a5fb8bb32fc49eca6d5ed5c349a4511e7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 10 Dec 2022 03:39:08 +0900 Subject: [PATCH 184/231] cargo fmt --- xcm/xcm-builder/src/tests/weight.rs | 6 +++--- xcm/xcm-builder/src/weight.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/xcm/xcm-builder/src/tests/weight.rs b/xcm/xcm-builder/src/tests/weight.rs index 09982bd84fe0..e98ea8bd0968 100644 --- a/xcm/xcm-builder/src/tests/weight.rs +++ b/xcm/xcm-builder/src/tests/weight.rs @@ -26,7 +26,8 @@ fn fixed_rate_of_fungible_should_work() { let mut trader = FixedRateOfFungible::::new(); // supplies 100 unit of asset, 80 still remains after purchasing weight assert_eq!( - trader.buy_weight(Weight::from_parts(10, 10), fungible_multi_asset(Here.into(), 100).into()), + trader + .buy_weight(Weight::from_parts(10, 10), fungible_multi_asset(Here.into(), 100).into()), Ok(fungible_multi_asset(Here.into(), 80).into()), ); // should have nothing left, as 5 + 5 = 10, and we supplied 10 units of asset. @@ -162,8 +163,7 @@ fn weight_trader_tuple_should_work() { let mut traders = Traders::new(); // trader one failed; trader two buys weight assert_eq!( - traders - .buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(para_1, 10).into()), + traders.buy_weight(Weight::from_parts(5, 5), fungible_multi_asset(para_1, 10).into()), Ok(vec![].into()), ); // trader two refunds diff --git a/xcm/xcm-builder/src/weight.rs b/xcm/xcm-builder/src/weight.rs index f518b5072897..815ad3ae9784 100644 --- a/xcm/xcm-builder/src/weight.rs +++ b/xcm/xcm-builder/src/weight.rs @@ -147,9 +147,9 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOf weight, payment, ); let (id, units_per_second, units_per_mb) = T::get(); - let amount = - (units_per_second * (weight.ref_time() as u128) / (WEIGHT_REF_TIME_PER_SECOND as u128)) - + (units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)); + let amount = (units_per_second * (weight.ref_time() as u128) / + (WEIGHT_REF_TIME_PER_SECOND as u128)) + + (units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)); if amount == 0 { return Ok(payment) } @@ -164,9 +164,9 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOf log::trace!(target: "xcm::weight", "FixedRateOfFungible::refund_weight weight: {:?}", weight); let (id, units_per_second, units_per_mb) = T::get(); let weight = weight.min(self.0); - let amount = - (units_per_second * (weight.ref_time() as u128) / (WEIGHT_REF_TIME_PER_SECOND as u128)) - + (units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)); + let amount = (units_per_second * (weight.ref_time() as u128) / + (WEIGHT_REF_TIME_PER_SECOND as u128)) + + (units_per_mb * (weight.proof_size() as u128) / (WEIGHT_PROOF_SIZE_PER_MB as u128)); self.0 -= weight; self.1 = self.1.saturating_sub(amount); if amount > 0 { From 1e0132dc3c0c906707e82b541ce17a086a276933 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 10 Dec 2022 03:53:24 +0900 Subject: [PATCH 185/231] Whitelist remark_with_event when runtime-benchmarks feature is enabled --- runtime/kusama/src/xcm_config.rs | 359 +++++++++++++++-------------- runtime/polkadot/src/xcm_config.rs | 295 +++++++++++++----------- runtime/rococo/src/xcm_config.rs | 241 ++++++++++--------- runtime/westend/src/xcm_config.rs | 179 +++++++------- 4 files changed, 563 insertions(+), 511 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 17511fd75572..c2da5c9a7528 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Everything, Nothing}, + traits::{Contains, Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -138,178 +138,191 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -match_types! { - // A call filter for the XCM Transact instruction. This is a temporary measure until we - // properly account for proof size weights. - // - // Calls that are allowed through this filter must: - // 1. Have a fixed weight; - // 2. Cannot lead to another call being made; - // 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. - pub type SafeCallFilter: impl Contains = { - RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, - ) | - RuntimeCall::Babe(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Indices(..) | - RuntimeCall::Balances(..) | - RuntimeCall::Staking( - pallet_staking::Call::bond { .. } | - pallet_staking::Call::bond_extra { .. } | - pallet_staking::Call::unbond { .. } | - pallet_staking::Call::withdraw_unbonded { .. } | - pallet_staking::Call::validate { .. } | - pallet_staking::Call::nominate { .. } | - pallet_staking::Call::chill { .. } | - pallet_staking::Call::set_payee { .. } | - pallet_staking::Call::set_controller { .. } | - pallet_staking::Call::set_validator_count { .. } | - pallet_staking::Call::increase_validator_count { .. } | - pallet_staking::Call::scale_validator_count { .. } | - pallet_staking::Call::force_no_eras { .. } | - pallet_staking::Call::force_new_era { .. } | - pallet_staking::Call::set_invulnerables { .. } | - pallet_staking::Call::force_unstake { .. } | - pallet_staking::Call::force_new_era_always { .. } | - pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::rebond { .. } | - pallet_staking::Call::reap_stash { .. } | - pallet_staking::Call::set_staking_configs { .. } | - pallet_staking::Call::chill_other { .. } | - pallet_staking::Call::force_apply_min_commission { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::Grandpa(..) | - RuntimeCall::ImOnline(..) | - RuntimeCall::Democracy( - pallet_democracy::Call::second { .. } | - pallet_democracy::Call::vote { .. } | - pallet_democracy::Call::emergency_cancel { .. } | - pallet_democracy::Call::fast_track { .. } | - pallet_democracy::Call::veto_external { .. } | - pallet_democracy::Call::cancel_referendum { .. } | - pallet_democracy::Call::delegate { .. } | - pallet_democracy::Call::undelegate { .. } | - pallet_democracy::Call::clear_public_proposals { .. } | - pallet_democracy::Call::unlock { .. } | - pallet_democracy::Call::remove_vote { .. } | - pallet_democracy::Call::remove_other_vote { .. } | - pallet_democracy::Call::blacklist { .. } | - pallet_democracy::Call::cancel_proposal { .. }, - ) | - RuntimeCall::Council( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::TechnicalCommittee( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::PhragmenElection( - pallet_elections_phragmen::Call::remove_voter { .. } | - pallet_elections_phragmen::Call::submit_candidacy { .. } | - pallet_elections_phragmen::Call::renounce_candidacy { .. } | - pallet_elections_phragmen::Call::remove_member { .. } | - pallet_elections_phragmen::Call::clean_defunct_voters { .. }, - ) | - RuntimeCall::TechnicalMembership( - pallet_membership::Call::add_member { .. } | - pallet_membership::Call::remove_member { .. } | - pallet_membership::Call::swap_member { .. } | - pallet_membership::Call::change_key { .. } | - pallet_membership::Call::set_prime { .. } | - pallet_membership::Call::clear_prime { .. }, - ) | - RuntimeCall::Treasury(..) | - RuntimeCall::ConvictionVoting(..) | - RuntimeCall::Referenda( - pallet_referenda::Call::place_decision_deposit { .. } | - pallet_referenda::Call::refund_decision_deposit { .. } | - pallet_referenda::Call::cancel { .. } | - pallet_referenda::Call::kill { .. } | - pallet_referenda::Call::nudge_referendum { .. } | - pallet_referenda::Call::one_fewer_deciding { .. }, - ) | - RuntimeCall::FellowshipCollective(..) | - RuntimeCall::FellowshipReferenda( - pallet_referenda::Call::place_decision_deposit { .. } | - pallet_referenda::Call::refund_decision_deposit { .. } | - pallet_referenda::Call::cancel { .. } | - pallet_referenda::Call::kill { .. } | - pallet_referenda::Call::nudge_referendum { .. } | - pallet_referenda::Call::one_fewer_deciding { .. }, - ) | - RuntimeCall::Claims( - super::claims::Call::claim { .. } | - super::claims::Call::mint_claim { .. } | - super::claims::Call::move_claim { .. }, - ) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Identity( - pallet_identity::Call::add_registrar { .. } | - pallet_identity::Call::set_identity { .. } | - pallet_identity::Call::clear_identity { .. } | - pallet_identity::Call::request_judgement { .. } | - pallet_identity::Call::cancel_request { .. } | - pallet_identity::Call::set_fee { .. } | - pallet_identity::Call::set_account_id { .. } | - pallet_identity::Call::set_fields { .. } | - pallet_identity::Call::provide_judgement { .. } | - pallet_identity::Call::kill_identity { .. } | - pallet_identity::Call::add_sub { .. } | - pallet_identity::Call::rename_sub { .. } | - pallet_identity::Call::remove_sub { .. } | - pallet_identity::Call::quit_sub { .. }, - ) | - RuntimeCall::Society( - pallet_society::Call::bid { .. } | - pallet_society::Call::unbid { .. } | - pallet_society::Call::vouch { .. } | - pallet_society::Call::unvouch { .. } | - pallet_society::Call::vote { .. } | - pallet_society::Call::defender_vote { .. } | - pallet_society::Call::payout { .. } | - pallet_society::Call::unfound { .. } | - pallet_society::Call::judge_suspended_member { .. } | - pallet_society::Call::judge_suspended_candidate { .. } | - pallet_society::Call::set_max_members { .. }, - ) | - RuntimeCall::Recovery(..) | - RuntimeCall::Vesting(..) | - RuntimeCall::Bounties( - pallet_bounties::Call::propose_bounty { .. } | - pallet_bounties::Call::approve_bounty { .. } | - pallet_bounties::Call::propose_curator { .. } | - pallet_bounties::Call::unassign_curator { .. } | - pallet_bounties::Call::accept_curator { .. } | - pallet_bounties::Call::award_bounty { .. } | - pallet_bounties::Call::claim_bounty { .. } | - pallet_bounties::Call::close_bounty { .. }, - ) | - RuntimeCall::ChildBounties(..) | - RuntimeCall::ElectionProviderMultiPhase(..) | - RuntimeCall::VoterList(..) | - RuntimeCall::NominationPools( - pallet_nomination_pools::Call::join { .. } | - pallet_nomination_pools::Call::bond_extra { .. } | - pallet_nomination_pools::Call::claim_payout { .. } | - pallet_nomination_pools::Call::unbond { .. } | - pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | - pallet_nomination_pools::Call::withdraw_unbonded { .. } | - pallet_nomination_pools::Call::create { .. } | - pallet_nomination_pools::Call::create_with_pool_id { .. } | - pallet_nomination_pools::Call::set_state { .. } | - pallet_nomination_pools::Call::set_configs { .. } | - pallet_nomination_pools::Call::update_roles { .. } | - pallet_nomination_pools::Call::chill { .. }, - ) | - RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) - }; +/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly +/// account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(call: &RuntimeCall) -> bool { + #[cfg(feature = "runtime-benchmarks")] + { + if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) { + return true + } + } + + match call { + RuntimeCall::System( + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::nominate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::rebond { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::ConvictionVoting(..) | + RuntimeCall::Referenda( + pallet_referenda::Call::place_decision_deposit { .. } | + pallet_referenda::Call::refund_decision_deposit { .. } | + pallet_referenda::Call::cancel { .. } | + pallet_referenda::Call::kill { .. } | + pallet_referenda::Call::nudge_referendum { .. } | + pallet_referenda::Call::one_fewer_deciding { .. }, + ) | + RuntimeCall::FellowshipCollective(..) | + RuntimeCall::FellowshipReferenda( + pallet_referenda::Call::place_decision_deposit { .. } | + pallet_referenda::Call::refund_decision_deposit { .. } | + pallet_referenda::Call::cancel { .. } | + pallet_referenda::Call::kill { .. } | + pallet_referenda::Call::nudge_referendum { .. } | + pallet_referenda::Call::one_fewer_deciding { .. }, + ) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Society( + pallet_society::Call::bid { .. } | + pallet_society::Call::unbid { .. } | + pallet_society::Call::vouch { .. } | + pallet_society::Call::unvouch { .. } | + pallet_society::Call::vote { .. } | + pallet_society::Call::defender_vote { .. } | + pallet_society::Call::payout { .. } | + pallet_society::Call::unfound { .. } | + pallet_society::Call::judge_suspended_member { .. } | + pallet_society::Call::judge_suspended_candidate { .. } | + pallet_society::Call::set_max_members { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ) | + RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { + .. + }) => true, + _ => false, + } + } } pub struct XcmConfig; diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index c4dc9ecb70bd..d609e610bb8b 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Everything, Nothing}, + traits::{Contains, Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -136,146 +136,159 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -match_types! { - // A call filter for the XCM Transact instruction. This is a temporary measure until we - // properly account for proof size weights. - // - // Calls that are allowed through this filter must: - // 1. Have a fixed weight; - // 2. Cannot lead to another call being made; - // 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. - pub type SafeCallFilter: impl Contains = { - RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, - ) | - RuntimeCall::Babe(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Indices(..) | - RuntimeCall::Balances(..) | - RuntimeCall::Staking( - pallet_staking::Call::bond { .. } | - pallet_staking::Call::bond_extra { .. } | - pallet_staking::Call::unbond { .. } | - pallet_staking::Call::withdraw_unbonded { .. } | - pallet_staking::Call::validate { .. } | - pallet_staking::Call::nominate { .. } | - pallet_staking::Call::chill { .. } | - pallet_staking::Call::set_payee { .. } | - pallet_staking::Call::set_controller { .. } | - pallet_staking::Call::set_validator_count { .. } | - pallet_staking::Call::increase_validator_count { .. } | - pallet_staking::Call::scale_validator_count { .. } | - pallet_staking::Call::force_no_eras { .. } | - pallet_staking::Call::force_new_era { .. } | - pallet_staking::Call::set_invulnerables { .. } | - pallet_staking::Call::force_unstake { .. } | - pallet_staking::Call::force_new_era_always { .. } | - pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::rebond { .. } | - pallet_staking::Call::reap_stash { .. } | - pallet_staking::Call::set_staking_configs { .. } | - pallet_staking::Call::chill_other { .. } | - pallet_staking::Call::force_apply_min_commission { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::Grandpa(..) | - RuntimeCall::ImOnline(..) | - RuntimeCall::Democracy( - pallet_democracy::Call::second { .. } | - pallet_democracy::Call::vote { .. } | - pallet_democracy::Call::emergency_cancel { .. } | - pallet_democracy::Call::fast_track { .. } | - pallet_democracy::Call::veto_external { .. } | - pallet_democracy::Call::cancel_referendum { .. } | - pallet_democracy::Call::delegate { .. } | - pallet_democracy::Call::undelegate { .. } | - pallet_democracy::Call::clear_public_proposals { .. } | - pallet_democracy::Call::unlock { .. } | - pallet_democracy::Call::remove_vote { .. } | - pallet_democracy::Call::remove_other_vote { .. } | - pallet_democracy::Call::blacklist { .. } | - pallet_democracy::Call::cancel_proposal { .. }, - ) | - RuntimeCall::Council( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::TechnicalCommittee( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::PhragmenElection( - pallet_elections_phragmen::Call::remove_voter { .. } | - pallet_elections_phragmen::Call::submit_candidacy { .. } | - pallet_elections_phragmen::Call::renounce_candidacy { .. } | - pallet_elections_phragmen::Call::remove_member { .. } | - pallet_elections_phragmen::Call::clean_defunct_voters { .. }, - ) | - RuntimeCall::TechnicalMembership( - pallet_membership::Call::add_member { .. } | - pallet_membership::Call::remove_member { .. } | - pallet_membership::Call::swap_member { .. } | - pallet_membership::Call::change_key { .. } | - pallet_membership::Call::set_prime { .. } | - pallet_membership::Call::clear_prime { .. }, - ) | - RuntimeCall::Treasury(..) | - RuntimeCall::Claims( - super::claims::Call::claim { .. } | - super::claims::Call::mint_claim { .. } | - super::claims::Call::move_claim { .. }, - ) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Identity( - pallet_identity::Call::add_registrar { .. } | - pallet_identity::Call::set_identity { .. } | - pallet_identity::Call::clear_identity { .. } | - pallet_identity::Call::request_judgement { .. } | - pallet_identity::Call::cancel_request { .. } | - pallet_identity::Call::set_fee { .. } | - pallet_identity::Call::set_account_id { .. } | - pallet_identity::Call::set_fields { .. } | - pallet_identity::Call::provide_judgement { .. } | - pallet_identity::Call::kill_identity { .. } | - pallet_identity::Call::add_sub { .. } | - pallet_identity::Call::rename_sub { .. } | - pallet_identity::Call::remove_sub { .. } | - pallet_identity::Call::quit_sub { .. }, - ) | - RuntimeCall::Vesting(..) | - RuntimeCall::Bounties( - pallet_bounties::Call::propose_bounty { .. } | - pallet_bounties::Call::approve_bounty { .. } | - pallet_bounties::Call::propose_curator { .. } | - pallet_bounties::Call::unassign_curator { .. } | - pallet_bounties::Call::accept_curator { .. } | - pallet_bounties::Call::award_bounty { .. } | - pallet_bounties::Call::claim_bounty { .. } | - pallet_bounties::Call::close_bounty { .. }, - ) | - RuntimeCall::ChildBounties(..) | - RuntimeCall::ElectionProviderMultiPhase(..) | - RuntimeCall::VoterList(..) | - RuntimeCall::NominationPools( - pallet_nomination_pools::Call::join { .. } | - pallet_nomination_pools::Call::bond_extra { .. } | - pallet_nomination_pools::Call::claim_payout { .. } | - pallet_nomination_pools::Call::unbond { .. } | - pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | - pallet_nomination_pools::Call::withdraw_unbonded { .. } | - pallet_nomination_pools::Call::create { .. } | - pallet_nomination_pools::Call::create_with_pool_id { .. } | - pallet_nomination_pools::Call::set_state { .. } | - pallet_nomination_pools::Call::set_configs { .. } | - pallet_nomination_pools::Call::update_roles { .. } | - pallet_nomination_pools::Call::chill { .. }, - ) | - RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) - }; +/// A call filter for the XCM Transact instruction. This is a temporary measure until we +/// properly account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(call: &RuntimeCall) -> bool { + #[cfg(feature = "runtime-benchmarks")] + { + if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) { + return true + } + } + + match call { + RuntimeCall::System( + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::nominate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::rebond { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ) | + RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { + .. + }) => true, + _ => false, + } + } } pub struct XcmConfig; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index a57f73c13f76..f3fe46fb6648 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -22,7 +22,7 @@ use super::{ }; use frame_support::{ match_types, parameter_types, - traits::{Everything, Nothing}, + traits::{Contains, Everything, Nothing}, weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; @@ -134,119 +134,132 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -match_types! { - // A call filter for the XCM Transact instruction. This is a temporary measure until we - // properly account for proof size weights. - // - // Calls that are allowed through this filter must: - // 1. Have a fixed weight; - // 2. Cannot lead to another call being made; - // 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. - pub type SafeCallFilter: impl Contains = { - RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, - ) | - RuntimeCall::Babe(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Indices(..) | - RuntimeCall::Balances(..) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::Grandpa(..) | - RuntimeCall::ImOnline(..) | - RuntimeCall::Democracy( - pallet_democracy::Call::second { .. } | - pallet_democracy::Call::vote { .. } | - pallet_democracy::Call::emergency_cancel { .. } | - pallet_democracy::Call::fast_track { .. } | - pallet_democracy::Call::veto_external { .. } | - pallet_democracy::Call::cancel_referendum { .. } | - pallet_democracy::Call::delegate { .. } | - pallet_democracy::Call::undelegate { .. } | - pallet_democracy::Call::clear_public_proposals { .. } | - pallet_democracy::Call::unlock { .. } | - pallet_democracy::Call::remove_vote { .. } | - pallet_democracy::Call::remove_other_vote { .. } | - pallet_democracy::Call::blacklist { .. } | - pallet_democracy::Call::cancel_proposal { .. }, - ) | - RuntimeCall::Council( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::TechnicalCommittee( - pallet_collective::Call::vote { .. } | - pallet_collective::Call::close_old_weight { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::PhragmenElection( - pallet_elections_phragmen::Call::remove_voter { .. } | - pallet_elections_phragmen::Call::submit_candidacy { .. } | - pallet_elections_phragmen::Call::renounce_candidacy { .. } | - pallet_elections_phragmen::Call::remove_member { .. } | - pallet_elections_phragmen::Call::clean_defunct_voters { .. }, - ) | - RuntimeCall::TechnicalMembership( - pallet_membership::Call::add_member { .. } | - pallet_membership::Call::remove_member { .. } | - pallet_membership::Call::swap_member { .. } | - pallet_membership::Call::change_key { .. } | - pallet_membership::Call::set_prime { .. } | - pallet_membership::Call::clear_prime { .. }, - ) | - RuntimeCall::Treasury(..) | - RuntimeCall::Claims( - super::claims::Call::claim { .. } | - super::claims::Call::mint_claim { .. } | - super::claims::Call::move_claim { .. }, - ) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Identity( - pallet_identity::Call::add_registrar { .. } | - pallet_identity::Call::set_identity { .. } | - pallet_identity::Call::clear_identity { .. } | - pallet_identity::Call::request_judgement { .. } | - pallet_identity::Call::cancel_request { .. } | - pallet_identity::Call::set_fee { .. } | - pallet_identity::Call::set_account_id { .. } | - pallet_identity::Call::set_fields { .. } | - pallet_identity::Call::provide_judgement { .. } | - pallet_identity::Call::kill_identity { .. } | - pallet_identity::Call::add_sub { .. } | - pallet_identity::Call::rename_sub { .. } | - pallet_identity::Call::remove_sub { .. } | - pallet_identity::Call::quit_sub { .. }, - ) | - RuntimeCall::Society( - pallet_society::Call::bid { .. } | - pallet_society::Call::unbid { .. } | - pallet_society::Call::vouch { .. } | - pallet_society::Call::unvouch { .. } | - pallet_society::Call::vote { .. } | - pallet_society::Call::defender_vote { .. } | - pallet_society::Call::payout { .. } | - pallet_society::Call::unfound { .. } | - pallet_society::Call::judge_suspended_member { .. } | - pallet_society::Call::judge_suspended_candidate { .. } | - pallet_society::Call::set_max_members { .. }, - ) | - RuntimeCall::Recovery(..) | - RuntimeCall::Vesting(..) | - RuntimeCall::Bounties( - pallet_bounties::Call::propose_bounty { .. } | - pallet_bounties::Call::approve_bounty { .. } | - pallet_bounties::Call::propose_curator { .. } | - pallet_bounties::Call::unassign_curator { .. } | - pallet_bounties::Call::accept_curator { .. } | - pallet_bounties::Call::award_bounty { .. } | - pallet_bounties::Call::claim_bounty { .. } | - pallet_bounties::Call::close_bounty { .. }, - ) | - RuntimeCall::ChildBounties(..) | - RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) - }; +/// A call filter for the XCM Transact instruction. This is a temporary measure until we +/// properly account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(call: &RuntimeCall) -> bool { + #[cfg(feature = "runtime-benchmarks")] + { + if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) { + return true + } + } + + match call { + RuntimeCall::System( + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy( + pallet_democracy::Call::second { .. } | + pallet_democracy::Call::vote { .. } | + pallet_democracy::Call::emergency_cancel { .. } | + pallet_democracy::Call::fast_track { .. } | + pallet_democracy::Call::veto_external { .. } | + pallet_democracy::Call::cancel_referendum { .. } | + pallet_democracy::Call::delegate { .. } | + pallet_democracy::Call::undelegate { .. } | + pallet_democracy::Call::clear_public_proposals { .. } | + pallet_democracy::Call::unlock { .. } | + pallet_democracy::Call::remove_vote { .. } | + pallet_democracy::Call::remove_other_vote { .. } | + pallet_democracy::Call::blacklist { .. } | + pallet_democracy::Call::cancel_proposal { .. }, + ) | + RuntimeCall::Council( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::TechnicalCommittee( + pallet_collective::Call::vote { .. } | + pallet_collective::Call::close_old_weight { .. } | + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::PhragmenElection( + pallet_elections_phragmen::Call::remove_voter { .. } | + pallet_elections_phragmen::Call::submit_candidacy { .. } | + pallet_elections_phragmen::Call::renounce_candidacy { .. } | + pallet_elections_phragmen::Call::remove_member { .. } | + pallet_elections_phragmen::Call::clean_defunct_voters { .. }, + ) | + RuntimeCall::TechnicalMembership( + pallet_membership::Call::add_member { .. } | + pallet_membership::Call::remove_member { .. } | + pallet_membership::Call::swap_member { .. } | + pallet_membership::Call::change_key { .. } | + pallet_membership::Call::set_prime { .. } | + pallet_membership::Call::clear_prime { .. }, + ) | + RuntimeCall::Treasury(..) | + RuntimeCall::Claims( + super::claims::Call::claim { .. } | + super::claims::Call::mint_claim { .. } | + super::claims::Call::move_claim { .. }, + ) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Society( + pallet_society::Call::bid { .. } | + pallet_society::Call::unbid { .. } | + pallet_society::Call::vouch { .. } | + pallet_society::Call::unvouch { .. } | + pallet_society::Call::vote { .. } | + pallet_society::Call::defender_vote { .. } | + pallet_society::Call::payout { .. } | + pallet_society::Call::unfound { .. } | + pallet_society::Call::judge_suspended_member { .. } | + pallet_society::Call::judge_suspended_candidate { .. } | + pallet_society::Call::set_max_members { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::Bounties( + pallet_bounties::Call::propose_bounty { .. } | + pallet_bounties::Call::approve_bounty { .. } | + pallet_bounties::Call::propose_curator { .. } | + pallet_bounties::Call::unassign_curator { .. } | + pallet_bounties::Call::accept_curator { .. } | + pallet_bounties::Call::award_bounty { .. } | + pallet_bounties::Call::claim_bounty { .. } | + pallet_bounties::Call::close_bounty { .. }, + ) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { + .. + }) => true, + _ => false, + } + } } pub struct XcmConfig; diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 069dfeb5fca1..1dbd6d483c32 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -21,8 +21,8 @@ use super::{ RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, }; use frame_support::{ - match_types, parameter_types, - traits::{Everything, Nothing}, + parameter_types, + traits::{Contains, Everything, Nothing}, }; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; @@ -106,87 +106,100 @@ pub type Barrier = ( AllowSubscriptionsFrom, ); -match_types! { - // A call filter for the XCM Transact instruction. This is a temporary measure until we - // properly account for proof size weights. - // - // Calls that are allowed through this filter must: - // 1. Have a fixed weight; - // 2. Cannot lead to another call being made; - // 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. - pub type SafeCallFilter: impl Contains = { - RuntimeCall::System( - frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, - ) | - RuntimeCall::Babe(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Indices(..) | - RuntimeCall::Balances(..) | - RuntimeCall::Staking( - pallet_staking::Call::bond { .. } | - pallet_staking::Call::bond_extra { .. } | - pallet_staking::Call::unbond { .. } | - pallet_staking::Call::withdraw_unbonded { .. } | - pallet_staking::Call::validate { .. } | - pallet_staking::Call::nominate { .. } | - pallet_staking::Call::chill { .. } | - pallet_staking::Call::set_payee { .. } | - pallet_staking::Call::set_controller { .. } | - pallet_staking::Call::set_validator_count { .. } | - pallet_staking::Call::increase_validator_count { .. } | - pallet_staking::Call::scale_validator_count { .. } | - pallet_staking::Call::force_no_eras { .. } | - pallet_staking::Call::force_new_era { .. } | - pallet_staking::Call::set_invulnerables { .. } | - pallet_staking::Call::force_unstake { .. } | - pallet_staking::Call::force_new_era_always { .. } | - pallet_staking::Call::payout_stakers { .. } | - pallet_staking::Call::rebond { .. } | - pallet_staking::Call::reap_stash { .. } | - pallet_staking::Call::set_staking_configs { .. } | - pallet_staking::Call::chill_other { .. } | - pallet_staking::Call::force_apply_min_commission { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::Grandpa(..) | - RuntimeCall::ImOnline(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Identity( - pallet_identity::Call::add_registrar { .. } | - pallet_identity::Call::set_identity { .. } | - pallet_identity::Call::clear_identity { .. } | - pallet_identity::Call::request_judgement { .. } | - pallet_identity::Call::cancel_request { .. } | - pallet_identity::Call::set_fee { .. } | - pallet_identity::Call::set_account_id { .. } | - pallet_identity::Call::set_fields { .. } | - pallet_identity::Call::provide_judgement { .. } | - pallet_identity::Call::kill_identity { .. } | - pallet_identity::Call::add_sub { .. } | - pallet_identity::Call::rename_sub { .. } | - pallet_identity::Call::remove_sub { .. } | - pallet_identity::Call::quit_sub { .. }, - ) | - RuntimeCall::Recovery(..) | - RuntimeCall::Vesting(..) | - RuntimeCall::ElectionProviderMultiPhase(..) | - RuntimeCall::VoterList(..) | - RuntimeCall::NominationPools( - pallet_nomination_pools::Call::join { .. } | - pallet_nomination_pools::Call::bond_extra { .. } | - pallet_nomination_pools::Call::claim_payout { .. } | - pallet_nomination_pools::Call::unbond { .. } | - pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | - pallet_nomination_pools::Call::withdraw_unbonded { .. } | - pallet_nomination_pools::Call::create { .. } | - pallet_nomination_pools::Call::create_with_pool_id { .. } | - pallet_nomination_pools::Call::set_state { .. } | - pallet_nomination_pools::Call::set_configs { .. } | - pallet_nomination_pools::Call::update_roles { .. } | - pallet_nomination_pools::Call::chill { .. }, - ) | - RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { .. }) - }; +/// A call filter for the XCM Transact instruction. This is a temporary measure until we +/// properly account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(call: &RuntimeCall) -> bool { + #[cfg(feature = "runtime-benchmarks")] + { + if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) { + return true + } + } + + match call { + RuntimeCall::System( + frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, + ) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(..) | + RuntimeCall::Balances(..) | + RuntimeCall::Staking( + pallet_staking::Call::bond { .. } | + pallet_staking::Call::bond_extra { .. } | + pallet_staking::Call::unbond { .. } | + pallet_staking::Call::withdraw_unbonded { .. } | + pallet_staking::Call::validate { .. } | + pallet_staking::Call::nominate { .. } | + pallet_staking::Call::chill { .. } | + pallet_staking::Call::set_payee { .. } | + pallet_staking::Call::set_controller { .. } | + pallet_staking::Call::set_validator_count { .. } | + pallet_staking::Call::increase_validator_count { .. } | + pallet_staking::Call::scale_validator_count { .. } | + pallet_staking::Call::force_no_eras { .. } | + pallet_staking::Call::force_new_era { .. } | + pallet_staking::Call::set_invulnerables { .. } | + pallet_staking::Call::force_unstake { .. } | + pallet_staking::Call::force_new_era_always { .. } | + pallet_staking::Call::payout_stakers { .. } | + pallet_staking::Call::rebond { .. } | + pallet_staking::Call::reap_stash { .. } | + pallet_staking::Call::set_staking_configs { .. } | + pallet_staking::Call::chill_other { .. } | + pallet_staking::Call::force_apply_min_commission { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Identity( + pallet_identity::Call::add_registrar { .. } | + pallet_identity::Call::set_identity { .. } | + pallet_identity::Call::clear_identity { .. } | + pallet_identity::Call::request_judgement { .. } | + pallet_identity::Call::cancel_request { .. } | + pallet_identity::Call::set_fee { .. } | + pallet_identity::Call::set_account_id { .. } | + pallet_identity::Call::set_fields { .. } | + pallet_identity::Call::provide_judgement { .. } | + pallet_identity::Call::kill_identity { .. } | + pallet_identity::Call::add_sub { .. } | + pallet_identity::Call::rename_sub { .. } | + pallet_identity::Call::remove_sub { .. } | + pallet_identity::Call::quit_sub { .. }, + ) | + RuntimeCall::Recovery(..) | + RuntimeCall::Vesting(..) | + RuntimeCall::ElectionProviderMultiPhase(..) | + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools( + pallet_nomination_pools::Call::join { .. } | + pallet_nomination_pools::Call::bond_extra { .. } | + pallet_nomination_pools::Call::claim_payout { .. } | + pallet_nomination_pools::Call::unbond { .. } | + pallet_nomination_pools::Call::pool_withdraw_unbonded { .. } | + pallet_nomination_pools::Call::withdraw_unbonded { .. } | + pallet_nomination_pools::Call::create { .. } | + pallet_nomination_pools::Call::create_with_pool_id { .. } | + pallet_nomination_pools::Call::set_state { .. } | + pallet_nomination_pools::Call::set_configs { .. } | + pallet_nomination_pools::Call::update_roles { .. } | + pallet_nomination_pools::Call::chill { .. }, + ) | + RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets { + .. + }) => true, + _ => false, + } + } } pub struct XcmConfig; From 840414726ffee9b6e32569de78f66d332556cb59 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 10 Dec 2022 03:57:12 +0900 Subject: [PATCH 186/231] Use remark_with_event for Transact benchmarks --- runtime/kusama/src/lib.rs | 2 +- runtime/rococo/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 00511bdb90d1..e77aa6eb14ac 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2039,7 +2039,7 @@ sp_api::impl_runtime_apis! { } fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { - Ok((Statemine::get(), pallet_session::Call::purge_keys {}.into())) + Ok((Statemine::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index c1ad0733d9b1..a971ae0848c3 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -2019,7 +2019,7 @@ sp_api::impl_runtime_apis! { } fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { - Ok((Statemine::get(), pallet_session::Call::purge_keys {}.into())) + Ok((Statemine::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 6cc984db5cfe..786b59647f1e 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1759,7 +1759,7 @@ sp_api::impl_runtime_apis! { } fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { - Ok((Westmint::get(), pallet_session::Call::purge_keys {}.into())) + Ok((Westmint::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { From aa028586e3640249033d773a81dc0b4a13781065 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 13 Dec 2022 16:43:42 +0900 Subject: [PATCH 187/231] Fix Cargo.lock --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97ad247643a6..29246de42a00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3168,7 +3168,7 @@ dependencies = [ "soketto", "tokio", "tokio-stream", - "tokio-util 0.7.1", + "tokio-util", "tower", "tracing", ] @@ -11401,7 +11401,7 @@ dependencies = [ "http", "http-body", "http-range-header", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "tower-layer", "tower-service", ] From 30b2df317dc9cf79df428a287ae4fddb1bb78306 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 13 Dec 2022 16:44:10 +0900 Subject: [PATCH 188/231] Allow up to 3 DescendOrigin instructions before UnpaidExecution --- xcm/xcm-builder/src/barriers.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 96f012cc55e4..2522f104f21f 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -74,7 +74,7 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionFro ); ensure!(T::contains(origin), ()); - // We will read up to 5 instructions. This allows up to 3 `ClearOrigin`s instructions. We + // We will read up to 5 instructions. This allows up to 3 `ClearOrigin` instructions. We // allow for more than one since anything beyond the first is a no-op and it's conceivable // that composition of operations might result in more than one being appended. let mut iter = instructions.iter_mut().take(5); @@ -241,10 +241,18 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF origin, instructions, max_weight, _weight_credit, ); ensure!(T::contains(origin), ()); - match instructions.first() { - Some(UnpaidExecution { weight_limit: Limited(m), .. }) if m.all_gte(max_weight) => + // We will read up to 4 instructions. This allows up to 3 `DescendOrigin` instructions. We + // allow for more than one since anything beyond the first is a no-op and it's conceivable + // that composition of operations might result in more than one being appended. + let mut iter = instructions.iter_mut().take(4); + let mut i = iter.next().ok_or(())?; + while let DescendOrigin(..) = i { + i = iter.next().ok_or(())?; + } + match i { + UnpaidExecution { weight_limit: Limited(m), .. } if m.all_gte(max_weight) => Ok(()), - Some(UnpaidExecution { weight_limit: Unlimited, .. }) => Ok(()), + UnpaidExecution { weight_limit: Unlimited, .. } => Ok(()), _ => Err(()), } } From ceb0cd1b4b21f8131efd179c5d772a5b0cde20cb Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 13 Dec 2022 16:44:59 +0900 Subject: [PATCH 189/231] cargo fmt --- xcm/xcm-builder/src/barriers.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 2522f104f21f..5b8864d5d5f8 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -250,8 +250,7 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF i = iter.next().ok_or(())?; } match i { - UnpaidExecution { weight_limit: Limited(m), .. } if m.all_gte(max_weight) => - Ok(()), + UnpaidExecution { weight_limit: Limited(m), .. } if m.all_gte(max_weight) => Ok(()), UnpaidExecution { weight_limit: Unlimited, .. } => Ok(()), _ => Err(()), } From 77713e5b8f8671375455764e91feb93f625773a7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 13 Dec 2022 16:46:16 +0900 Subject: [PATCH 190/231] Edit code comment --- xcm/xcm-builder/src/barriers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 5b8864d5d5f8..d8f007127e21 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -242,8 +242,8 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF ); ensure!(T::contains(origin), ()); // We will read up to 4 instructions. This allows up to 3 `DescendOrigin` instructions. We - // allow for more than one since anything beyond the first is a no-op and it's conceivable - // that composition of operations might result in more than one being appended. + // allow for more than one since it's conceivable that composition of operations might + // result in more than one being appended. let mut iter = instructions.iter_mut().take(4); let mut i = iter.next().ok_or(())?; while let DescendOrigin(..) = i { From a08303e021fb5993a4e245464aab4d622be2e929 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 13 Dec 2022 21:09:31 +0900 Subject: [PATCH 191/231] Check check_origin for unpaid execution privilege --- xcm/xcm-builder/src/barriers.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index d8f007127e21..3dd1d833943f 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -240,7 +240,6 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF "AllowUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", origin, instructions, max_weight, _weight_credit, ); - ensure!(T::contains(origin), ()); // We will read up to 4 instructions. This allows up to 3 `DescendOrigin` instructions. We // allow for more than one since it's conceivable that composition of operations might // result in more than one being appended. @@ -250,7 +249,9 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF i = iter.next().ok_or(())?; } match i { - UnpaidExecution { weight_limit: Limited(m), .. } if m.all_gte(max_weight) => Ok(()), + UnpaidExecution { weight_limit: Limited(m), check_origin } + if m.all_gte(max_weight) && check_origin.map_or(true, |o| T::contains(&o)) => + Ok(()), UnpaidExecution { weight_limit: Unlimited, .. } => Ok(()), _ => Err(()), } From 3e9cc17afea3bf077069d5114d850a0fc3dbbb32 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 13 Dec 2022 21:12:30 +0900 Subject: [PATCH 192/231] Fixes --- xcm/xcm-builder/src/barriers.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 3dd1d833943f..5e58e9cd22f1 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -252,7 +252,9 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF UnpaidExecution { weight_limit: Limited(m), check_origin } if m.all_gte(max_weight) && check_origin.map_or(true, |o| T::contains(&o)) => Ok(()), - UnpaidExecution { weight_limit: Unlimited, .. } => Ok(()), + UnpaidExecution { weight_limit: Unlimited, check_origin } + if check_origin.map_or(true, |o| T::contains(&o)) => + Ok(()), _ => Err(()), } } From 4b9a8e8d149bd59df9d27f46bbeea9e21193a745 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 13 Dec 2022 16:38:42 +0100 Subject: [PATCH 193/231] Small nits for xcm-v3 (#6408) * Add possibility to skip benchmark for export_message * ".git/.scripts/bench-bot.sh" xcm westend-dev pallet_xcm_benchmarks::generic * Revert * ".git/.scripts/bench-bot.sh" xcm westend-dev pallet_xcm_benchmarks::generic * Add HaulBlobError to `fn haul_blob` * ".git/.scripts/bench-bot.sh" xcm westend-dev pallet_xcm_benchmarks::generic Co-authored-by: command-bot <> --- .../xcm/pallet_xcm_benchmarks_generic.rs | 79 ++++++++++--------- xcm/pallet-xcm-benchmarks/src/generic/mod.rs | 8 +- xcm/xcm-builder/src/tests/bridging/mod.rs | 3 +- xcm/xcm-builder/src/universal_exports.rs | 18 ++++- 4 files changed, 62 insertions(+), 46 deletions(-) diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 2a811ac3d2f0..aed7316cdd28 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,24 +17,25 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-04-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-12-12, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: -// target/production/polkadot +// /home/benchbot/cargo_target_dir/production/polkadot // benchmark // pallet -// --chain=westend-dev // --steps=50 // --repeat=20 -// --pallet=pallet_xcm_benchmarks::generic // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=pallet_xcm_benchmarks::generic +// --chain=westend-dev // --header=./file_header.txt // --template=./xcm/pallet-xcm-benchmarks/template.hbs -// --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +// --output=./runtime/westend/src/weights/xcm/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,135 +50,135 @@ impl WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) pub(crate) fn report_holding() -> Weight { - Weight::from_ref_time(24_686_000 as u64) + Weight::from_ref_time(34_089_000 as u64) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn buy_execution() -> Weight { - Weight::from_ref_time(3_620_000 as u64) + Weight::from_ref_time(5_751_000 as u64) } // Storage: XcmPallet Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - Weight::from_ref_time(12_946_000 as u64) + Weight::from_ref_time(17_938_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) } pub(crate) fn transact() -> Weight { - Weight::from_ref_time(13_206_000 as u64) + Weight::from_ref_time(20_699_000 as u64) } pub(crate) fn refund_surplus() -> Weight { - Weight::from_ref_time(3_879_000 as u64) + Weight::from_ref_time(6_077_000 as u64) } pub(crate) fn set_error_handler() -> Weight { - Weight::from_ref_time(3_659_000 as u64) + Weight::from_ref_time(5_747_000 as u64) } pub(crate) fn set_appendix() -> Weight { - Weight::from_ref_time(3_743_000 as u64) + Weight::from_ref_time(5_837_000 as u64) } pub(crate) fn clear_error() -> Weight { - Weight::from_ref_time(3_711_000 as u64) + Weight::from_ref_time(5_712_000 as u64) } pub(crate) fn descend_origin() -> Weight { - Weight::from_ref_time(4_618_000 as u64) + Weight::from_ref_time(6_471_000 as u64) } pub(crate) fn clear_origin() -> Weight { - Weight::from_ref_time(3_588_000 as u64) + Weight::from_ref_time(5_725_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) pub(crate) fn report_error() -> Weight { - Weight::from_ref_time(20_331_000 as u64) + Weight::from_ref_time(29_975_000 as u64) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: XcmPallet AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - Weight::from_ref_time(7_650_000 as u64) + Weight::from_ref_time(21_598_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } pub(crate) fn trap() -> Weight { - Weight::from_ref_time(3_617_000 as u64) + Weight::from_ref_time(5_665_000 as u64) } // Storage: XcmPallet VersionNotifyTargets (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - Weight::from_ref_time(28_613_000 as u64) + Weight::from_ref_time(38_343_000 as u64) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: XcmPallet VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - Weight::from_ref_time(5_443_000 as u64) + Weight::from_ref_time(8_353_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - Weight::from_ref_time(24_401_000 as u64) + Weight::from_ref_time(33_100_000 as u64) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn burn_asset() -> Weight { - Weight::from_ref_time(5_259_000 as u64) + Weight::from_ref_time(7_259_000 as u64) } pub(crate) fn expect_asset() -> Weight { - Weight::from_ref_time(3_745_000 as u64) + Weight::from_ref_time(5_848_000 as u64) } pub(crate) fn expect_origin() -> Weight { - Weight::from_ref_time(3_847_000 as u64) + Weight::from_ref_time(5_787_000 as u64) } pub(crate) fn expect_error() -> Weight { - Weight::from_ref_time(3_633_000 as u64) + Weight::from_ref_time(5_775_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) pub(crate) fn query_pallet() -> Weight { - Weight::from_ref_time(21_645_000 as u64) + Weight::from_ref_time(34_846_000 as u64) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn expect_pallet() -> Weight { - Weight::from_ref_time(4_017_000 as u64) + Weight::from_ref_time(8_844_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) pub(crate) fn report_transact_status() -> Weight { - Weight::from_ref_time(20_465_000 as u64) + Weight::from_ref_time(50_256_000 as u64) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn clear_transact_status() -> Weight { - Weight::from_ref_time(3_723_000 as u64) + Weight::from_ref_time(9_959_000 as u64) } pub(crate) fn set_topic() -> Weight { - Weight::from_ref_time(3_687_000 as u64) + Weight::from_ref_time(10_007_000 as u64) } pub(crate) fn clear_topic() -> Weight { - Weight::from_ref_time(3_654_000 as u64) + Weight::from_ref_time(8_289_000 as u64) } pub(crate) fn set_fees_mode() -> Weight { - Weight::from_ref_time(3_721_000 as u64) + Weight::from_ref_time(5_764_000 as u64) } pub(crate) fn unpaid_execution() -> Weight { - Weight::from_ref_time(3_111_000 as u64) + Weight::from_ref_time(5_924_000 as u64) } } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index 1f1dbf51a92f..d60081c19182 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -30,24 +30,24 @@ pub mod pallet { /// The first element in the returned tuple represents the assets that are being exchanged /// from, whereas the second element represents the assets that are being exchanged to. /// - /// If set to `None`, benchmarks which rely on an `exchange_asset` will be skipped. + /// If set to `Err`, benchmarks which rely on an `exchange_asset` will be skipped. fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError>; /// A `Junction` that is one of the `UniversalAliases` configured by the XCM executor. /// - /// If set to `None`, benchmarks which rely on a universal alias will be skipped. + /// If set to `Err`, benchmarks which rely on a universal alias will be skipped. fn universal_alias() -> Result; /// The `MultiLocation` and `RuntimeCall` used for successful transaction XCMs. /// - /// If set to `None`, benchmarks which rely on a `transact_origin_and_runtime_call` will be + /// If set to `Err`, benchmarks which rely on a `transact_origin_and_runtime_call` will be /// skipped. fn transact_origin_and_runtime_call( ) -> Result<(MultiLocation, >::RuntimeCall), BenchmarkError>; /// A valid `MultiLocation` we can successfully subscribe to. /// - /// If set to `None`, benchmarks which rely on a `subscribe_origin` will be skipped. + /// If set to `Err`, benchmarks which rely on a `subscribe_origin` will be skipped. fn subscribe_origin() -> Result; /// Return an origin, ticket, and assets that can be trapped and claimed. diff --git a/xcm/xcm-builder/src/tests/bridging/mod.rs b/xcm/xcm-builder/src/tests/bridging/mod.rs index 77014c76d9e3..0ca3733c108b 100644 --- a/xcm/xcm-builder/src/tests/bridging/mod.rs +++ b/xcm/xcm-builder/src/tests/bridging/mod.rs @@ -51,8 +51,9 @@ impl TestBridge { } } impl HaulBlob for TestBridge { - fn haul_blob(blob: Vec) { + fn haul_blob(blob: Vec) -> Result<(), HaulBlobError> { BRIDGE_TRAFFIC.with(|t| t.borrow_mut().push(blob)); + Ok(()) } } diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index 41c65ad1de64..e9600a317fd2 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -239,7 +239,21 @@ pub trait DispatchBlob { pub trait HaulBlob { /// Sends a blob over some point-to-point link. This will generally be implemented by a bridge. - fn haul_blob(blob: Vec); + fn haul_blob(blob: Vec) -> Result<(), HaulBlobError>; +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum HaulBlobError { + /// Represents point-to-point link failure with a human-readable explanation of the specific issue is provided. + Transport(&'static str), +} + +impl From for SendError { + fn from(err: HaulBlobError) -> Self { + match err { + HaulBlobError::Transport(reason) => SendError::Transport(reason), + } + } } #[derive(Clone, Encode, Decode)] @@ -334,7 +348,7 @@ impl, Price: Get> } fn deliver((blob, hash): (Vec, XcmHash)) -> Result { - Bridge::haul_blob(blob); + Bridge::haul_blob(blob)?; Ok(hash) } } From e13d9266c34bf9bc38184d10138adaa7ec4a6c93 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 14 Dec 2022 19:31:40 +0900 Subject: [PATCH 194/231] Revert changes to UnpaidExecution --- xcm/xcm-builder/src/barriers.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 5e58e9cd22f1..9f927deefdbf 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -240,21 +240,11 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF "AllowUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", origin, instructions, max_weight, _weight_credit, ); - // We will read up to 4 instructions. This allows up to 3 `DescendOrigin` instructions. We - // allow for more than one since it's conceivable that composition of operations might - // result in more than one being appended. - let mut iter = instructions.iter_mut().take(4); - let mut i = iter.next().ok_or(())?; - while let DescendOrigin(..) = i { - i = iter.next().ok_or(())?; - } - match i { - UnpaidExecution { weight_limit: Limited(m), check_origin } - if m.all_gte(max_weight) && check_origin.map_or(true, |o| T::contains(&o)) => - Ok(()), - UnpaidExecution { weight_limit: Unlimited, check_origin } - if check_origin.map_or(true, |o| T::contains(&o)) => + ensure!(T::contains(origin), ()); + match instructions.first() { + Some(UnpaidExecution { weight_limit: Limited(m), .. }) if m.all_gte(max_weight) => Ok(()), + Some(UnpaidExecution { weight_limit: Unlimited, .. }) => Ok(()), _ => Err(()), } } From 9f72f2cf08d2a96ae83c12399cbc41cd6bf41057 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 15 Dec 2022 21:43:34 +0900 Subject: [PATCH 195/231] Change AllowUnpaidExecutionFrom to be explicit --- runtime/kusama/src/xcm_config.rs | 4 ++-- runtime/rococo/src/xcm_config.rs | 4 ++-- runtime/westend/src/xcm_config.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index c2da5c9a7528..d769ac8bb434 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -29,7 +29,7 @@ use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, + AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, @@ -131,7 +131,7 @@ pub type Barrier = ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, // Messages coming from system parachains need not pay for execution. - AllowUnpaidExecutionFrom>, + AllowExplicitUnpaidExecutionFrom>, // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index f3fe46fb6648..53d9a20b882f 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -29,7 +29,7 @@ use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, + AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, @@ -127,7 +127,7 @@ pub type Barrier = ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, // Messages coming from system parachains need not pay for execution. - AllowUnpaidExecutionFrom>, + AllowExplicitUnpaidExecutionFrom>, // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 1dbd6d483c32..ac49ee55ae42 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -28,7 +28,7 @@ use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative, + AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, @@ -99,7 +99,7 @@ pub type Barrier = ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, // Messages coming from system parachains need not pay for execution. - AllowUnpaidExecutionFrom>, + AllowExplicitUnpaidExecutionFrom>, // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. From ac9af6e04fb0103d91d495ac7b4f338900cfcb32 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 15 Dec 2022 23:45:38 +0900 Subject: [PATCH 196/231] Fix log text --- xcm/xcm-builder/src/barriers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 9f927deefdbf..1e1389489e99 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -237,7 +237,7 @@ impl> ShouldExecute for AllowExplicitUnpaidExecutionF ) -> Result<(), ()> { log::trace!( target: "xcm::barriers", - "AllowUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + "AllowExplicitUnpaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", origin, instructions, max_weight, _weight_credit, ); ensure!(T::contains(origin), ()); From 88d21b14217eb15782c200aa26884f2db8faf6f4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 16 Dec 2022 16:37:52 +0900 Subject: [PATCH 197/231] cargo fmt --- runtime/kusama/src/xcm_config.rs | 4 ++-- runtime/rococo/src/xcm_config.rs | 4 ++-- runtime/westend/src/xcm_config.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index d769ac8bb434..49b182ec22a9 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -28,8 +28,8 @@ use frame_support::{ use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ - AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom, BackingToPlurality, + AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 53d9a20b882f..6d3f1a540eb1 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -28,8 +28,8 @@ use frame_support::{ use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ - AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom, BackingToPlurality, + AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index ac49ee55ae42..b2eaaa4e2057 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -27,8 +27,8 @@ use frame_support::{ use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; use xcm_builder::{ - AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom, ChildParachainAsNative, + AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, From aea49b3d3d31e883a623d56cd199055250bf2af5 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sun, 18 Dec 2022 03:10:57 +0900 Subject: [PATCH 198/231] Add benchmarks for XCM pallet version migration (#6448) * Add benchmarks for XCM pallet version migration * cargo fmt * Fixes * Fixes * Fixes * ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime rococo-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm * Fix benchmarks * Fix benchmarks * ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime rococo-dev pallet_xcm * ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_xcm Co-authored-by: command-bot <> --- runtime/kusama/src/weights/pallet_xcm.rs | 113 +++++++++++++++----- runtime/polkadot/src/weights/pallet_xcm.rs | 95 +++++++++++++---- runtime/rococo/src/weights/pallet_xcm.rs | 115 ++++++++++++++++----- runtime/westend/src/weights/pallet_xcm.rs | 93 +++++++++++++---- xcm/pallet-xcm/src/benchmarking.rs | 76 +++++++++++++- xcm/pallet-xcm/src/lib.rs | 64 +++++++++--- 6 files changed, 448 insertions(+), 108 deletions(-) diff --git a/runtime/kusama/src/weights/pallet_xcm.rs b/runtime/kusama/src/weights/pallet_xcm.rs index a14b50ec9212..fc7d75768aff 100644 --- a/runtime/kusama/src/weights/pallet_xcm.rs +++ b/runtime/kusama/src/weights/pallet_xcm.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-12-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -49,63 +49,120 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) fn send() -> Weight { - // Minimum execution time: 32_807 nanoseconds. - Weight::from_ref_time(33_383_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Minimum execution time: 36_474 nanoseconds. + Weight::from_ref_time(37_030_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } fn teleport_assets() -> Weight { - // Minimum execution time: 28_036 nanoseconds. - Weight::from_ref_time(28_386_000 as u64) + // Minimum execution time: 28_147 nanoseconds. + Weight::from_ref_time(28_836_000) } fn reserve_transfer_assets() -> Weight { - // Minimum execution time: 26_239 nanoseconds. - Weight::from_ref_time(27_146_000 as u64) + // Minimum execution time: 28_469 nanoseconds. + Weight::from_ref_time(29_002_000) } fn execute() -> Weight { - // Minimum execution time: 14_327 nanoseconds. - Weight::from_ref_time(14_693_000 as u64) + // Minimum execution time: 15_637 nanoseconds. + Weight::from_ref_time(15_880_000) } // Storage: XcmPallet SupportedVersion (r:0 w:1) fn force_xcm_version() -> Weight { - // Minimum execution time: 13_854 nanoseconds. - Weight::from_ref_time(14_658_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 15_330 nanoseconds. + Weight::from_ref_time(15_817_000) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet SafeXcmVersion (r:0 w:1) fn force_default_xcm_version() -> Weight { - // Minimum execution time: 3_786 nanoseconds. - Weight::from_ref_time(3_986_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 4_104 nanoseconds. + Weight::from_ref_time(4_365_000) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) // Storage: XcmPallet QueryCounter (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_subscribe_version_notify() -> Weight { - // Minimum execution time: 37_959 nanoseconds. - Weight::from_ref_time(38_689_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + // Minimum execution time: 42_177 nanoseconds. + Weight::from_ref_time(42_657_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_unsubscribe_version_notify() -> Weight { - // Minimum execution time: 41_213 nanoseconds. - Weight::from_ref_time(41_668_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Minimum execution time: 45_481 nanoseconds. + Weight::from_ref_time(45_960_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: XcmPallet SupportedVersion (r:4 w:2) + fn migrate_supported_version() -> Weight { + // Minimum execution time: 14_899 nanoseconds. + Weight::from_ref_time(15_452_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifiers (r:4 w:2) + fn migrate_version_notifiers() -> Weight { + // Minimum execution time: 14_759 nanoseconds. + Weight::from_ref_time(15_176_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifyTargets (r:5 w:0) + fn already_notified_target() -> Weight { + // Minimum execution time: 17_022 nanoseconds. + Weight::from_ref_time(17_468_000) + .saturating_add(T::DbWeight::get().reads(5)) + } + // Storage: XcmPallet VersionNotifyTargets (r:2 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + fn notify_current_targets() -> Weight { + // Minimum execution time: 37_810 nanoseconds. + Weight::from_ref_time(38_198_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: XcmPallet VersionNotifyTargets (r:3 w:0) + fn notify_target_migration_fail() -> Weight { + // Minimum execution time: 7_440 nanoseconds. + Weight::from_ref_time(7_659_000) + .saturating_add(T::DbWeight::get().reads(3)) + } + // Storage: XcmPallet VersionNotifyTargets (r:4 w:2) + fn migrate_version_notify_targets() -> Weight { + // Minimum execution time: 14_975 nanoseconds. + Weight::from_ref_time(15_479_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifyTargets (r:4 w:2) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + fn migrate_and_notify_old_targets() -> Weight { + // Minimum execution time: 43_328 nanoseconds. + Weight::from_ref_time(44_054_000) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(5)) } } diff --git a/runtime/polkadot/src/weights/pallet_xcm.rs b/runtime/polkadot/src/weights/pallet_xcm.rs index 5f47a21a67f5..cc1cca28068d 100644 --- a/runtime/polkadot/src/weights/pallet_xcm.rs +++ b/runtime/polkadot/src/weights/pallet_xcm.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-06, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-12-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 @@ -50,21 +50,21 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) fn send() -> Weight { - // Minimum execution time: 33_342 nanoseconds. - Weight::from_ref_time(34_378_000) + // Minimum execution time: 35_717 nanoseconds. + Weight::from_ref_time(36_278_000) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } fn teleport_assets() -> Weight { - // Minimum execution time: 29_082 nanoseconds. - Weight::from_ref_time(29_445_000) + // Minimum execution time: 28_865 nanoseconds. + Weight::from_ref_time(29_336_000) } fn reserve_transfer_assets() -> Weight { - // Minimum execution time: 27_698 nanoseconds. - Weight::from_ref_time(28_811_000) + // Minimum execution time: 27_531 nanoseconds. + Weight::from_ref_time(28_248_000) } // Storage: Benchmark Override (r:0 w:0) fn execute() -> Weight { @@ -73,14 +73,14 @@ impl pallet_xcm::WeightInfo for WeightInfo { } // Storage: XcmPallet SupportedVersion (r:0 w:1) fn force_xcm_version() -> Weight { - // Minimum execution time: 14_670 nanoseconds. - Weight::from_ref_time(15_073_000) + // Minimum execution time: 15_205 nanoseconds. + Weight::from_ref_time(15_526_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet SafeXcmVersion (r:0 w:1) fn force_default_xcm_version() -> Weight { - // Minimum execution time: 4_072 nanoseconds. - Weight::from_ref_time(4_258_000) + // Minimum execution time: 4_336 nanoseconds. + Weight::from_ref_time(4_518_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) @@ -89,12 +89,12 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_subscribe_version_notify() -> Weight { - // Minimum execution time: 38_016 nanoseconds. - Weight::from_ref_time(39_062_000) + // Minimum execution time: 41_446 nanoseconds. + Weight::from_ref_time(42_152_000) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -103,13 +103,72 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_unsubscribe_version_notify() -> Weight { - // Minimum execution time: 44_887 nanoseconds. - Weight::from_ref_time(45_471_000) + // Minimum execution time: 44_944 nanoseconds. + Weight::from_ref_time(45_519_000) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } + // Storage: XcmPallet SupportedVersion (r:4 w:2) + fn migrate_supported_version() -> Weight { + // Minimum execution time: 15_254 nanoseconds. + Weight::from_ref_time(15_491_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifiers (r:4 w:2) + fn migrate_version_notifiers() -> Weight { + // Minimum execution time: 15_083 nanoseconds. + Weight::from_ref_time(15_298_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifyTargets (r:5 w:0) + fn already_notified_target() -> Weight { + // Minimum execution time: 17_889 nanoseconds. + Weight::from_ref_time(18_144_000) + .saturating_add(T::DbWeight::get().reads(5)) + } + // Storage: XcmPallet VersionNotifyTargets (r:2 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + fn notify_current_targets() -> Weight { + // Minimum execution time: 37_255 nanoseconds. + Weight::from_ref_time(37_893_000) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: XcmPallet VersionNotifyTargets (r:3 w:0) + fn notify_target_migration_fail() -> Weight { + // Minimum execution time: 7_884 nanoseconds. + Weight::from_ref_time(8_111_000) + .saturating_add(T::DbWeight::get().reads(3)) + } + // Storage: XcmPallet VersionNotifyTargets (r:4 w:2) + fn migrate_version_notify_targets() -> Weight { + // Minimum execution time: 15_853 nanoseconds. + Weight::from_ref_time(16_220_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifyTargets (r:4 w:2) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + fn migrate_and_notify_old_targets() -> Weight { + // Minimum execution time: 43_836 nanoseconds. + Weight::from_ref_time(44_836_000) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(5)) + } } diff --git a/runtime/rococo/src/weights/pallet_xcm.rs b/runtime/rococo/src/weights/pallet_xcm.rs index e6759a46becc..7534c87cb6de 100644 --- a/runtime/rococo/src/weights/pallet_xcm.rs +++ b/runtime/rococo/src/weights/pallet_xcm.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-12-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 @@ -50,37 +50,37 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) fn send() -> Weight { - // Minimum execution time: 33_793 nanoseconds. - Weight::from_ref_time(34_487_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Minimum execution time: 36_707 nanoseconds. + Weight::from_ref_time(37_718_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) } fn teleport_assets() -> Weight { - // Minimum execution time: 27_892 nanoseconds. - Weight::from_ref_time(28_743_000 as u64) + // Minimum execution time: 28_720 nanoseconds. + Weight::from_ref_time(29_098_000) } fn reserve_transfer_assets() -> Weight { - // Minimum execution time: 27_514 nanoseconds. - Weight::from_ref_time(28_068_000 as u64) + // Minimum execution time: 27_702 nanoseconds. + Weight::from_ref_time(28_517_000) } fn execute() -> Weight { - // Minimum execution time: 14_485 nanoseconds. - Weight::from_ref_time(14_860_000 as u64) + // Minimum execution time: 14_527 nanoseconds. + Weight::from_ref_time(14_823_000) } // Storage: XcmPallet SupportedVersion (r:0 w:1) fn force_xcm_version() -> Weight { - // Minimum execution time: 14_669 nanoseconds. - Weight::from_ref_time(15_412_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 16_306 nanoseconds. + Weight::from_ref_time(16_619_000) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet SafeXcmVersion (r:0 w:1) fn force_default_xcm_version() -> Weight { - // Minimum execution time: 4_542 nanoseconds. - Weight::from_ref_time(4_710_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 4_911 nanoseconds. + Weight::from_ref_time(5_080_000) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) // Storage: XcmPallet QueryCounter (r:1 w:1) @@ -88,27 +88,86 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_subscribe_version_notify() -> Weight { - // Minimum execution time: 38_404 nanoseconds. - Weight::from_ref_time(39_169_000 as u64) - .saturating_add(T::DbWeight::get().reads(8 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + // Minimum execution time: 48_258 nanoseconds. + Weight::from_ref_time(49_130_000) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_unsubscribe_version_notify() -> Weight { - // Minimum execution time: 41_677 nanoseconds. - Weight::from_ref_time(42_484_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Minimum execution time: 52_381 nanoseconds. + Weight::from_ref_time(53_183_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: XcmPallet SupportedVersion (r:4 w:2) + fn migrate_supported_version() -> Weight { + // Minimum execution time: 16_915 nanoseconds. + Weight::from_ref_time(17_479_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifiers (r:4 w:2) + fn migrate_version_notifiers() -> Weight { + // Minimum execution time: 17_012 nanoseconds. + Weight::from_ref_time(17_319_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifyTargets (r:5 w:0) + fn already_notified_target() -> Weight { + // Minimum execution time: 19_489 nanoseconds. + Weight::from_ref_time(19_995_000) + .saturating_add(T::DbWeight::get().reads(5)) + } + // Storage: XcmPallet VersionNotifyTargets (r:2 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + fn notify_current_targets() -> Weight { + // Minimum execution time: 43_334 nanoseconds. + Weight::from_ref_time(43_983_000) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: XcmPallet VersionNotifyTargets (r:3 w:0) + fn notify_target_migration_fail() -> Weight { + // Minimum execution time: 8_627 nanoseconds. + Weight::from_ref_time(8_860_000) + .saturating_add(T::DbWeight::get().reads(3)) + } + // Storage: XcmPallet VersionNotifyTargets (r:4 w:2) + fn migrate_version_notify_targets() -> Weight { + // Minimum execution time: 17_679 nanoseconds. + Weight::from_ref_time(18_042_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifyTargets (r:4 w:2) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + fn migrate_and_notify_old_targets() -> Weight { + // Minimum execution time: 45_445 nanoseconds. + Weight::from_ref_time(48_369_000) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(5)) } } diff --git a/runtime/westend/src/weights/pallet_xcm.rs b/runtime/westend/src/weights/pallet_xcm.rs index 92e5302a8dba..50478ed21f1b 100644 --- a/runtime/westend/src/weights/pallet_xcm.rs +++ b/runtime/westend/src/weights/pallet_xcm.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-06, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-12-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 @@ -49,21 +49,21 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) fn send() -> Weight { - // Minimum execution time: 34_038 nanoseconds. - Weight::from_ref_time(34_919_000) + // Minimum execution time: 36_453 nanoseconds. + Weight::from_ref_time(37_511_000) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } fn teleport_assets() -> Weight { - // Minimum execution time: 27_962 nanoseconds. - Weight::from_ref_time(28_514_000) + // Minimum execution time: 28_144 nanoseconds. + Weight::from_ref_time(28_952_000) } fn reserve_transfer_assets() -> Weight { - // Minimum execution time: 27_771 nanoseconds. - Weight::from_ref_time(28_642_000) + // Minimum execution time: 28_245 nanoseconds. + Weight::from_ref_time(28_710_000) } // Storage: Benchmark Override (r:0 w:0) fn execute() -> Weight { @@ -72,14 +72,14 @@ impl pallet_xcm::WeightInfo for WeightInfo { } // Storage: XcmPallet SupportedVersion (r:0 w:1) fn force_xcm_version() -> Weight { - // Minimum execution time: 14_821 nanoseconds. - Weight::from_ref_time(15_342_000) + // Minimum execution time: 15_350 nanoseconds. + Weight::from_ref_time(15_829_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet SafeXcmVersion (r:0 w:1) fn force_default_xcm_version() -> Weight { - // Minimum execution time: 4_501 nanoseconds. - Weight::from_ref_time(4_628_000) + // Minimum execution time: 4_482 nanoseconds. + Weight::from_ref_time(4_588_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmPallet VersionNotifiers (r:1 w:1) @@ -87,12 +87,12 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_subscribe_version_notify() -> Weight { - // Minimum execution time: 39_480 nanoseconds. - Weight::from_ref_time(40_278_000) + // Minimum execution time: 41_818 nanoseconds. + Weight::from_ref_time(42_824_000) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -100,13 +100,70 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) // Storage: XcmPallet SafeXcmVersion (r:1 w:0) - // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: XcmPallet Queries (r:0 w:1) fn force_unsubscribe_version_notify() -> Weight { - // Minimum execution time: 42_607 nanoseconds. - Weight::from_ref_time(43_430_000) + // Minimum execution time: 45_488 nanoseconds. + Weight::from_ref_time(46_295_000) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(5)) } + // Storage: XcmPallet SupportedVersion (r:4 w:2) + fn migrate_supported_version() -> Weight { + // Minimum execution time: 14_614 nanoseconds. + Weight::from_ref_time(14_829_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifiers (r:4 w:2) + fn migrate_version_notifiers() -> Weight { + // Minimum execution time: 14_724 nanoseconds. + Weight::from_ref_time(14_915_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifyTargets (r:5 w:0) + fn already_notified_target() -> Weight { + // Minimum execution time: 16_814 nanoseconds. + Weight::from_ref_time(17_007_000) + .saturating_add(T::DbWeight::get().reads(5)) + } + // Storage: XcmPallet VersionNotifyTargets (r:2 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + fn notify_current_targets() -> Weight { + // Minimum execution time: 37_273 nanoseconds. + Weight::from_ref_time(37_869_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: XcmPallet VersionNotifyTargets (r:3 w:0) + fn notify_target_migration_fail() -> Weight { + // Minimum execution time: 7_517 nanoseconds. + Weight::from_ref_time(7_682_000) + .saturating_add(T::DbWeight::get().reads(3)) + } + // Storage: XcmPallet VersionNotifyTargets (r:4 w:2) + fn migrate_version_notify_targets() -> Weight { + // Minimum execution time: 15_088 nanoseconds. + Weight::from_ref_time(15_464_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: XcmPallet VersionNotifyTargets (r:4 w:2) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + fn migrate_and_notify_old_targets() -> Weight { + // Minimum execution time: 42_829 nanoseconds. + Weight::from_ref_time(43_814_000) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(5)) + } } diff --git a/xcm/pallet-xcm/src/benchmarking.rs b/xcm/pallet-xcm/src/benchmarking.rs index f61b4934ddce..fff4b8b2ead4 100644 --- a/xcm/pallet-xcm/src/benchmarking.rs +++ b/xcm/pallet-xcm/src/benchmarking.rs @@ -18,8 +18,9 @@ use super::*; use frame_benchmarking::{benchmarks, BenchmarkError, BenchmarkResult}; use frame_support::weights::Weight; use frame_system::RawOrigin; +use sp_core::{bounded::WeakBoundedVec, ConstU32}; use sp_std::prelude::*; -use xcm::latest::prelude::*; +use xcm::{latest::prelude::*, v2}; type RuntimeOrigin = ::RuntimeOrigin; @@ -110,6 +111,79 @@ benchmarks! { let _ = Pallet::::request_version_notify(loc); }: _(RawOrigin::Root, Box::new(versioned_loc)) + migrate_supported_version { + let old_version = XCM_VERSION - 1; + let loc = VersionedMultiLocation::from(MultiLocation::from(Parent)); + SupportedVersion::::insert(old_version, loc, old_version); + }: { + Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateSupportedVersion, Weight::zero()); + } + + migrate_version_notifiers { + let old_version = XCM_VERSION - 1; + let loc = VersionedMultiLocation::from(MultiLocation::from(Parent)); + VersionNotifiers::::insert(old_version, loc, 0); + }: { + Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateVersionNotifiers, Weight::zero()); + } + + already_notified_target { + let loc = T::ReachableDest::get().ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(T::DbWeight::get().reads(1))), + )?; + let loc = VersionedMultiLocation::from(loc); + let current_version = T::AdvertisedXcmVersion::get(); + VersionNotifyTargets::::insert(current_version, loc, (0, Weight::zero(), current_version)); + }: { + Pallet::::check_xcm_version_change(VersionMigrationStage::NotifyCurrentTargets(None), Weight::zero()); + } + + notify_current_targets { + let loc = T::ReachableDest::get().ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(T::DbWeight::get().reads_writes(1, 3))), + )?; + let loc = VersionedMultiLocation::from(loc); + let current_version = T::AdvertisedXcmVersion::get(); + let old_version = current_version - 1; + VersionNotifyTargets::::insert(current_version, loc, (0, Weight::zero(), old_version)); + }: { + Pallet::::check_xcm_version_change(VersionMigrationStage::NotifyCurrentTargets(None), Weight::zero()); + } + + notify_target_migration_fail { + let bad_loc: v2::MultiLocation = v2::Junction::Plurality { + id: v2::BodyId::Named(WeakBoundedVec::>::try_from(vec![0; 32]) + .expect("vec has a length of 32 bits; qed")), + part: v2::BodyPart::Voice, + } + .into(); + let bad_loc = VersionedMultiLocation::from(bad_loc); + let current_version = T::AdvertisedXcmVersion::get(); + VersionNotifyTargets::::insert(current_version, bad_loc, (0, Weight::zero(), current_version)); + }: { + Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); + } + + migrate_version_notify_targets { + let current_version = T::AdvertisedXcmVersion::get(); + let old_version = current_version - 1; + let loc = VersionedMultiLocation::from(MultiLocation::from(Parent)); + VersionNotifyTargets::::insert(old_version, loc, (0, Weight::zero(), current_version)); + }: { + Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); + } + + migrate_and_notify_old_targets { + let loc = T::ReachableDest::get().ok_or( + BenchmarkError::Override(BenchmarkResult::from_weight(T::DbWeight::get().reads_writes(1, 3))), + )?; + let loc = VersionedMultiLocation::from(loc); + let old_version = T::AdvertisedXcmVersion::get() - 1; + VersionNotifyTargets::::insert(old_version, loc, (0, Weight::zero(), old_version)); + }: { + Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); + } + impl_benchmark_test_suite!( Pallet, crate::mock::new_test_ext_with_balances(Vec::new()), diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index 63ec311edd20..f8e483d1b7a9 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -66,6 +66,13 @@ pub trait WeightInfo { fn force_default_xcm_version() -> Weight; fn force_subscribe_version_notify() -> Weight; fn force_unsubscribe_version_notify() -> Weight; + fn migrate_supported_version() -> Weight; + fn migrate_version_notifiers() -> Weight; + fn already_notified_target() -> Weight; + fn notify_current_targets() -> Weight; + fn notify_target_migration_fail() -> Weight; + fn migrate_version_notify_targets() -> Weight; + fn migrate_and_notify_old_targets() -> Weight; } /// fallback implementation @@ -102,6 +109,34 @@ impl WeightInfo for TestWeightInfo { fn force_unsubscribe_version_notify() -> Weight { Weight::from_ref_time(100_000_000) } + + fn migrate_supported_version() -> Weight { + Weight::from_ref_time(100_000_000) + } + + fn migrate_version_notifiers() -> Weight { + Weight::from_ref_time(100_000_000) + } + + fn already_notified_target() -> Weight { + Weight::from_ref_time(100_000_000) + } + + fn notify_current_targets() -> Weight { + Weight::from_ref_time(100_000_000) + } + + fn notify_target_migration_fail() -> Weight { + Weight::from_ref_time(100_000_000) + } + + fn migrate_version_notify_targets() -> Weight { + Weight::from_ref_time(100_000_000) + } + + fn migrate_and_notify_old_targets() -> Weight { + Weight::from_ref_time(100_000_000) + } } #[frame_support::pallet] @@ -1175,14 +1210,13 @@ impl Pallet { ) -> (Weight, Option) { let mut weight_used = Weight::zero(); - // TODO: Correct weights for the components of this: - let todo_sv_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1); - let todo_vn_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1); - let todo_vnt_already_notified_weight: Weight = T::DbWeight::get().reads(1); - let todo_vnt_notify_weight: Weight = T::DbWeight::get().reads_writes(1, 3); - let todo_vnt_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1); - let todo_vnt_migrate_fail_weight: Weight = T::DbWeight::get().reads_writes(1, 1); - let todo_vnt_notify_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 3); + let sv_migrate_weight = T::WeightInfo::migrate_supported_version(); + let vn_migrate_weight = T::WeightInfo::migrate_version_notifiers(); + let vnt_already_notified_weight = T::WeightInfo::already_notified_target(); + let vnt_notify_weight = T::WeightInfo::notify_current_targets(); + let vnt_migrate_weight = T::WeightInfo::migrate_version_notify_targets(); + let vnt_migrate_fail_weight = T::WeightInfo::notify_target_migration_fail(); + let vnt_notify_migrate_weight = T::WeightInfo::migrate_and_notify_old_targets(); use VersionMigrationStage::*; @@ -1194,7 +1228,7 @@ impl Pallet { if let Ok(new_key) = old_key.into_latest() { SupportedVersion::::insert(XCM_VERSION, new_key, value); } - weight_used.saturating_accrue(todo_sv_migrate_weight); + weight_used.saturating_accrue(sv_migrate_weight); if weight_used.any_gte(weight_cutoff) { return (weight_used, Some(stage)) } @@ -1208,7 +1242,7 @@ impl Pallet { if let Ok(new_key) = old_key.into_latest() { VersionNotifiers::::insert(XCM_VERSION, new_key, value); } - weight_used.saturating_accrue(todo_vn_migrate_weight); + weight_used.saturating_accrue(vn_migrate_weight); if weight_used.any_gte(weight_cutoff) { return (weight_used, Some(stage)) } @@ -1231,7 +1265,7 @@ impl Pallet { _ => { // We don't early return here since we need to be certain that we // make some progress. - weight_used.saturating_accrue(todo_vnt_already_notified_weight); + weight_used.saturating_accrue(vnt_already_notified_weight); continue }, }; @@ -1250,7 +1284,7 @@ impl Pallet { }, }; Self::deposit_event(event); - weight_used.saturating_accrue(todo_vnt_notify_weight); + weight_used.saturating_accrue(vnt_notify_weight); if weight_used.any_gte(weight_cutoff) { let last = Some(iter.last_raw_key().into()); return (weight_used, Some(NotifyCurrentTargets(last))) @@ -1266,7 +1300,7 @@ impl Pallet { Ok(k) => k, Err(()) => { Self::deposit_event(Event::NotifyTargetMigrationFail(old_key, value.0)); - weight_used.saturating_accrue(todo_vnt_migrate_fail_weight); + weight_used.saturating_accrue(vnt_migrate_fail_weight); if weight_used.any_gte(weight_cutoff) { return (weight_used, Some(stage)) } @@ -1277,7 +1311,7 @@ impl Pallet { let versioned_key = LatestVersionedMultiLocation(&new_key); if target_xcm_version == xcm_version { VersionNotifyTargets::::insert(XCM_VERSION, versioned_key, value); - weight_used.saturating_accrue(todo_vnt_migrate_weight); + weight_used.saturating_accrue(vnt_migrate_weight); } else { // Need to notify target. let response = Response::Version(xcm_version); @@ -1299,7 +1333,7 @@ impl Pallet { Err(e) => Event::NotifyTargetSendFail(new_key, query_id, e.into()), }; Self::deposit_event(event); - weight_used.saturating_accrue(todo_vnt_notify_migrate_weight); + weight_used.saturating_accrue(vnt_notify_migrate_weight); } if weight_used.any_gte(weight_cutoff) { return (weight_used, Some(stage)) From 0142d5cd38addbee48bae2aeafce9c9c06552c55 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 21 Dec 2022 16:21:19 +0900 Subject: [PATCH 199/231] Merge remote-tracking branch 'origin/master' into gav-xcm-v3 --- Cargo.lock | 521 ++++++++---------- cli/src/command.rs | 2 +- node/client/src/lib.rs | 4 +- node/core/candidate-validation/src/lib.rs | 17 +- node/core/candidate-validation/src/tests.rs | 2 +- node/core/chain-api/src/lib.rs | 9 +- node/core/chain-api/src/tests.rs | 18 +- node/core/parachains-inherent/Cargo.toml | 1 - node/core/parachains-inherent/src/lib.rs | 3 +- node/core/pvf/src/error.rs | 74 ++- node/core/pvf/src/host.rs | 17 +- node/core/pvf/src/prepare/pool.rs | 84 ++- node/core/pvf/src/prepare/queue.rs | 2 +- node/core/pvf/src/prepare/worker.rs | 70 ++- node/core/pvf/src/worker_common.rs | 15 +- .../src/requester/fetch_task/mod.rs | 21 +- node/network/bridge/src/network.rs | 14 + node/overseer/Cargo.toml | 3 +- node/overseer/src/dummy.rs | 3 + node/overseer/src/lib.rs | 25 +- node/overseer/src/tests.rs | 14 +- node/service/src/grandpa_support.rs | 47 +- node/service/src/lib.rs | 11 +- node/subsystem-types/Cargo.toml | 2 +- node/subsystem-types/src/messages.rs | 18 - node/subsystem/src/lib.rs | 3 + node/test/client/src/block_builder.rs | 13 +- runtime/common/src/assigned_slots.rs | 3 + runtime/common/src/auctions.rs | 3 + runtime/common/src/claims.rs | 5 + runtime/common/src/crowdloan/mod.rs | 9 + runtime/common/src/paras_registrar.rs | 9 + runtime/common/src/paras_sudo_wrapper.rs | 6 + runtime/common/src/purchase.rs | 7 + runtime/common/src/slots/mod.rs | 3 + runtime/parachains/src/configuration.rs | 45 ++ runtime/parachains/src/disputes.rs | 1 + runtime/parachains/src/disputes/slashing.rs | 1 + runtime/parachains/src/hrmp.rs | 8 + runtime/parachains/src/initializer.rs | 1 + runtime/parachains/src/paras/mod.rs | 8 + runtime/parachains/src/paras_inherent/mod.rs | 1 + runtime/parachains/src/ump.rs | 1 + runtime/rococo/src/validator_manager.rs | 2 + runtime/test-runtime/src/lib.rs | 3 + scripts/ci/gitlab/pipeline/check.yml | 7 +- xcm/pallet-xcm/src/lib.rs | 10 + xcm/pallet-xcm/src/mock.rs | 3 + 48 files changed, 642 insertions(+), 507 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0dcbfc93310..af80abdaaebf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,20 +412,17 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "async-trait", "fnv", "futures", - "futures-timer", "log", "parity-scale-codec", "parking_lot 0.12.1", - "sc-chain-spec", "sc-client-api", "sc-consensus", - "sc-finality-grandpa", "sc-keystore", "sc-network", "sc-network-common", @@ -449,7 +446,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "beefy-gadget", "futures", @@ -458,7 +455,6 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "sc-rpc", - "sc-utils", "serde", "sp-beefy", "sp-core", @@ -469,7 +465,7 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "sp-api", "sp-beefy", @@ -1997,7 +1993,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", ] @@ -2020,7 +2016,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -2043,7 +2039,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "Inflector", "array-bytes", @@ -2055,16 +2051,13 @@ dependencies = [ "frame-system", "gethostname", "handlebars", - "hash-db", "itertools", - "kvdb", "lazy_static", "linked-hash-map", "log", - "memory-db", "parity-scale-codec", "rand 0.8.5", - "rand_pcg 0.3.1", + "rand_pcg", "sc-block-builder", "sc-cli", "sc-client-api", @@ -2074,7 +2067,6 @@ dependencies = [ "sc-sysinfo", "serde", "serde_json", - "serde_nanos", "sp-api", "sp-blockchain", "sp-core", @@ -2087,7 +2079,6 @@ dependencies = [ "sp-std", "sp-storage", "sp-trie", - "tempfile", "thiserror", "thousands", ] @@ -2095,7 +2086,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2106,7 +2097,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2123,7 +2114,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -2152,18 +2143,15 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ - "env_logger", "futures", "log", "parity-scale-codec", "serde", - "serde_json", "sp-core", "sp-io", "sp-runtime", - "sp-version", "substrate-rpc-client", "tokio", ] @@ -2171,7 +2159,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "bitflags", "frame-metadata", @@ -2203,7 +2191,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "Inflector", "cfg-expr", @@ -2217,7 +2205,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2229,7 +2217,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "proc-macro2", "quote", @@ -2239,7 +2227,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2262,7 +2250,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -2273,7 +2261,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "log", @@ -2291,7 +2279,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -2306,7 +2294,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "sp-api", @@ -2315,7 +2303,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "parity-scale-codec", @@ -2486,7 +2474,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "chrono", "frame-election-provider-support", @@ -2495,7 +2483,6 @@ dependencies = [ "git2", "num-format", "pallet-staking", - "sp-io", ] [[package]] @@ -2534,10 +2521,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -4102,7 +4087,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", "log", @@ -4114,7 +4099,6 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-core", - "sp-io", "sp-mmr-primitives", "sp-runtime", ] @@ -4122,7 +4106,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "anyhow", "jsonrpsee", @@ -4576,9 +4560,9 @@ dependencies = [ [[package]] name = "orchestra" -version = "0.0.2" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aab54694ddaa8a9b703724c6ef04272b2d27bc32d2c855aae5cdd1857216b43" +checksum = "17e7d5b6bb115db09390bed8842c94180893dd83df3dfce7354f2a2aa090a4ee" dependencies = [ "async-trait", "dyn-clonable", @@ -4593,9 +4577,9 @@ dependencies = [ [[package]] name = "orchestra-proc-macro" -version = "0.0.2" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a702b2f6bf592b3eb06c00d80d05afaf7a8eff6b41bb361e397d799acc21b45a" +checksum = "c2af4dabb2286b0be0e9711d2d24e25f6217048b71210cffd3daddc3b5c84e1f" dependencies = [ "expander 0.0.6", "itertools", @@ -4645,7 +4629,7 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4660,7 +4644,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -4676,7 +4660,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -4691,7 +4675,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4715,7 +4699,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4735,7 +4719,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-election-provider-support", "frame-remote-externalities", @@ -4754,7 +4738,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4769,7 +4753,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -4785,7 +4769,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "beefy-merkle-tree", @@ -4808,7 +4792,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4826,7 +4810,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4845,7 +4829,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4862,7 +4846,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "assert_matches", "frame-benchmarking", @@ -4879,7 +4863,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4897,7 +4881,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4906,7 +4890,7 @@ dependencies = [ "log", "pallet-election-provider-support-benchmarking", "parity-scale-codec", - "rand 0.7.3", + "rand 0.8.5", "scale-info", "sp-arithmetic", "sp-core", @@ -4914,14 +4898,13 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "static_assertions", "strum", ] [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4934,7 +4917,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4952,7 +4935,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4970,7 +4953,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -4993,7 +4976,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5009,7 +4992,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5029,7 +5012,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5046,7 +5029,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5063,7 +5046,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5080,7 +5063,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5096,7 +5079,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5112,7 +5095,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -5129,7 +5112,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5149,7 +5132,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "sp-api", @@ -5159,7 +5142,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -5176,7 +5159,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5199,7 +5182,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5216,7 +5199,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5231,7 +5214,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5249,7 +5232,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5264,7 +5247,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5283,7 +5266,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5300,7 +5283,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -5321,14 +5304,14 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "pallet-session", "pallet-staking", - "rand 0.7.3", + "rand 0.8.5", "sp-runtime", "sp-session", "sp-std", @@ -5337,7 +5320,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -5351,7 +5334,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5374,7 +5357,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5385,7 +5368,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "log", "sp-arithmetic", @@ -5394,7 +5377,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5411,7 +5394,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -5425,7 +5408,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5443,7 +5426,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5462,7 +5445,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-support", "frame-system", @@ -5478,7 +5461,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -5494,7 +5477,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5506,7 +5489,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5538,7 +5521,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5554,7 +5537,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5569,7 +5552,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-benchmarking", "frame-support", @@ -5749,20 +5732,20 @@ checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" [[package]] name = "pbkdf2" -version = "0.4.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" dependencies = [ - "crypto-mac 0.8.0", + "crypto-mac 0.11.1", ] [[package]] name = "pbkdf2" -version = "0.8.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "crypto-mac 0.11.1", + "digest 0.10.5", ] [[package]] @@ -6455,7 +6438,6 @@ dependencies = [ "polkadot-primitives", "sp-blockchain", "sp-inherents", - "sp-runtime", "thiserror", "tracing-gum", ] @@ -7796,7 +7778,6 @@ dependencies = [ "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc", - "rand_pcg 0.2.1", ] [[package]] @@ -7867,15 +7848,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", -] - [[package]] name = "rand_pcg" version = "0.3.1" @@ -8353,7 +8325,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "log", "sp-core", @@ -8364,7 +8336,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "futures", @@ -8375,7 +8347,7 @@ dependencies = [ "parity-scale-codec", "prost", "prost-build", - "rand 0.7.3", + "rand 0.8.5", "sc-client-api", "sc-network-common", "sp-api", @@ -8391,7 +8363,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", "futures-timer", @@ -8414,7 +8386,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8430,11 +8402,9 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ - "impl-trait-for-tuples", "memmap2", - "parity-scale-codec", "sc-chain-spec-derive", "sc-network-common", "sc-telemetry", @@ -8447,7 +8417,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8458,7 +8428,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "chrono", @@ -8469,7 +8439,7 @@ dependencies = [ "log", "names", "parity-scale-codec", - "rand 0.7.3", + "rand 0.8.5", "regex", "rpassword", "sc-client-api", @@ -8498,11 +8468,10 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "fnv", "futures", - "hash-db", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -8519,14 +8488,13 @@ dependencies = [ "sp-runtime", "sp-state-machine", "sp-storage", - "sp-trie", "substrate-prometheus-endpoint", ] [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "hash-db", "kvdb", @@ -8551,7 +8519,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "futures", @@ -8576,7 +8544,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "fork-tree", @@ -8595,7 +8563,6 @@ dependencies = [ "sc-keystore", "sc-telemetry", "schnorrkel", - "serde", "sp-api", "sp-application-crypto", "sp-block-builder", @@ -8606,10 +8573,8 @@ dependencies = [ "sp-consensus-vrf", "sp-core", "sp-inherents", - "sp-io", "sp-keystore", "sp-runtime", - "sp-version", "substrate-prometheus-endpoint", "thiserror", ] @@ -8617,7 +8582,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", "jsonrpsee", @@ -8639,7 +8604,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8652,7 +8617,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "futures", @@ -8670,13 +8635,12 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "thiserror", ] [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "lru", "parity-scale-codec", @@ -8700,7 +8664,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -8713,7 +8677,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "log", "sc-allocator", @@ -8726,7 +8690,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "cfg-if", "libc", @@ -8743,7 +8707,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "ahash", "array-bytes", @@ -8761,7 +8725,6 @@ dependencies = [ "sc-chain-spec", "sc-client-api", "sc-consensus", - "sc-keystore", "sc-network", "sc-network-common", "sc-network-gossip", @@ -8784,7 +8747,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "finality-grandpa", "futures", @@ -8795,7 +8758,6 @@ dependencies = [ "sc-finality-grandpa", "sc-rpc", "serde", - "serde_json", "sp-blockchain", "sp-core", "sp-runtime", @@ -8805,7 +8767,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "ansi_term", "futures", @@ -8813,7 +8775,6 @@ dependencies = [ "log", "sc-client-api", "sc-network-common", - "sc-transaction-pool-api", "sp-blockchain", "sp-runtime", ] @@ -8821,7 +8782,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "async-trait", @@ -8836,30 +8797,24 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "async-trait", "asynchronous-codec", - "bitflags", "bytes", - "cid", "either", "fnv", - "fork-tree", "futures", "futures-timer", "ip_network", "libp2p", - "linked-hash-map", - "linked_hash_set", "log", "lru", "parity-scale-codec", "parking_lot 0.12.1", "pin-project", - "prost", - "rand 0.7.3", + "rand 0.8.5", "sc-block-builder", "sc-client-api", "sc-consensus", @@ -8883,7 +8838,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "cid", "futures", @@ -8897,13 +8852,12 @@ dependencies = [ "sp-runtime", "thiserror", "unsigned-varint", - "void", ] [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "bitflags", @@ -8929,7 +8883,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "ahash", "futures", @@ -8947,7 +8901,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "futures", @@ -8968,7 +8922,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "async-trait", @@ -9000,11 +8954,10 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "futures", - "hex", "libp2p", "log", "parity-scale-codec", @@ -9019,7 +8972,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "bytes", @@ -9033,7 +8986,7 @@ dependencies = [ "once_cell", "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.7.3", + "rand 0.8.5", "sc-client-api", "sc-network-common", "sc-peerset", @@ -9049,7 +9002,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", "libp2p", @@ -9062,7 +9015,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9071,10 +9024,9 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", - "hash-db", "jsonrpsee", "log", "parity-scale-codec", @@ -9101,13 +9053,10 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ - "futures", "jsonrpsee", - "log", "parity-scale-codec", - "parking_lot 0.12.1", "sc-chain-spec", "sc-transaction-pool-api", "scale-info", @@ -9116,7 +9065,6 @@ dependencies = [ "sp-core", "sp-rpc", "sp-runtime", - "sp-tracing", "sp-version", "thiserror", ] @@ -9124,9 +9072,8 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ - "futures", "http", "jsonrpsee", "log", @@ -9140,39 +9087,45 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ + "array-bytes", "futures", + "futures-util", "hex", "jsonrpsee", + "log", "parity-scale-codec", + "parking_lot 0.12.1", "sc-chain-spec", + "sc-client-api", "sc-transaction-pool-api", "serde", "sp-api", "sp-blockchain", "sp-core", "sp-runtime", + "sp-version", "thiserror", + "tokio-stream", ] [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "directories", "exit-future", "futures", "futures-timer", - "hash-db", "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.1", "pin-project", - "rand 0.7.3", + "rand 0.8.5", "sc-block-builder", "sc-chain-spec", "sc-client-api", @@ -9200,19 +9153,15 @@ dependencies = [ "serde", "serde_json", "sp-api", - "sp-application-crypto", - "sp-block-builder", "sp-blockchain", "sp-consensus", "sp-core", "sp-externalities", - "sp-inherents", "sp-keystore", "sp-runtime", "sp-session", "sp-state-machine", "sp-storage", - "sp-tracing", "sp-transaction-pool", "sp-transaction-storage-proof", "sp-trie", @@ -9229,19 +9178,18 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "log", "parity-scale-codec", "parking_lot 0.12.1", - "sc-client-api", "sp-core", ] [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9260,13 +9208,13 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", "libc", "log", - "rand 0.7.3", - "rand_pcg 0.2.1", + "rand 0.8.5", + "rand_pcg", "regex", "sc-telemetry", "serde", @@ -9279,7 +9227,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "chrono", "futures", @@ -9287,7 +9235,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "pin-project", - "rand 0.7.3", + "rand 0.8.5", "serde", "serde_json", "thiserror", @@ -9297,7 +9245,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "ansi_term", "atty", @@ -9328,7 +9276,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9339,7 +9287,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "futures", @@ -9365,7 +9313,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "futures", @@ -9379,7 +9327,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", "futures-timer", @@ -9599,15 +9547,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_nanos" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e44969a61f5d316be20a42ff97816efb3b407a924d06824c3d8a49fa8450de0e" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -9863,7 +9802,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "hash-db", "log", @@ -9881,7 +9820,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "blake2", "proc-macro-crate", @@ -9893,7 +9832,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "scale-info", @@ -9906,14 +9845,13 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "integer-sqrt", "num-traits", "parity-scale-codec", "scale-info", "serde", - "sp-debug-derive", "sp-std", "static_assertions", ] @@ -9921,7 +9859,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "scale-info", @@ -9934,7 +9872,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "parity-scale-codec", @@ -9946,7 +9884,7 @@ dependencies = [ [[package]] name = "sp-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "scale-info", @@ -9963,7 +9901,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "sp-api", @@ -9975,7 +9913,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", "log", @@ -9993,11 +9931,10 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "futures", - "futures-timer", "log", "parity-scale-codec", "sp-core", @@ -10012,7 +9949,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "merlin", @@ -10035,13 +9972,11 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-arithmetic", - "sp-runtime", "sp-std", "sp-timestamp", ] @@ -10049,7 +9984,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "scale-info", @@ -10062,13 +9997,12 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "base58", "bitflags", "blake2", - "byteorder", "dyn-clonable", "ed25519-zebra", "futures", @@ -10079,11 +10013,10 @@ dependencies = [ "libsecp256k1", "log", "merlin", - "num-traits", "parity-scale-codec", "parking_lot 0.12.1", "primitive-types", - "rand 0.7.3", + "rand 0.8.5", "regex", "scale-info", "schnorrkel", @@ -10100,14 +10033,13 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", - "wasmi", "zeroize", ] [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "blake2", "byteorder", @@ -10121,7 +10053,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "proc-macro2", "quote", @@ -10132,7 +10064,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10141,7 +10073,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "proc-macro2", "quote", @@ -10151,7 +10083,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "environmental", "parity-scale-codec", @@ -10162,7 +10094,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "finality-grandpa", "log", @@ -10180,7 +10112,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10194,16 +10126,15 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "bytes", + "ed25519", "ed25519-dalek", "futures", - "hash-db", "libsecp256k1", "log", "parity-scale-codec", - "parking_lot 0.12.1", "secp256k1", "sp-core", "sp-externalities", @@ -10213,7 +10144,6 @@ dependencies = [ "sp-std", "sp-tracing", "sp-trie", - "sp-wasm-interface", "tracing", "tracing-core", ] @@ -10221,7 +10151,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "lazy_static", "sp-core", @@ -10232,7 +10162,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "futures", @@ -10249,7 +10179,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "thiserror", "zstd", @@ -10258,7 +10188,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -10276,7 +10206,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "scale-info", @@ -10290,7 +10220,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "sp-api", "sp-core", @@ -10300,7 +10230,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "backtrace", "lazy_static", @@ -10310,7 +10240,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "rustc-hash", "serde", @@ -10320,7 +10250,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "either", "hash256-std-hasher", @@ -10328,7 +10258,7 @@ dependencies = [ "log", "parity-scale-codec", "paste", - "rand 0.7.3", + "rand 0.8.5", "scale-info", "serde", "sp-application-crypto", @@ -10342,7 +10272,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10360,7 +10290,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "Inflector", "proc-macro-crate", @@ -10372,7 +10302,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "scale-info", @@ -10386,7 +10316,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "scale-info", @@ -10398,14 +10328,13 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "hash-db", "log", - "num-traits", "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.7.3", + "rand 0.8.5", "smallvec", "sp-core", "sp-externalities", @@ -10414,18 +10343,17 @@ dependencies = [ "sp-trie", "thiserror", "tracing", - "trie-root", ] [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10438,13 +10366,12 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "futures-timer", "log", "parity-scale-codec", - "sp-api", "sp-inherents", "sp-runtime", "sp-std", @@ -10454,7 +10381,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "sp-std", @@ -10466,7 +10393,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "sp-api", "sp-runtime", @@ -10475,7 +10402,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "log", @@ -10491,7 +10418,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "ahash", "hash-db", @@ -10514,7 +10441,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10531,7 +10458,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10542,7 +10469,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "impl-trait-for-tuples", "log", @@ -10555,9 +10482,8 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ - "impl-trait-for-tuples", "parity-scale-codec", "scale-info", "serde", @@ -10770,7 +10696,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "platforms", ] @@ -10778,17 +10704,15 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "frame-system-rpc-runtime-api", "futures", "jsonrpsee", "log", "parity-scale-codec", - "sc-client-api", "sc-rpc-api", "sc-transaction-pool-api", - "serde_json", "sp-api", "sp-block-builder", "sp-blockchain", @@ -10799,9 +10723,8 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ - "futures-util", "hyper", "log", "prometheus", @@ -10812,7 +10735,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "async-trait", "jsonrpsee", @@ -10825,7 +10748,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "jsonrpsee", "log", @@ -10835,10 +10758,8 @@ dependencies = [ "scale-info", "serde", "sp-core", - "sp-io", "sp-runtime", "sp-state-machine", - "sp-std", "sp-trie", "trie-db", ] @@ -10846,7 +10767,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "array-bytes", "async-trait", @@ -10872,7 +10793,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "futures", "substrate-test-utils-derive", @@ -10882,7 +10803,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10893,7 +10814,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "ansi_term", "build-helper", @@ -10947,9 +10868,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.103" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" dependencies = [ "proc-macro2", "quote", @@ -11242,17 +11163,17 @@ dependencies = [ [[package]] name = "tiny-bip39" -version = "0.8.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" dependencies = [ "anyhow", - "hmac 0.8.1", + "hmac 0.12.1", "once_cell", - "pbkdf2 0.4.0", - "rand 0.7.3", + "pbkdf2 0.11.0", + "rand 0.8.5", "rustc-hash", - "sha2 0.9.9", + "sha2 0.10.6", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -11344,6 +11265,7 @@ dependencies = [ "futures-core", "pin-project-lite 0.2.9", "tokio", + "tokio-util", ] [[package]] @@ -11627,7 +11549,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#cd2fdcf85eb96c53ce2a5d418d4338eb92f5d4f5" +source = "git+https://github.com/paritytech/substrate?branch=master#657c808eb3d22284359a802d67fdfdbe823fbd17" dependencies = [ "clap", "frame-remote-externalities", @@ -11635,7 +11557,6 @@ dependencies = [ "hex", "log", "parity-scale-codec", - "sc-chain-spec", "sc-cli", "sc-executor", "sc-service", diff --git a/cli/src/command.rs b/cli/src/command.rs index 81d707e58a24..d7a66bb9d711 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -541,7 +541,7 @@ pub fn run() -> Result<()> { ensure_dev(chain_spec).map_err(Error::Other)?; runner.sync_run(|mut config| { let (client, _, _, _) = service::new_chain_ops(&mut config, None)?; - let header = client.header(BlockId::Number(0_u32.into())).unwrap().unwrap(); + let header = client.header(client.info().genesis_hash).unwrap().unwrap(); let inherent_data = benchmark_inherent_data(header) .map_err(|e| format!("generating inherent data: {:?}", e))?; let remark_builder = RemarkBuilder::new(client.clone()); diff --git a/node/client/src/lib.rs b/node/client/src/lib.rs index d2c119ba04a8..2a231058bb83 100644 --- a/node/client/src/lib.rs +++ b/node/client/src/lib.rs @@ -560,12 +560,12 @@ impl sc_client_api::StorageProvider for Client { } impl sp_blockchain::HeaderBackend for Client { - fn header(&self, id: BlockId) -> sp_blockchain::Result> { + fn header(&self, hash: Hash) -> sp_blockchain::Result> { with_client! { self, client, { - client.header(&id) + client.header(hash) } } } diff --git a/node/core/candidate-validation/src/lib.rs b/node/core/candidate-validation/src/lib.rs index 74610bc113ec..70fc24eacade 100644 --- a/node/core/candidate-validation/src/lib.rs +++ b/node/core/candidate-validation/src/lib.rs @@ -320,12 +320,12 @@ where match validation_backend.precheck_pvf(validation_code).await { Ok(_) => PreCheckOutcome::Valid, - Err(prepare_err) => match prepare_err { - PrepareError::Prevalidation(_) | - PrepareError::Preparation(_) | - PrepareError::Panic(_) => PreCheckOutcome::Invalid, - PrepareError::TimedOut | PrepareError::DidNotMakeIt => PreCheckOutcome::Failed, - }, + Err(prepare_err) => + if prepare_err.is_deterministic() { + PreCheckOutcome::Invalid + } else { + PreCheckOutcome::Failed + }, } } @@ -667,10 +667,11 @@ impl ValidationBackend for ValidationHost { async fn precheck_pvf(&mut self, pvf: Pvf) -> Result { let (tx, rx) = oneshot::channel(); if let Err(_) = self.precheck_pvf(pvf, tx).await { - return Err(PrepareError::DidNotMakeIt) + // Return an IO error if there was an error communicating with the host. + return Err(PrepareError::IoErr) } - let precheck_result = rx.await.or(Err(PrepareError::DidNotMakeIt))?; + let precheck_result = rx.await.or(Err(PrepareError::IoErr))?; precheck_result } diff --git a/node/core/candidate-validation/src/tests.rs b/node/core/candidate-validation/src/tests.rs index 5ac93bc7d1f4..c6003c734973 100644 --- a/node/core/candidate-validation/src/tests.rs +++ b/node/core/candidate-validation/src/tests.rs @@ -1053,5 +1053,5 @@ fn precheck_properly_classifies_outcomes() { inner(Err(PrepareError::Panic("baz".to_owned())), PreCheckOutcome::Invalid); inner(Err(PrepareError::TimedOut), PreCheckOutcome::Failed); - inner(Err(PrepareError::DidNotMakeIt), PreCheckOutcome::Failed); + inner(Err(PrepareError::IoErr), PreCheckOutcome::Failed); } diff --git a/node/core/chain-api/src/lib.rs b/node/core/chain-api/src/lib.rs index 7205527982c1..b218c00c57e5 100644 --- a/node/core/chain-api/src/lib.rs +++ b/node/core/chain-api/src/lib.rs @@ -41,7 +41,7 @@ use polkadot_node_subsystem::{ messages::ChainApiMessage, overseer, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, SubsystemResult, }; -use polkadot_primitives::v2::{Block, BlockId}; +use polkadot_primitives::v2::Block; mod metrics; use self::metrics::Metrics; @@ -99,10 +99,7 @@ where }, ChainApiMessage::BlockHeader(hash, response_channel) => { let _timer = subsystem.metrics.time_block_header(); - let result = subsystem - .client - .header(BlockId::Hash(hash)) - .map_err(|e| e.to_string().into()); + let result = subsystem.client.header(hash).map_err(|e| e.to_string().into()); subsystem.metrics.on_request(result.is_ok()); let _ = response_channel.send(result); }, @@ -134,7 +131,7 @@ where let mut hash = hash; let next_parent = core::iter::from_fn(|| { - let maybe_header = subsystem.client.header(BlockId::Hash(hash)); + let maybe_header = subsystem.client.header(hash); match maybe_header { // propagate the error Err(e) => { diff --git a/node/core/chain-api/src/tests.rs b/node/core/chain-api/src/tests.rs index aa24b3621200..5b0a2a0e390f 100644 --- a/node/core/chain-api/src/tests.rs +++ b/node/core/chain-api/src/tests.rs @@ -117,13 +117,11 @@ impl HeaderBackend for TestClient { fn hash(&self, number: BlockNumber) -> sp_blockchain::Result> { Ok(self.finalized_blocks.get(&number).copied()) } - fn header(&self, id: BlockId) -> sp_blockchain::Result> { - match id { - // for error path testing - BlockId::Hash(hash) if hash.is_zero() => - Err(sp_blockchain::Error::Backend("Zero hashes are illegal!".into())), - BlockId::Hash(hash) => Ok(self.headers.get(&hash).cloned()), - _ => unreachable!(), + fn header(&self, hash: Hash) -> sp_blockchain::Result> { + if hash.is_zero() { + Err(sp_blockchain::Error::Backend("Zero hashes are illegal!".into())) + } else { + Ok(self.headers.get(&hash).cloned()) } } fn status(&self, _id: BlockId) -> sp_blockchain::Result { @@ -203,10 +201,8 @@ fn request_block_header() { test_harness(|client, mut sender| { async move { const NOT_HERE: Hash = Hash::repeat_byte(0x5); - let test_cases = [ - (TWO, client.header(BlockId::Hash(TWO)).unwrap()), - (NOT_HERE, client.header(BlockId::Hash(NOT_HERE)).unwrap()), - ]; + let test_cases = + [(TWO, client.header(TWO).unwrap()), (NOT_HERE, client.header(NOT_HERE).unwrap())]; for (hash, expected) in &test_cases { let (tx, rx) = oneshot::channel(); diff --git a/node/core/parachains-inherent/Cargo.toml b/node/core/parachains-inherent/Cargo.toml index 26277dd47f8a..d4301cb22270 100644 --- a/node/core/parachains-inherent/Cargo.toml +++ b/node/core/parachains-inherent/Cargo.toml @@ -15,4 +15,3 @@ polkadot-overseer = { path = "../../overseer" } polkadot-primitives = { path = "../../../primitives" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/node/core/parachains-inherent/src/lib.rs b/node/core/parachains-inherent/src/lib.rs index 7634522128e7..a4df582b17a8 100644 --- a/node/core/parachains-inherent/src/lib.rs +++ b/node/core/parachains-inherent/src/lib.rs @@ -29,7 +29,6 @@ use polkadot_node_subsystem::{ errors::SubsystemError, messages::ProvisionerMessage, overseer::Handle, }; use polkadot_primitives::v2::{Block, Hash, InherentData as ParachainsInherentData}; -use sp_runtime::generic::BlockId; use std::{sync::Arc, time}; pub(crate) const LOG_TARGET: &str = "parachain::parachains-inherent"; @@ -87,7 +86,7 @@ impl> ParachainsInherentDataProvider { let mut timeout = futures_timer::Delay::new(PROVISIONER_TIMEOUT).fuse(); - let parent_header = match client.header(BlockId::Hash(parent)) { + let parent_header = match client.header(parent) { Ok(Some(h)) => h, Ok(None) => return Err(Error::ParentHeaderNotFound(parent)), Err(err) => return Err(Error::Blockchain(err)), diff --git a/node/core/pvf/src/error.rs b/node/core/pvf/src/error.rs index ddcdb2561cfd..01d8c78d39ca 100644 --- a/node/core/pvf/src/error.rs +++ b/node/core/pvf/src/error.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use parity_scale_codec::{Decode, Encode}; -use std::{any::Any, time::Duration}; +use std::{any::Any, fmt, time::Duration}; /// Result of PVF preparation performed by the validation host. Contains the elapsed CPU time if /// successful @@ -32,9 +32,46 @@ pub enum PrepareError { Panic(String), /// Failed to prepare the PVF due to the time limit. TimedOut, - /// This state indicates that the process assigned to prepare the artifact wasn't responsible - /// or were killed. This state is reported by the validation host (not by the worker). - DidNotMakeIt, + /// An IO error occurred while receiving the result from the worker process. This state is reported by the + /// validation host (not by the worker). + IoErr, + /// The temporary file for the artifact could not be created at the given cache path. This state is reported by the + /// validation host (not by the worker). + CreateTmpFileErr(String), + /// The response from the worker is received, but the file cannot be renamed (moved) to the final destination + /// location. This state is reported by the validation host (not by the worker). + RenameTmpFileErr(String), +} + +impl PrepareError { + /// Returns whether this is a deterministic error, i.e. one that should trigger reliably. Those + /// errors depend on the PVF itself and the sc-executor/wasmtime logic. + /// + /// Non-deterministic errors can happen spuriously. Typically, they occur due to resource + /// starvation, e.g. under heavy load or memory pressure. Those errors are typically transient + /// but may persist e.g. if the node is run by overwhelmingly underpowered machine. + pub fn is_deterministic(&self) -> bool { + use PrepareError::*; + match self { + Prevalidation(_) | Preparation(_) | Panic(_) => true, + TimedOut | IoErr | CreateTmpFileErr(_) | RenameTmpFileErr(_) => false, + } + } +} + +impl fmt::Display for PrepareError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use PrepareError::*; + match self { + Prevalidation(err) => write!(f, "prevalidation: {}", err), + Preparation(err) => write!(f, "preparation: {}", err), + Panic(err) => write!(f, "panic: {}", err), + TimedOut => write!(f, "prepare: timeout"), + IoErr => write!(f, "prepare: io error while receiving response"), + CreateTmpFileErr(err) => write!(f, "prepare: error creating tmp file: {}", err), + RenameTmpFileErr(err) => write!(f, "prepare: error renaming tmp file: {}", err), + } + } } /// A error raised during validation of the candidate. @@ -81,32 +118,17 @@ pub enum InvalidCandidate { impl From for ValidationError { fn from(error: PrepareError) -> Self { // Here we need to classify the errors into two errors: deterministic and non-deterministic. + // See [`PrepareError::is_deterministic`]. // - // Non-deterministic errors can happen spuriously. Typically, they occur due to resource - // starvation, e.g. under heavy load or memory pressure. Those errors are typically transient - // but may persist e.g. if the node is run by overwhelmingly underpowered machine. - // - // Deterministic errors should trigger reliably. Those errors depend on the PVF itself and - // the sc-executor/wasmtime logic. - // - // For now, at least until the PVF pre-checking lands, the deterministic errors will be - // treated as `InvalidCandidate`. Should those occur they could potentially trigger disputes. + // We treat the deterministic errors as `InvalidCandidate`. Should those occur they could + // potentially trigger disputes. // // All non-deterministic errors are qualified as `InternalError`s and will not trigger // disputes. - match error { - PrepareError::Prevalidation(err) => ValidationError::InvalidCandidate( - InvalidCandidate::PrepareError(format!("prevalidation: {}", err)), - ), - PrepareError::Preparation(err) => ValidationError::InvalidCandidate( - InvalidCandidate::PrepareError(format!("preparation: {}", err)), - ), - PrepareError::Panic(err) => ValidationError::InvalidCandidate( - InvalidCandidate::PrepareError(format!("panic: {}", err)), - ), - PrepareError::TimedOut => ValidationError::InternalError("prepare: timeout".to_owned()), - PrepareError::DidNotMakeIt => - ValidationError::InternalError("prepare: did not make it".to_owned()), + if error.is_deterministic() { + ValidationError::InvalidCandidate(InvalidCandidate::PrepareError(error.to_string())) + } else { + ValidationError::InternalError(error.to_string()) } } } diff --git a/node/core/pvf/src/host.rs b/node/core/pvf/src/host.rs index ad59cdb3bc4c..fed8021a86cb 100644 --- a/node/core/pvf/src/host.rs +++ b/node/core/pvf/src/host.rs @@ -776,16 +776,15 @@ fn can_retry_prepare_after_failure( num_failures: u32, error: &PrepareError, ) -> bool { - use PrepareError::*; - match error { - // Gracefully returned an error, so it will probably be reproducible. Don't retry. - Prevalidation(_) | Preparation(_) => false, - // Retry if the retry cooldown has elapsed and if we have already retried less than - // `NUM_PREPARE_RETRIES` times. IO errors may resolve themselves. - Panic(_) | TimedOut | DidNotMakeIt => - SystemTime::now() >= last_time_failed + PREPARE_FAILURE_COOLDOWN && - num_failures <= NUM_PREPARE_RETRIES, + if error.is_deterministic() { + // This error is considered deterministic, so it will probably be reproducible. Don't retry. + return false } + + // Retry if the retry cooldown has elapsed and if we have already retried less than `NUM_PREPARE_RETRIES` times. IO + // errors may resolve themselves. + SystemTime::now() >= last_time_failed + PREPARE_FAILURE_COOLDOWN && + num_failures <= NUM_PREPARE_RETRIES } /// A stream that yields a pulse continuously at a given interval. diff --git a/node/core/pvf/src/prepare/pool.rs b/node/core/pvf/src/prepare/pool.rs index 306588eb429a..3319d44e7fb4 100644 --- a/node/core/pvf/src/prepare/pool.rs +++ b/node/core/pvf/src/prepare/pool.rs @@ -22,7 +22,6 @@ use crate::{ LOG_TARGET, }; use always_assert::never; -use assert_matches::assert_matches; use async_std::path::{Path, PathBuf}; use futures::{ channel::mpsc, future::BoxFuture, stream::FuturesUnordered, Future, FutureExt, StreamExt, @@ -232,7 +231,7 @@ fn handle_to_pool( // items concluded; // thus idle token is Some; // qed. - never!("unexpected abscence of the idle token in prepare pool"); + never!("unexpected absence of the idle token in prepare pool"); } } else { // That's a relatively normal situation since the queue may send `start_work` and @@ -294,29 +293,28 @@ fn handle_mux( Ok(()) }, PoolEvent::StartWork(worker, outcome) => { - // If we receive any outcome other than `Concluded`, we attempt to kill the worker - // process. + // If we receive an outcome that the worker is unreachable or that an error occurred on + // the worker, we attempt to kill the worker process. match outcome { - Outcome::Concluded { worker: idle, result } => { - let data = match spawned.get_mut(worker) { - None => { - // Perhaps the worker was killed meanwhile and the result is no longer - // relevant. We already send `Rip` when purging if we detect that the - // worker is dead. - return Ok(()) - }, - Some(data) => data, - }; - - // We just replace the idle worker that was loaned from this option during - // the work starting. - let old = data.idle.replace(idle); - assert_matches!(old, None, "attempt to overwrite an idle worker"); - - reply(from_pool, FromPool::Concluded { worker, rip: false, result })?; - - Ok(()) - }, + Outcome::Concluded { worker: idle, result } => + handle_concluded_no_rip(from_pool, spawned, worker, idle, result), + // Return `Concluded`, but do not kill the worker since the error was on the host side. + Outcome::CreateTmpFileErr { worker: idle, err } => handle_concluded_no_rip( + from_pool, + spawned, + worker, + idle, + Err(PrepareError::CreateTmpFileErr(err)), + ), + // Return `Concluded`, but do not kill the worker since the error was on the host side. + Outcome::RenameTmpFileErr { worker: idle, result: _, err } => + handle_concluded_no_rip( + from_pool, + spawned, + worker, + idle, + Err(PrepareError::RenameTmpFileErr(err)), + ), Outcome::Unreachable => { if attempt_retire(metrics, spawned, worker) { reply(from_pool, FromPool::Rip(worker))?; @@ -324,14 +322,14 @@ fn handle_mux( Ok(()) }, - Outcome::DidNotMakeIt => { + Outcome::IoErr => { if attempt_retire(metrics, spawned, worker) { reply( from_pool, FromPool::Concluded { worker, rip: true, - result: Err(PrepareError::DidNotMakeIt), + result: Err(PrepareError::IoErr), }, )?; } @@ -380,6 +378,40 @@ fn attempt_retire( } } +/// Handles the case where we received a response. There potentially was an error, but not the fault +/// of the worker as far as we know, so the worker should not be killed. +/// +/// This function tries to put the idle worker back into the pool and then replies with +/// `FromPool::Concluded` with `rip: false`. +fn handle_concluded_no_rip( + from_pool: &mut mpsc::UnboundedSender, + spawned: &mut HopSlotMap, + worker: Worker, + idle: IdleWorker, + result: PrepareResult, +) -> Result<(), Fatal> { + let data = match spawned.get_mut(worker) { + None => { + // Perhaps the worker was killed meanwhile and the result is no longer relevant. We + // already send `Rip` when purging if we detect that the worker is dead. + return Ok(()) + }, + Some(data) => data, + }; + + // We just replace the idle worker that was loaned from this option during + // the work starting. + let old = data.idle.replace(idle); + never!( + old.is_some(), + "old idle worker was taken out when starting work; we only replace it here; qed" + ); + + reply(from_pool, FromPool::Concluded { worker, rip: false, result })?; + + Ok(()) +} + /// Spins up the pool and returns the future that should be polled to make the pool functional. pub fn start( metrics: Metrics, diff --git a/node/core/pvf/src/prepare/queue.rs b/node/core/pvf/src/prepare/queue.rs index df0a8ec41883..e78351af9839 100644 --- a/node/core/pvf/src/prepare/queue.rs +++ b/node/core/pvf/src/prepare/queue.rs @@ -761,7 +761,7 @@ mod tests { test.send_from_pool(pool::FromPool::Concluded { worker: w1, rip: true, - result: Err(PrepareError::DidNotMakeIt), + result: Err(PrepareError::IoErr), }); test.poll_ensure_to_pool_is_empty().await; } diff --git a/node/core/pvf/src/prepare/worker.rs b/node/core/pvf/src/prepare/worker.rs index 91361eacaf26..5b4212e1e313 100644 --- a/node/core/pvf/src/prepare/worker.rs +++ b/node/core/pvf/src/prepare/worker.rs @@ -59,28 +59,26 @@ pub enum Outcome { /// The host tried to reach the worker but failed. This is most likely because the worked was /// killed by the system. Unreachable, + /// The temporary file for the artifact could not be created at the given cache path. + CreateTmpFileErr { worker: IdleWorker, err: String }, + /// The response from the worker is received, but the file cannot be renamed (moved) to the + /// final destination location. + RenameTmpFileErr { worker: IdleWorker, result: PrepareResult, err: String }, /// The worker failed to finish the job until the given deadline. /// /// The worker is no longer usable and should be killed. TimedOut, - /// The execution was interrupted abruptly and the worker is not available anymore. + /// An IO error occurred while receiving the result from the worker process. /// /// This doesn't return an idle worker instance, thus this worker is no longer usable. - DidNotMakeIt, -} - -#[derive(Debug)] -enum Selected { - Done(PrepareResult), IoErr, - Deadline, } /// Given the idle token of a worker and parameters of work, communicates with the worker and /// returns the outcome. /// -/// NOTE: Returning the `TimedOut` or `DidNotMakeIt` errors will trigger the child process being -/// killed. +/// NOTE: Returning the `TimedOut`, `IoErr` or `Unreachable` outcomes will trigger the child process +/// being killed. pub async fn start_work( worker: IdleWorker, code: Arc>, @@ -97,7 +95,7 @@ pub async fn start_work( artifact_path.display(), ); - with_tmp_file(pid, cache_path, |tmp_file| async move { + with_tmp_file(stream.clone(), pid, cache_path, |tmp_file| async move { if let Err(err) = send_request(&mut stream, code, &tmp_file, preparation_timeout).await { gum::warn!( target: LOG_TARGET, @@ -120,10 +118,11 @@ pub async fn start_work( let timeout = preparation_timeout * JOB_TIMEOUT_WALL_CLOCK_FACTOR; let result = async_std::future::timeout(timeout, framed_recv(&mut stream)).await; - let selected = match result { + match result { // Received bytes from worker within the time limit. Ok(Ok(response_bytes)) => handle_response_bytes( + IdleWorker { stream, pid }, response_bytes, pid, tmp_file, @@ -139,7 +138,7 @@ pub async fn start_work( "failed to recv a prepare response: {:?}", err, ); - Selected::IoErr + Outcome::IoErr }, Err(_) => { // Timed out here on the host. @@ -148,18 +147,8 @@ pub async fn start_work( worker_pid = %pid, "did not recv a prepare response within the time limit", ); - Selected::Deadline + Outcome::TimedOut }, - }; - - // NOTE: A `TimedOut` or `DidNotMakeIt` error triggers the child process being killed. - match selected { - // Timed out on the child. This should already be logged by the child. - Selected::Done(Err(PrepareError::TimedOut)) => Outcome::TimedOut, - Selected::Done(result) => - Outcome::Concluded { worker: IdleWorker { stream, pid }, result }, - Selected::Deadline => Outcome::TimedOut, - Selected::IoErr => Outcome::DidNotMakeIt, } }) .await @@ -170,12 +159,13 @@ pub async fn start_work( /// NOTE: Here we know the artifact exists, but is still located in a temporary file which will be /// cleared by `with_tmp_file`. async fn handle_response_bytes( + worker: IdleWorker, response_bytes: Vec, pid: u32, tmp_file: PathBuf, artifact_path: PathBuf, preparation_timeout: Duration, -) -> Selected { +) -> Outcome { // By convention we expect encoded `PrepareResult`. let result = match PrepareResult::decode(&mut response_bytes.as_slice()) { Ok(result) => result, @@ -188,12 +178,14 @@ async fn handle_response_bytes( "received unexpected response from the prepare worker: {}", HexDisplay::from(&bound_bytes), ); - return Selected::IoErr + return Outcome::IoErr }, }; let cpu_time_elapsed = match result { Ok(result) => result, - Err(_) => return Selected::Done(result), + // Timed out on the child. This should already be logged by the child. + Err(PrepareError::TimedOut) => return Outcome::TimedOut, + Err(_) => return Outcome::Concluded { worker, result }, }; if cpu_time_elapsed > preparation_timeout { @@ -208,7 +200,10 @@ async fn handle_response_bytes( ); // Return a timeout error. - return Selected::Deadline + // + // NOTE: The artifact exists, but is located in a temporary file which + // will be cleared by `with_tmp_file`. + return Outcome::TimedOut } gum::debug!( @@ -219,10 +214,9 @@ async fn handle_response_bytes( artifact_path.display(), ); - async_std::fs::rename(&tmp_file, &artifact_path) - .await - .map(|_| Selected::Done(result)) - .unwrap_or_else(|err| { + match async_std::fs::rename(&tmp_file, &artifact_path).await { + Ok(_) => Outcome::Concluded { worker, result }, + Err(err) => { gum::warn!( target: LOG_TARGET, worker_pid = %pid, @@ -231,15 +225,16 @@ async fn handle_response_bytes( artifact_path.display(), err, ); - Selected::IoErr - }) + Outcome::RenameTmpFileErr { worker, result, err: format!("{:?}", err) } + }, + } } /// Create a temporary file for an artifact at the given cache path and execute the given /// future/closure passing the file path in. /// /// The function will try best effort to not leave behind the temporary file. -async fn with_tmp_file(pid: u32, cache_path: &Path, f: F) -> Outcome +async fn with_tmp_file(stream: UnixStream, pid: u32, cache_path: &Path, f: F) -> Outcome where Fut: futures::Future, F: FnOnce(PathBuf) -> Fut, @@ -253,7 +248,10 @@ where "failed to create a temp file for the artifact: {:?}", err, ); - return Outcome::DidNotMakeIt + return Outcome::CreateTmpFileErr { + worker: IdleWorker { stream, pid }, + err: format!("{:?}", err), + } }, }; diff --git a/node/core/pvf/src/worker_common.rs b/node/core/pvf/src/worker_common.rs index f9eaf42dcf67..e052bd77ed06 100644 --- a/node/core/pvf/src/worker_common.rs +++ b/node/core/pvf/src/worker_common.rs @@ -19,6 +19,7 @@ use crate::{execute::ExecuteResponse, PrepareError, LOG_TARGET}; use async_std::{ io, + net::Shutdown, os::unix::net::{UnixListener, UnixStream}, path::{Path, PathBuf}, }; @@ -185,7 +186,19 @@ where let stream = UnixStream::connect(socket_path).await?; let _ = async_std::fs::remove_file(socket_path).await; - event_loop(stream).await + let result = event_loop(stream.clone()).await; + + if let Err(err) = stream.shutdown(Shutdown::Both) { + // Log, but don't return error here, as it may shadow any error from `event_loop`. + gum::debug!( + target: LOG_TARGET, + "error shutting down stream at path {}: {}", + socket_path, + err + ); + } + + result }) .unwrap_err(); // it's never `Ok` because it's `Ok(Never)` diff --git a/node/network/availability-distribution/src/requester/fetch_task/mod.rs b/node/network/availability-distribution/src/requester/fetch_task/mod.rs index 89b634a5ce7e..c6356c9ccd5f 100644 --- a/node/network/availability-distribution/src/requester/fetch_task/mod.rs +++ b/node/network/availability-distribution/src/requester/fetch_task/mod.rs @@ -326,6 +326,17 @@ impl RunningTask { &mut self, validator: &AuthorityDiscoveryId, ) -> std::result::Result { + gum::trace!( + target: LOG_TARGET, + origin = ?validator, + relay_parent = ?self.relay_parent, + group_index = ?self.group_index, + session_index = ?self.session_index, + chunk_index = ?self.request.index, + candidate_hash = ?self.request.candidate_hash, + "Starting chunk request", + ); + let (full_request, response_recv) = OutgoingRequest::new(Recipient::Authority(validator.clone()), self.request); let requests = Requests::ChunkFetchingV1(full_request); @@ -346,13 +357,13 @@ impl RunningTask { Err(RequestError::InvalidResponse(err)) => { gum::warn!( target: LOG_TARGET, - origin= ?validator, + origin = ?validator, relay_parent = ?self.relay_parent, group_index = ?self.group_index, session_index = ?self.session_index, chunk_index = ?self.request.index, candidate_hash = ?self.request.candidate_hash, - err= ?err, + err = ?err, "Peer sent us invalid erasure chunk data" ); Err(TaskError::PeerError) @@ -360,13 +371,13 @@ impl RunningTask { Err(RequestError::NetworkError(err)) => { gum::debug!( target: LOG_TARGET, - origin= ?validator, + origin = ?validator, relay_parent = ?self.relay_parent, group_index = ?self.group_index, session_index = ?self.session_index, chunk_index = ?self.request.index, candidate_hash = ?self.request.candidate_hash, - err= ?err, + err = ?err, "Some network error occurred when fetching erasure chunk" ); Err(TaskError::PeerError) @@ -374,7 +385,7 @@ impl RunningTask { Err(RequestError::Canceled(oneshot::Canceled)) => { gum::debug!( target: LOG_TARGET, - origin= ?validator, + origin = ?validator, relay_parent = ?self.relay_parent, group_index = ?self.group_index, session_index = ?self.session_index, diff --git a/node/network/bridge/src/network.rs b/node/network/bridge/src/network.rs index 32dc79d25814..ec7623bb2e1d 100644 --- a/node/network/bridge/src/network.rs +++ b/node/network/bridge/src/network.rs @@ -161,6 +161,12 @@ impl Network for Arc> { let peer_id = match peer { Recipient::Peer(peer_id) => Some(peer_id), Recipient::Authority(authority) => { + gum::trace!( + target: LOG_TARGET, + ?authority, + "Searching for peer id to connect to authority", + ); + let mut found_peer_id = None; // Note: `get_addresses_by_authority_id` searched in a cache, and it thus expected // to be very quick. @@ -196,6 +202,14 @@ impl Network for Arc> { Some(peer_id) => peer_id, }; + gum::trace!( + target: LOG_TARGET, + %peer_id, + protocol = %req_protocol_names.get_name(protocol), + ?if_disconnected, + "Starting request", + ); + NetworkService::start_request( self, peer_id, diff --git a/node/overseer/Cargo.toml b/node/overseer/Cargo.toml index 092ba410a126..52310422eb4d 100644 --- a/node/overseer/Cargo.toml +++ b/node/overseer/Cargo.toml @@ -15,7 +15,7 @@ polkadot-node-primitives = { path = "../primitives" } polkadot-node-subsystem-types = { path = "../subsystem-types" } polkadot-node-metrics = { path = "../metrics" } polkadot-primitives = { path = "../../primitives" } -orchestra = "0.0.2" +orchestra = "0.0.4" gum = { package = "tracing-gum", path = "../gum" } lru = "0.8" sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -34,3 +34,4 @@ test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../pri [features] default = [] expand = ["orchestra/expand"] +dotgraph = ["orchestra/dotgraph"] diff --git a/node/overseer/src/dummy.rs b/node/overseer/src/dummy.rs index 0706244356aa..cf72774826ea 100644 --- a/node/overseer/src/dummy.rs +++ b/node/overseer/src/dummy.rs @@ -22,6 +22,9 @@ use crate::{ use lru::LruCache; use orchestra::{FromOrchestra, SpawnedSubsystem, Subsystem, SubsystemContext}; use polkadot_node_subsystem_types::{errors::SubsystemError, messages::*}; +// Generated dummy messages +use crate::messages::*; + /// A dummy subsystem that implements [`Subsystem`] for all /// types of messages. Used for tests or as a placeholder. #[derive(Clone, Copy, Debug)] diff --git a/node/overseer/src/lib.rs b/node/overseer/src/lib.rs index 78d1e1fe7889..6253f8b3e264 100644 --- a/node/overseer/src/lib.rs +++ b/node/overseer/src/lib.rs @@ -74,15 +74,16 @@ use lru::LruCache; use client::{BlockImportNotification, BlockchainEvents, FinalityNotification}; use polkadot_primitives::v2::{Block, BlockNumber, Hash}; +use self::messages::{BitfieldSigningMessage, PvfCheckerMessage}; use polkadot_node_subsystem_types::messages::{ ApprovalDistributionMessage, ApprovalVotingMessage, AvailabilityDistributionMessage, AvailabilityRecoveryMessage, AvailabilityStoreMessage, BitfieldDistributionMessage, - BitfieldSigningMessage, CandidateBackingMessage, CandidateValidationMessage, ChainApiMessage, - ChainSelectionMessage, CollationGenerationMessage, CollatorProtocolMessage, - DisputeCoordinatorMessage, DisputeDistributionMessage, GossipSupportMessage, - NetworkBridgeRxMessage, NetworkBridgeTxMessage, ProvisionerMessage, PvfCheckerMessage, - RuntimeApiMessage, StatementDistributionMessage, + CandidateBackingMessage, CandidateValidationMessage, ChainApiMessage, ChainSelectionMessage, + CollationGenerationMessage, CollatorProtocolMessage, DisputeCoordinatorMessage, + DisputeDistributionMessage, GossipSupportMessage, NetworkBridgeRxMessage, + NetworkBridgeTxMessage, ProvisionerMessage, RuntimeApiMessage, StatementDistributionMessage, }; + pub use polkadot_node_subsystem_types::{ errors::{SubsystemError, SubsystemResult}, jaeger, ActivatedLeaf, ActiveLeavesUpdate, LeafStatus, OverseerSignal, @@ -458,7 +459,7 @@ pub struct Overseer { ])] candidate_validation: CandidateValidation, - #[subsystem(PvfCheckerMessage, sends: [ + #[subsystem(sends: [ CandidateValidationMessage, RuntimeApiMessage, ])] @@ -498,7 +499,7 @@ pub struct Overseer { ])] availability_recovery: AvailabilityRecovery, - #[subsystem(blocking, BitfieldSigningMessage, sends: [ + #[subsystem(blocking, sends: [ AvailabilityStoreMessage, RuntimeApiMessage, BitfieldDistributionMessage, @@ -711,7 +712,15 @@ where } /// Run the `Overseer`. - pub async fn run(mut self) -> SubsystemResult<()> { + /// + /// Logging any errors. + pub async fn run(self) { + if let Err(err) = self.run_inner().await { + gum::error!(target: LOG_TARGET, ?err, "Overseer exited with error"); + } + } + + async fn run_inner(mut self) -> SubsystemResult<()> { let metrics = self.metrics.clone(); spawn_metronome_metrics(&mut self, metrics)?; diff --git a/node/overseer/src/tests.rs b/node/overseer/src/tests.rs index dee4c7cbbba9..ca84f033b599 100644 --- a/node/overseer/src/tests.rs +++ b/node/overseer/src/tests.rs @@ -241,7 +241,7 @@ fn overseer_metrics_work() { .unwrap(); let mut handle = Handle::new(handle); - let overseer_fut = overseer.run().fuse(); + let overseer_fut = overseer.run_inner().fuse(); pin_mut!(overseer_fut); @@ -302,7 +302,7 @@ fn overseer_ends_on_subsystem_exit() { .build() .unwrap(); - overseer.run().await.unwrap(); + overseer.run_inner().await.unwrap(); }) } @@ -400,7 +400,7 @@ fn overseer_start_stop_works() { .unwrap(); let mut handle = Handle::new(handle); - let overseer_fut = overseer.run().fuse(); + let overseer_fut = overseer.run_inner().fuse(); pin_mut!(overseer_fut); let mut ss5_results = Vec::new(); @@ -499,7 +499,7 @@ fn overseer_finalize_works() { .unwrap(); let mut handle = Handle::new(handle); - let overseer_fut = overseer.run().fuse(); + let overseer_fut = overseer.run_inner().fuse(); pin_mut!(overseer_fut); let mut ss5_results = Vec::new(); @@ -595,7 +595,7 @@ fn overseer_finalize_leaf_preserves_it() { .unwrap(); let mut handle = Handle::new(handle); - let overseer_fut = overseer.run().fuse(); + let overseer_fut = overseer.run_inner().fuse(); pin_mut!(overseer_fut); let mut ss5_results = Vec::new(); @@ -684,7 +684,7 @@ fn do_not_send_empty_leaves_update_on_block_finalization() { let mut handle = Handle::new(handle); - let overseer_fut = overseer.run().fuse(); + let overseer_fut = overseer.run_inner().fuse(); pin_mut!(overseer_fut); let mut ss5_results = Vec::new(); @@ -947,7 +947,7 @@ fn overseer_all_subsystems_receive_signals_and_messages() { .unwrap(); let mut handle = Handle::new(handle); - let overseer_fut = overseer.run().fuse(); + let overseer_fut = overseer.run_inner().fuse(); pin_mut!(overseer_fut); diff --git a/node/service/src/grandpa_support.rs b/node/service/src/grandpa_support.rs index f85249579ecf..2e31737d97c3 100644 --- a/node/service/src/grandpa_support.rs +++ b/node/service/src/grandpa_support.rs @@ -224,7 +224,7 @@ mod tests { TestClientBuilder, TestClientBuilderExt, }; use sp_blockchain::HeaderBackend; - use sp_runtime::{generic::BlockId, traits::Header}; + use sp_runtime::traits::Header; use std::sync::Arc; #[test] @@ -232,13 +232,16 @@ mod tests { let _ = env_logger::try_init(); let client = Arc::new(TestClientBuilder::new().build()); + let mut hashes = vec![]; + hashes.push(client.info().genesis_hash); let mut push_blocks = { let mut client = client.clone(); - move |n| { + move |hashes: &mut Vec<_>, n| { for _ in 0..n { let block = client.init_polkadot_block_builder().build().unwrap().block; + hashes.push(block.header.hash()); futures::executor::block_on(client.import(BlockOrigin::Own, block)).unwrap(); } } @@ -246,7 +249,7 @@ mod tests { let get_header = { let client = client.clone(); - move |n| client.header(&BlockId::Number(n)).unwrap().unwrap() + move |n| client.expect_header(n).unwrap() }; // the rule should filter all votes after block #20 @@ -254,7 +257,7 @@ mod tests { let voting_rule = super::PauseAfterBlockFor(20, 30); // add 10 blocks - push_blocks(10); + push_blocks(&mut hashes, 10); assert_eq!(client.info().best_number, 10); // we have not reached the pause block @@ -262,38 +265,38 @@ mod tests { assert_eq!( futures::executor::block_on(voting_rule.restrict_vote( client.clone(), - &get_header(0), - &get_header(10), - &get_header(10) + &get_header(hashes[0]), + &get_header(hashes[10]), + &get_header(hashes[10]) )), None, ); // add 15 more blocks // best block: #25 - push_blocks(15); + push_blocks(&mut hashes, 15); // we are targeting the pause block, // the vote should not be restricted assert_eq!( futures::executor::block_on(voting_rule.restrict_vote( client.clone(), - &get_header(10), - &get_header(20), - &get_header(20) + &get_header(hashes[10]), + &get_header(hashes[20]), + &get_header(hashes[20]) )), None, ); // we are past the pause block, votes should // be limited to the pause block. - let pause_block = get_header(20); + let pause_block = get_header(hashes[20]); assert_eq!( futures::executor::block_on(voting_rule.restrict_vote( client.clone(), - &get_header(10), - &get_header(21), - &get_header(21) + &get_header(hashes[10]), + &get_header(hashes[21]), + &get_header(hashes[21]) )), Some((pause_block.hash(), *pause_block.number())), ); @@ -304,15 +307,15 @@ mod tests { futures::executor::block_on(voting_rule.restrict_vote( client.clone(), &pause_block, // #20 - &get_header(21), - &get_header(21), + &get_header(hashes[21]), + &get_header(hashes[21]), )), Some((pause_block.hash(), *pause_block.number())), ); // add 30 more blocks // best block: #55 - push_blocks(30); + push_blocks(&mut hashes, 30); // we're at the last block of the pause, this block // should still be considered in the pause period @@ -320,8 +323,8 @@ mod tests { futures::executor::block_on(voting_rule.restrict_vote( client.clone(), &pause_block, // #20 - &get_header(50), - &get_header(50), + &get_header(hashes[50]), + &get_header(hashes[50]), )), Some((pause_block.hash(), *pause_block.number())), ); @@ -331,8 +334,8 @@ mod tests { futures::executor::block_on(voting_rule.restrict_vote( client.clone(), &pause_block, // #20 - &get_header(51), - &get_header(51), + &get_header(hashes[51]), + &get_header(hashes[51]), )), None, ); diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs index 4252474a68f5..4cd937b1d7de 100644 --- a/node/service/src/lib.rs +++ b/node/service/src/lib.rs @@ -161,10 +161,7 @@ where &self, hash: Block::Hash, ) -> sp_blockchain::Result::Header>> { - >::header( - self, - generic::BlockId::::Hash(hash), - ) + >::header(self, hash) } fn number( &self, @@ -701,7 +698,7 @@ where return None }; - let parent_hash = client.header(&BlockId::Hash(hash)).ok()??.parent_hash; + let parent_hash = client.header(hash).ok()??.parent_hash; Some(BlockInfo { hash, parent_hash, number }) }) @@ -1112,8 +1109,8 @@ where pin_mut!(forward); select! { - _ = forward => (), - _ = overseer_fut => (), + () = forward => (), + () = overseer_fut => (), complete => (), } }), diff --git a/node/subsystem-types/Cargo.toml b/node/subsystem-types/Cargo.toml index 175623dc32d8..22528503ccc4 100644 --- a/node/subsystem-types/Cargo.toml +++ b/node/subsystem-types/Cargo.toml @@ -13,7 +13,7 @@ polkadot-node-primitives = { path = "../primitives" } polkadot-node-network-protocol = { path = "../network/protocol" } polkadot-statement-table = { path = "../../statement-table" } polkadot-node-jaeger = { path = "../jaeger" } -orchestra = "0.0.2" +orchestra = "0.0.4" sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/node/subsystem-types/src/messages.rs b/node/subsystem-types/src/messages.rs index 94562ae6baef..cb0834c5ba34 100644 --- a/node/subsystem-types/src/messages.rs +++ b/node/subsystem-types/src/messages.rs @@ -473,18 +473,6 @@ impl BitfieldDistributionMessage { } } -/// Bitfield signing message. -/// -/// Currently non-instantiable. -#[derive(Debug)] -pub enum BitfieldSigningMessage {} - -impl BoundToRelayParent for BitfieldSigningMessage { - fn relay_parent(&self) -> Hash { - match *self {} - } -} - /// Availability store subsystem message. #[derive(Debug)] pub enum AvailabilityStoreMessage { @@ -950,9 +938,3 @@ pub enum GossipSupportMessage { #[from] NetworkBridgeUpdate(NetworkBridgeEvent), } - -/// PVF checker message. -/// -/// Currently non-instantiable. -#[derive(Debug)] -pub enum PvfCheckerMessage {} diff --git a/node/subsystem/src/lib.rs b/node/subsystem/src/lib.rs index ce5fef2c8b51..6d534f5fd5bd 100644 --- a/node/subsystem/src/lib.rs +++ b/node/subsystem/src/lib.rs @@ -34,6 +34,9 @@ pub use polkadot_node_subsystem_types::{ /// Re-export of all messages type, including the wrapper type. pub mod messages { pub use super::overseer::AllMessages; + // generated, empty message types + pub use super::overseer::messages::*; + // deliberately defined messages pub use polkadot_node_subsystem_types::messages::*; } diff --git a/node/test/client/src/block_builder.rs b/node/test/client/src/block_builder.rs index 1ee6d1e87dc5..058d469a26a1 100644 --- a/node/test/client/src/block_builder.rs +++ b/node/test/client/src/block_builder.rs @@ -24,7 +24,7 @@ use sp_consensus_babe::{ digests::{PreDigest, SecondaryPlainPreDigest}, BABE_ENGINE_ID, }; -use sp_runtime::{generic::BlockId, Digest, DigestItem}; +use sp_runtime::{generic::BlockId, traits::Block as BlockT, Digest, DigestItem}; use sp_state_machine::BasicExternalities; /// An extension for the test client to initialize a Polkadot specific block builder. @@ -42,20 +42,21 @@ pub trait InitPolkadotBlockBuilder { /// which should be the parent block of the block that is being build. fn init_polkadot_block_builder_at( &self, - at: &BlockId, + hash: ::Hash, ) -> sc_block_builder::BlockBuilder; } impl InitPolkadotBlockBuilder for Client { fn init_polkadot_block_builder(&self) -> BlockBuilder { let chain_info = self.chain_info(); - self.init_polkadot_block_builder_at(&BlockId::Hash(chain_info.best_hash)) + self.init_polkadot_block_builder_at(chain_info.best_hash) } fn init_polkadot_block_builder_at( &self, - at: &BlockId, + hash: ::Hash, ) -> BlockBuilder { + let at = BlockId::Hash(hash); let last_timestamp = self.runtime_api().get_last_timestamp(&at).expect("Get last timestamp"); @@ -87,7 +88,7 @@ impl InitPolkadotBlockBuilder for Client { }; let mut block_builder = self - .new_block_at(at, digest, false) + .new_block_at(&at, digest, false) .expect("Creates new block builder for test runtime"); let mut inherent_data = sp_inherents::InherentData::new(); @@ -97,7 +98,7 @@ impl InitPolkadotBlockBuilder for Client { .expect("Put timestamp inherent data"); let parent_header = self - .header(at) + .header(hash) .expect("Get the parent block header") .expect("The target block header must exist"); diff --git a/runtime/common/src/assigned_slots.rs b/runtime/common/src/assigned_slots.rs index 9be227a37352..e7da8c7407cf 100644 --- a/runtime/common/src/assigned_slots.rs +++ b/runtime/common/src/assigned_slots.rs @@ -200,6 +200,7 @@ pub mod pallet { impl Pallet { // TODO: Benchmark this /// Assign a permanent parachain slot and immediately create a lease for it. + #[pallet::call_index(0)] #[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))] pub fn assign_perm_parachain_slot(origin: OriginFor, id: ParaId) -> DispatchResult { T::AssignSlotOrigin::ensure_origin(origin)?; @@ -258,6 +259,7 @@ pub mod pallet { /// Assign a temporary parachain slot. The function tries to create a lease for it /// immediately if `SlotLeasePeriodStart::Current` is specified, and if the number /// of currently active temporary slots is below `MaxTemporarySlotPerLeasePeriod`. + #[pallet::call_index(1)] #[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))] pub fn assign_temp_parachain_slot( origin: OriginFor, @@ -341,6 +343,7 @@ pub mod pallet { // TODO: Benchmark this /// Unassign a permanent or temporary parachain slot + #[pallet::call_index(2)] #[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))] pub fn unassign_parachain_slot(origin: OriginFor, id: ParaId) -> DispatchResult { T::AssignSlotOrigin::ensure_origin(origin.clone())?; diff --git a/runtime/common/src/auctions.rs b/runtime/common/src/auctions.rs index f9181a7eac7b..bdbd9d4cae97 100644 --- a/runtime/common/src/auctions.rs +++ b/runtime/common/src/auctions.rs @@ -253,6 +253,7 @@ pub mod pallet { /// This can only happen when there isn't already an auction in progress and may only be /// called by the root origin. Accepts the `duration` of this auction and the /// `lease_period_index` of the initial lease period of the four that are to be auctioned. + #[pallet::call_index(0)] #[pallet::weight((T::WeightInfo::new_auction(), DispatchClass::Operational))] pub fn new_auction( origin: OriginFor, @@ -279,6 +280,7 @@ pub mod pallet { /// absolute lease period index value, not an auction-specific offset. /// - `amount` is the amount to bid to be held as deposit for the parachain should the /// bid win. This amount is held throughout the range. + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::bid())] pub fn bid( origin: OriginFor, @@ -296,6 +298,7 @@ pub mod pallet { /// Cancel an in-progress auction. /// /// Can only be called by Root origin. + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::cancel_auction())] pub fn cancel_auction(origin: OriginFor) -> DispatchResult { ensure_root(origin)?; diff --git a/runtime/common/src/claims.rs b/runtime/common/src/claims.rs index 1bb5b0cdc8d3..a07bf37079d3 100644 --- a/runtime/common/src/claims.rs +++ b/runtime/common/src/claims.rs @@ -305,6 +305,7 @@ pub mod pallet { /// /// Total Complexity: O(1) /// + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::claim())] pub fn claim( origin: OriginFor, @@ -337,6 +338,7 @@ pub mod pallet { /// /// Total Complexity: O(1) /// + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::mint_claim())] pub fn mint_claim( origin: OriginFor, @@ -384,6 +386,7 @@ pub mod pallet { /// /// Total Complexity: O(1) /// + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::claim_attest())] pub fn claim_attest( origin: OriginFor, @@ -420,6 +423,7 @@ pub mod pallet { /// /// Total Complexity: O(1) /// + #[pallet::call_index(3)] #[pallet::weight(( T::WeightInfo::attest(), DispatchClass::Normal, @@ -436,6 +440,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(4)] #[pallet::weight(T::WeightInfo::move_claim())] pub fn move_claim( origin: OriginFor, diff --git a/runtime/common/src/crowdloan/mod.rs b/runtime/common/src/crowdloan/mod.rs index 224f06c0d6e4..711bf0b7b33b 100644 --- a/runtime/common/src/crowdloan/mod.rs +++ b/runtime/common/src/crowdloan/mod.rs @@ -372,6 +372,7 @@ pub mod pallet { /// /// This applies a lock to your parachain configuration, ensuring that it cannot be changed /// by the parachain manager. + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::create())] pub fn create( origin: OriginFor, @@ -449,6 +450,7 @@ pub mod pallet { /// Contribute to a crowd sale. This will transfer some balance over to fund a parachain /// slot. It will be withdrawable when the crowdloan has ended and the funds are unused. + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::contribute())] pub fn contribute( origin: OriginFor, @@ -477,6 +479,7 @@ pub mod pallet { /// /// - `who`: The account whose contribution should be withdrawn. /// - `index`: The parachain to whose crowdloan the contribution was made. + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::withdraw())] pub fn withdraw( origin: OriginFor, @@ -510,6 +513,7 @@ pub mod pallet { /// times to fully refund all users. We will refund `RemoveKeysLimit` users at a time. /// /// Origin must be signed, but can come from anyone. + #[pallet::call_index(3)] #[pallet::weight(T::WeightInfo::refund(T::RemoveKeysLimit::get()))] pub fn refund( origin: OriginFor, @@ -555,6 +559,7 @@ pub mod pallet { } /// Remove a fund after the retirement period has ended and all funds have been returned. + #[pallet::call_index(4)] #[pallet::weight(T::WeightInfo::dissolve())] pub fn dissolve(origin: OriginFor, #[pallet::compact] index: ParaId) -> DispatchResult { let who = ensure_signed(origin)?; @@ -582,6 +587,7 @@ pub mod pallet { /// Edit the configuration for an in-progress crowdloan. /// /// Can only be called by Root origin. + #[pallet::call_index(5)] #[pallet::weight(T::WeightInfo::edit())] pub fn edit( origin: OriginFor, @@ -619,6 +625,7 @@ pub mod pallet { /// Add an optional memo to an existing crowdloan contribution. /// /// Origin must be Signed, and the user must have contributed to the crowdloan. + #[pallet::call_index(6)] #[pallet::weight(T::WeightInfo::add_memo())] pub fn add_memo(origin: OriginFor, index: ParaId, memo: Vec) -> DispatchResult { let who = ensure_signed(origin)?; @@ -637,6 +644,7 @@ pub mod pallet { /// Poke the fund into `NewRaise` /// /// Origin must be Signed, and the fund has non-zero raise. + #[pallet::call_index(7)] #[pallet::weight(T::WeightInfo::poke())] pub fn poke(origin: OriginFor, index: ParaId) -> DispatchResult { ensure_signed(origin)?; @@ -650,6 +658,7 @@ pub mod pallet { /// Contribute your entire balance to a crowd sale. This will transfer the entire balance of a user over to fund a parachain /// slot. It will be withdrawable when the crowdloan has ended and the funds are unused. + #[pallet::call_index(8)] #[pallet::weight(T::WeightInfo::contribute())] pub fn contribute_all( origin: OriginFor, diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index 5dab30cedf85..eac66871e6ee 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -228,6 +228,7 @@ pub mod pallet { /// /// ## Events /// The `Registered` event is emitted in case of success. + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::register())] pub fn register( origin: OriginFor, @@ -246,6 +247,7 @@ pub mod pallet { /// /// The deposit taken can be specified for this registration. Any `ParaId` /// can be registered, including sub-1000 IDs which are System Parachains. + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::force_register())] pub fn force_register( origin: OriginFor, @@ -262,6 +264,7 @@ pub mod pallet { /// Deregister a Para Id, freeing all data and returning any deposit. /// /// The caller must be Root, the `para` owner, or the `para` itself. The para must be a parathread. + #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::deregister())] pub fn deregister(origin: OriginFor, id: ParaId) -> DispatchResult { Self::ensure_root_para_or_owner(origin, id)?; @@ -279,6 +282,7 @@ pub mod pallet { /// `ParaId` to be a long-term identifier of a notional "parachain". However, their /// scheduling info (i.e. whether they're a parathread or parachain), auction information /// and the auction deposit are switched. + #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::swap())] pub fn swap(origin: OriginFor, id: ParaId, other: ParaId) -> DispatchResult { Self::ensure_root_para_or_owner(origin, id)?; @@ -328,6 +332,7 @@ pub mod pallet { /// previously locked para to deregister or swap a para without using governance. /// /// Can only be called by the Root origin or the parachain. + #[pallet::call_index(4)] #[pallet::weight(T::DbWeight::get().reads_writes(1, 1))] pub fn remove_lock(origin: OriginFor, para: ParaId) -> DispatchResult { Self::ensure_root_or_para(origin, para)?; @@ -349,6 +354,7 @@ pub mod pallet { /// /// ## Events /// The `Reserved` event is emitted in case of success, which provides the ID reserved for use. + #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::reserve())] pub fn reserve(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; @@ -362,6 +368,7 @@ pub mod pallet { /// para to deregister or swap a para. /// /// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked. + #[pallet::call_index(6)] #[pallet::weight(T::DbWeight::get().reads_writes(1, 1))] pub fn add_lock(origin: OriginFor, para: ParaId) -> DispatchResult { Self::ensure_root_para_or_owner(origin, para)?; @@ -372,6 +379,7 @@ pub mod pallet { /// Schedule a parachain upgrade. /// /// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked. + #[pallet::call_index(7)] #[pallet::weight(::WeightInfo::schedule_code_upgrade(new_code.0.len() as u32))] pub fn schedule_code_upgrade( origin: OriginFor, @@ -386,6 +394,7 @@ pub mod pallet { /// Set the parachain's current head. /// /// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked. + #[pallet::call_index(8)] #[pallet::weight(::WeightInfo::set_current_head(new_head.0.len() as u32))] pub fn set_current_head( origin: OriginFor, diff --git a/runtime/common/src/paras_sudo_wrapper.rs b/runtime/common/src/paras_sudo_wrapper.rs index 49f27a8d44c3..8cb402c0930e 100644 --- a/runtime/common/src/paras_sudo_wrapper.rs +++ b/runtime/common/src/paras_sudo_wrapper.rs @@ -70,6 +70,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Schedule a para to be initialized at the start of the next session. + #[pallet::call_index(0)] #[pallet::weight((1_000, DispatchClass::Operational))] pub fn sudo_schedule_para_initialize( origin: OriginFor, @@ -83,6 +84,7 @@ pub mod pallet { } /// Schedule a para to be cleaned up at the start of the next session. + #[pallet::call_index(1)] #[pallet::weight((1_000, DispatchClass::Operational))] pub fn sudo_schedule_para_cleanup(origin: OriginFor, id: ParaId) -> DispatchResult { ensure_root(origin)?; @@ -92,6 +94,7 @@ pub mod pallet { } /// Upgrade a parathread to a parachain + #[pallet::call_index(2)] #[pallet::weight((1_000, DispatchClass::Operational))] pub fn sudo_schedule_parathread_upgrade( origin: OriginFor, @@ -109,6 +112,7 @@ pub mod pallet { } /// Downgrade a parachain to a parathread + #[pallet::call_index(3)] #[pallet::weight((1_000, DispatchClass::Operational))] pub fn sudo_schedule_parachain_downgrade( origin: OriginFor, @@ -129,6 +133,7 @@ pub mod pallet { /// /// The given parachain should exist and the payload should not exceed the preconfigured size /// `config.max_downward_message_size`. + #[pallet::call_index(4)] #[pallet::weight((1_000, DispatchClass::Operational))] pub fn sudo_queue_downward_xcm( origin: OriginFor, @@ -149,6 +154,7 @@ pub mod pallet { /// /// This is equivalent to sending an `Hrmp::hrmp_init_open_channel` extrinsic followed by /// `Hrmp::hrmp_accept_open_channel`. + #[pallet::call_index(5)] #[pallet::weight((1_000, DispatchClass::Operational))] pub fn sudo_establish_hrmp_channel( origin: OriginFor, diff --git a/runtime/common/src/purchase.rs b/runtime/common/src/purchase.rs index 52ad22bec2fb..dcc3f1e2b5c5 100644 --- a/runtime/common/src/purchase.rs +++ b/runtime/common/src/purchase.rs @@ -195,6 +195,7 @@ pub mod pallet { /// We check that the account does not exist at this stage. /// /// Origin must match the `ValidityOrigin`. + #[pallet::call_index(0)] #[pallet::weight(Weight::from_ref_time(200_000_000) + T::DbWeight::get().reads_writes(4, 1))] pub fn create_account( origin: OriginFor, @@ -232,6 +233,7 @@ pub mod pallet { /// We check that the account exists at this stage, but has not completed the process. /// /// Origin must match the `ValidityOrigin`. + #[pallet::call_index(1)] #[pallet::weight(T::DbWeight::get().reads_writes(1, 1))] pub fn update_validity_status( origin: OriginFor, @@ -260,6 +262,7 @@ pub mod pallet { /// We check that the account is valid for a balance transfer at this point. /// /// Origin must match the `ValidityOrigin`. + #[pallet::call_index(2)] #[pallet::weight(T::DbWeight::get().reads_writes(2, 1))] pub fn update_balance( origin: OriginFor, @@ -297,6 +300,7 @@ pub mod pallet { /// /// Origin must match the configured `PaymentAccount` (if it is not configured then this /// will always fail with `BadOrigin`). + #[pallet::call_index(3)] #[pallet::weight(T::DbWeight::get().reads_writes(4, 2))] pub fn payout(origin: OriginFor, who: T::AccountId) -> DispatchResult { // Payments must be made directly by the `PaymentAccount`. @@ -366,6 +370,7 @@ pub mod pallet { /// Set the account that will be used to payout users in the DOT purchase process. /// /// Origin must match the `ConfigurationOrigin` + #[pallet::call_index(4)] #[pallet::weight(T::DbWeight::get().writes(1))] pub fn set_payment_account(origin: OriginFor, who: T::AccountId) -> DispatchResult { T::ConfigurationOrigin::ensure_origin(origin)?; @@ -378,6 +383,7 @@ pub mod pallet { /// Set the statement that must be signed for a user to participate on the DOT sale. /// /// Origin must match the `ConfigurationOrigin` + #[pallet::call_index(5)] #[pallet::weight(T::DbWeight::get().writes(1))] pub fn set_statement(origin: OriginFor, statement: Vec) -> DispatchResult { T::ConfigurationOrigin::ensure_origin(origin)?; @@ -394,6 +400,7 @@ pub mod pallet { /// Set the block where locked DOTs will become unlocked. /// /// Origin must match the `ConfigurationOrigin` + #[pallet::call_index(6)] #[pallet::weight(T::DbWeight::get().writes(1))] pub fn set_unlock_block( origin: OriginFor, diff --git a/runtime/common/src/slots/mod.rs b/runtime/common/src/slots/mod.rs index 21391dc3d774..62637d582b55 100644 --- a/runtime/common/src/slots/mod.rs +++ b/runtime/common/src/slots/mod.rs @@ -165,6 +165,7 @@ pub mod pallet { /// independently of any other on-chain mechanism to use it. /// /// The dispatch origin for this call must match `T::ForceOrigin`. + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::force_lease())] pub fn force_lease( origin: OriginFor, @@ -183,6 +184,7 @@ pub mod pallet { /// Clear all leases for a Para Id, refunding any deposits back to the original owners. /// /// The dispatch origin for this call must match `T::ForceOrigin`. + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::clear_all_leases())] pub fn clear_all_leases(origin: OriginFor, para: ParaId) -> DispatchResult { T::ForceOrigin::ensure_origin(origin)?; @@ -205,6 +207,7 @@ pub mod pallet { /// let them onboard from here. /// /// Origin must be signed, but can be called by anyone. + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::trigger_onboard())] pub fn trigger_onboard(origin: OriginFor, para: ParaId) -> DispatchResult { let _ = ensure_signed(origin)?; diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index 113fad1d7a57..2f09deb34ded 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -521,6 +521,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Set the validation upgrade cooldown. + #[pallet::call_index(0)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -536,6 +537,7 @@ pub mod pallet { } /// Set the validation upgrade delay. + #[pallet::call_index(1)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -551,6 +553,7 @@ pub mod pallet { } /// Set the acceptance period for an included candidate. + #[pallet::call_index(2)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -566,6 +569,7 @@ pub mod pallet { } /// Set the max validation code size for incoming upgrades. + #[pallet::call_index(3)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -578,6 +582,7 @@ pub mod pallet { } /// Set the max POV block size for incoming upgrades. + #[pallet::call_index(4)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -590,6 +595,7 @@ pub mod pallet { } /// Set the max head data size for paras. + #[pallet::call_index(5)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -602,6 +608,7 @@ pub mod pallet { } /// Set the number of parathread execution cores. + #[pallet::call_index(6)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -614,6 +621,7 @@ pub mod pallet { } /// Set the number of retries for a particular parathread. + #[pallet::call_index(7)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -626,6 +634,7 @@ pub mod pallet { } /// Set the parachain validator-group rotation frequency + #[pallet::call_index(8)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -641,6 +650,7 @@ pub mod pallet { } /// Set the availability period for parachains. + #[pallet::call_index(9)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -656,6 +666,7 @@ pub mod pallet { } /// Set the availability period for parathreads. + #[pallet::call_index(10)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -671,6 +682,7 @@ pub mod pallet { } /// Set the scheduling lookahead, in expected number of blocks at peak throughput. + #[pallet::call_index(11)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -683,6 +695,7 @@ pub mod pallet { } /// Set the maximum number of validators to assign to any core. + #[pallet::call_index(12)] #[pallet::weight(( T::WeightInfo::set_config_with_option_u32(), DispatchClass::Operational, @@ -698,6 +711,7 @@ pub mod pallet { } /// Set the maximum number of validators to use in parachain consensus. + #[pallet::call_index(13)] #[pallet::weight(( T::WeightInfo::set_config_with_option_u32(), DispatchClass::Operational, @@ -710,6 +724,7 @@ pub mod pallet { } /// Set the dispute period, in number of sessions to keep for disputes. + #[pallet::call_index(14)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -722,6 +737,7 @@ pub mod pallet { } /// Set the dispute post conclusion acceptance period. + #[pallet::call_index(15)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -737,6 +753,7 @@ pub mod pallet { } /// Set the maximum number of dispute spam slots. + #[pallet::call_index(16)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -749,6 +766,7 @@ pub mod pallet { } /// Set the dispute conclusion by time out period. + #[pallet::call_index(17)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -765,6 +783,7 @@ pub mod pallet { /// Set the no show slots, in number of number of consensus slots. /// Must be at least 1. + #[pallet::call_index(18)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -777,6 +796,7 @@ pub mod pallet { } /// Set the total number of delay tranches. + #[pallet::call_index(19)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -789,6 +809,7 @@ pub mod pallet { } /// Set the zeroth delay tranche width. + #[pallet::call_index(20)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -801,6 +822,7 @@ pub mod pallet { } /// Set the number of validators needed to approve a block. + #[pallet::call_index(21)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -813,6 +835,7 @@ pub mod pallet { } /// Set the number of samples to do of the `RelayVRFModulo` approval assignment criterion. + #[pallet::call_index(22)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -825,6 +848,7 @@ pub mod pallet { } /// Sets the maximum items that can present in a upward dispatch queue at once. + #[pallet::call_index(23)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -837,6 +861,7 @@ pub mod pallet { } /// Sets the maximum total size of items that can present in a upward dispatch queue at once. + #[pallet::call_index(24)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -849,6 +874,7 @@ pub mod pallet { } /// Set the critical downward message size. + #[pallet::call_index(25)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -861,6 +887,7 @@ pub mod pallet { } /// Sets the soft limit for the phase of dispatching dispatchable upward messages. + #[pallet::call_index(26)] #[pallet::weight(( T::WeightInfo::set_config_with_weight(), DispatchClass::Operational, @@ -873,6 +900,7 @@ pub mod pallet { } /// Sets the maximum size of an upward message that can be sent by a candidate. + #[pallet::call_index(27)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -885,6 +913,7 @@ pub mod pallet { } /// Sets the maximum number of messages that a candidate can contain. + #[pallet::call_index(28)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -900,6 +929,7 @@ pub mod pallet { } /// Sets the number of sessions after which an HRMP open channel request expires. + #[pallet::call_index(29)] #[pallet::weight(( T::WeightInfo::set_hrmp_open_request_ttl(), DispatchClass::Operational, @@ -911,6 +941,7 @@ pub mod pallet { } /// Sets the amount of funds that the sender should provide for opening an HRMP channel. + #[pallet::call_index(30)] #[pallet::weight(( T::WeightInfo::set_config_with_balance(), DispatchClass::Operational, @@ -924,6 +955,7 @@ pub mod pallet { /// Sets the amount of funds that the recipient should provide for accepting opening an HRMP /// channel. + #[pallet::call_index(31)] #[pallet::weight(( T::WeightInfo::set_config_with_balance(), DispatchClass::Operational, @@ -936,6 +968,7 @@ pub mod pallet { } /// Sets the maximum number of messages allowed in an HRMP channel at once. + #[pallet::call_index(32)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -948,6 +981,7 @@ pub mod pallet { } /// Sets the maximum total size of messages in bytes allowed in an HRMP channel at once. + #[pallet::call_index(33)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -960,6 +994,7 @@ pub mod pallet { } /// Sets the maximum number of inbound HRMP channels a parachain is allowed to accept. + #[pallet::call_index(34)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -975,6 +1010,7 @@ pub mod pallet { } /// Sets the maximum number of inbound HRMP channels a parathread is allowed to accept. + #[pallet::call_index(35)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -990,6 +1026,7 @@ pub mod pallet { } /// Sets the maximum size of a message that could ever be put into an HRMP channel. + #[pallet::call_index(36)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -1002,6 +1039,7 @@ pub mod pallet { } /// Sets the maximum number of outbound HRMP channels a parachain is allowed to open. + #[pallet::call_index(37)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -1017,6 +1055,7 @@ pub mod pallet { } /// Sets the maximum number of outbound HRMP channels a parathread is allowed to open. + #[pallet::call_index(38)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -1032,6 +1071,7 @@ pub mod pallet { } /// Sets the maximum number of outbound HRMP messages can be sent by a candidate. + #[pallet::call_index(39)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -1047,6 +1087,7 @@ pub mod pallet { } /// Sets the maximum amount of weight any individual upward message may consume. + #[pallet::call_index(40)] #[pallet::weight(( T::WeightInfo::set_config_with_weight(), DispatchClass::Operational, @@ -1059,6 +1100,7 @@ pub mod pallet { } /// Enable or disable PVF pre-checking. Consult the field documentation prior executing. + #[pallet::call_index(41)] #[pallet::weight(( // Using u32 here is a little bit of cheating, but that should be fine. T::WeightInfo::set_config_with_u32(), @@ -1072,6 +1114,7 @@ pub mod pallet { } /// Set the number of session changes after which a PVF pre-checking voting is rejected. + #[pallet::call_index(42)] #[pallet::weight(( T::WeightInfo::set_config_with_u32(), DispatchClass::Operational, @@ -1087,6 +1130,7 @@ pub mod pallet { /// upgrade taking place. /// /// See the field documentation for information and constraints for the new value. + #[pallet::call_index(43)] #[pallet::weight(( T::WeightInfo::set_config_with_block_number(), DispatchClass::Operational, @@ -1103,6 +1147,7 @@ pub mod pallet { /// Setting this to true will disable consistency checks for the configuration setters. /// Use with caution. + #[pallet::call_index(44)] #[pallet::weight(( T::DbWeight::get().writes(1), DispatchClass::Operational, diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 084564ca656a..0f88dd35494f 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -525,6 +525,7 @@ pub mod pallet { #[pallet::call] impl Pallet { + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::force_unfreeze())] pub fn force_unfreeze(origin: OriginFor) -> DispatchResult { ensure_root(origin)?; diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 2dfdc87c4b4e..419db8654d89 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -475,6 +475,7 @@ pub mod pallet { #[pallet::call] impl Pallet { + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::report_dispute_lost( key_owner_proof.validator_count() ))] diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index ed8e554bc498..4476f1f4a4da 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -465,6 +465,7 @@ pub mod pallet { /// /// The channel can be opened only after the recipient confirms it and only on a session /// change. + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::hrmp_init_open_channel())] pub fn hrmp_init_open_channel( origin: OriginFor, @@ -491,6 +492,7 @@ pub mod pallet { /// Accept a pending open channel request from the given sender. /// /// The channel will be opened only on the next session boundary. + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::hrmp_accept_open_channel())] pub fn hrmp_accept_open_channel(origin: OriginFor, sender: ParaId) -> DispatchResult { let origin = ensure_parachain(::RuntimeOrigin::from(origin))?; @@ -503,6 +505,7 @@ pub mod pallet { /// recipient in the channel being closed. /// /// The closure can only happen on a session change. + #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::hrmp_close_channel())] pub fn hrmp_close_channel( origin: OriginFor, @@ -521,6 +524,7 @@ pub mod pallet { /// Origin must be Root. /// /// Number of inbound and outbound channels for `para` must be provided as witness data of weighing. + #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::force_clean_hrmp(*_inbound, *_outbound))] pub fn force_clean_hrmp( origin: OriginFor, @@ -539,6 +543,7 @@ pub mod pallet { /// function process all of those requests immediately. /// /// Total number of opening channels must be provided as witness data of weighing. + #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::force_process_hrmp_open(*_channels))] pub fn force_process_hrmp_open(origin: OriginFor, _channels: u32) -> DispatchResult { ensure_root(origin)?; @@ -553,6 +558,7 @@ pub mod pallet { /// function process all of those requests immediately. /// /// Total number of closing channels must be provided as witness data of weighing. + #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::force_process_hrmp_close(*_channels))] pub fn force_process_hrmp_close(origin: OriginFor, _channels: u32) -> DispatchResult { ensure_root(origin)?; @@ -568,6 +574,7 @@ pub mod pallet { /// /// Total number of open requests (i.e. `HrmpOpenChannelRequestsList`) must be provided as /// witness data. + #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::hrmp_cancel_open_request(*open_requests))] pub fn hrmp_cancel_open_request( origin: OriginFor, @@ -591,6 +598,7 @@ pub mod pallet { /// /// Expected use is when one of the `ParaId`s involved in the channel is governed by the /// Relay Chain, e.g. a common good parachain. + #[pallet::call_index(7)] #[pallet::weight(::WeightInfo::force_open_hrmp_channel())] pub fn force_open_hrmp_channel( origin: OriginFor, diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index ef00e5b884cc..85546559b7de 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -210,6 +210,7 @@ pub mod pallet { /// Issue a signal to the consensus engine to forcibly act as though all parachain /// blocks in all relay chain blocks up to and including the given number in the current /// chain are valid and should be finalized. + #[pallet::call_index(0)] #[pallet::weight(( ::WeightInfo::force_approve( frame_system::Pallet::::digest().logs.len() as u32, diff --git a/runtime/parachains/src/paras/mod.rs b/runtime/parachains/src/paras/mod.rs index 7fa76e3f41e2..8f7739f04b74 100644 --- a/runtime/parachains/src/paras/mod.rs +++ b/runtime/parachains/src/paras/mod.rs @@ -788,6 +788,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Set the storage for the parachain validation code immediately. + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::force_set_current_code(new_code.0.len() as u32))] pub fn force_set_current_code( origin: OriginFor, @@ -815,6 +816,7 @@ pub mod pallet { } /// Set the storage for the current parachain head data immediately. + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::force_set_current_head(new_head.0.len() as u32))] pub fn force_set_current_head( origin: OriginFor, @@ -827,6 +829,7 @@ pub mod pallet { } /// Schedule an upgrade as if it was scheduled in the given relay parent block. + #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::force_schedule_code_upgrade(new_code.0.len() as u32))] pub fn force_schedule_code_upgrade( origin: OriginFor, @@ -842,6 +845,7 @@ pub mod pallet { } /// Note a new block head for para within the context of the current block. + #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::force_note_new_head(new_head.0.len() as u32))] pub fn force_note_new_head( origin: OriginFor, @@ -858,6 +862,7 @@ pub mod pallet { /// Put a parachain directly into the next session's action queue. /// We can't queue it any sooner than this without going into the /// initializer... + #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::force_queue_action())] pub fn force_queue_action(origin: OriginFor, para: ParaId) -> DispatchResult { ensure_root(origin)?; @@ -884,6 +889,7 @@ pub mod pallet { /// /// This function is mainly meant to be used for upgrading parachains that do not follow /// the go-ahead signal while the PVF pre-checking feature is enabled. + #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::add_trusted_validation_code(validation_code.0.len() as u32))] pub fn add_trusted_validation_code( origin: OriginFor, @@ -932,6 +938,7 @@ pub mod pallet { /// This is better than removing the storage directly, because it will not remove the code /// that was suddenly got used by some parachain while this dispatchable was pending /// dispatching. + #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::poke_unused_validation_code())] pub fn poke_unused_validation_code( origin: OriginFor, @@ -946,6 +953,7 @@ pub mod pallet { /// Includes a statement for a PVF pre-checking vote. Potentially, finalizes the vote and /// enacts the results if that was the last vote before achieving the supermajority. + #[pallet::call_index(7)] #[pallet::weight( ::WeightInfo::include_pvf_check_statement_finalize_upgrade_accept() .max(::WeightInfo::include_pvf_check_statement_finalize_upgrade_reject()) diff --git a/runtime/parachains/src/paras_inherent/mod.rs b/runtime/parachains/src/paras_inherent/mod.rs index a053e3dbfaf9..15669ec9c15d 100644 --- a/runtime/parachains/src/paras_inherent/mod.rs +++ b/runtime/parachains/src/paras_inherent/mod.rs @@ -277,6 +277,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Enter the paras inherent. This will process bitfields and backed candidates. + #[pallet::call_index(0)] #[pallet::weight(( paras_inherent_total_weight::( data.backed_candidates.as_slice(), diff --git a/runtime/parachains/src/ump.rs b/runtime/parachains/src/ump.rs index 5bcdc6cd7bc7..bcce8ddab692 100644 --- a/runtime/parachains/src/ump.rs +++ b/runtime/parachains/src/ump.rs @@ -351,6 +351,7 @@ pub mod pallet { /// /// Events: /// - `OverweightServiced`: On success. + #[pallet::call_index(0)] #[pallet::weight(weight_limit.saturating_add(::WeightInfo::service_overweight()))] pub fn service_overweight( origin: OriginFor, diff --git a/runtime/rococo/src/validator_manager.rs b/runtime/rococo/src/validator_manager.rs index bb13bc823ca4..55b1878cbc7f 100644 --- a/runtime/rococo/src/validator_manager.rs +++ b/runtime/rococo/src/validator_manager.rs @@ -66,6 +66,7 @@ pub mod pallet { /// Add new validators to the set. /// /// The new validators will be active from current session + 2. + #[pallet::call_index(0)] #[pallet::weight(100_000)] pub fn register_validators( origin: OriginFor, @@ -82,6 +83,7 @@ pub mod pallet { /// Remove validators from the set. /// /// The removed validators will be deactivated from current session + 2. + #[pallet::call_index(1)] #[pallet::weight(100_000)] pub fn deregister_validators( origin: OriginFor, diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index f049bf90899e..c55bdf7f542e 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -593,6 +593,7 @@ pub mod pallet_test_notifier { #[pallet::call] impl Pallet { + #[pallet::call_index(0)] #[pallet::weight(1_000_000)] pub fn prepare_new_query(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; @@ -608,6 +609,7 @@ pub mod pallet_test_notifier { Ok(()) } + #[pallet::call_index(1)] #[pallet::weight(1_000_000)] pub fn prepare_new_notify_query(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; @@ -626,6 +628,7 @@ pub mod pallet_test_notifier { Ok(()) } + #[pallet::call_index(2)] #[pallet::weight(1_000_000)] pub fn notification_received( origin: OriginFor, diff --git a/scripts/ci/gitlab/pipeline/check.yml b/scripts/ci/gitlab/pipeline/check.yml index f443e76d6779..44185d6f4ca7 100644 --- a/scripts/ci/gitlab/pipeline/check.yml +++ b/scripts/ci/gitlab/pipeline/check.yml @@ -68,7 +68,12 @@ check-try-runtime: echo "Found label runtimemigration. Running tests" export RUST_LOG=remote-ext=debug,runtime=debug echo "---------- Running try-runtime for ${NETWORK} ----------" - time cargo run --release --features=try-runtime try-runtime --chain=${NETWORK}-dev --execution=Wasm --no-spec-check-panic on-runtime-upgrade live --uri wss://${NETWORK}-try-runtime-node.parity-chains.parity.io:443 + time cargo build --release -p "$NETWORK"-runtime + time cargo run --release --features try-runtime try-runtime \ + --runtime ./target/release/wbuild/"$NETWORK"-runtime/target/wasm32-unknown-unknown/release/"$NETWORK"_runtime.wasm \ + -lruntime=debug \ + --chain=${NETWORK}-dev \ + on-runtime-upgrade live --uri wss://${NETWORK}-try-runtime-node.parity-chains.parity.io:443 else echo "runtimemigration label not found. Skipping" fi diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index f8e483d1b7a9..628d010d0a4e 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -745,6 +745,7 @@ pub mod pallet { #[pallet::call] impl Pallet { + #[pallet::call_index(0)] #[pallet::weight({ let maybe_msg: Result, ()> = (*message.clone()).try_into(); match maybe_msg { @@ -786,6 +787,7 @@ pub mod pallet { /// `dest` side. May not be empty. /// - `fee_asset_item`: The index into `assets` of the item which should be used to pay /// fees. + #[pallet::call_index(1)] #[pallet::weight({ let maybe_assets: Result = (*assets.clone()).try_into(); let maybe_dest: Result = (*dest.clone()).try_into(); @@ -832,6 +834,7 @@ pub mod pallet { /// `dest` side. /// - `fee_asset_item`: The index into `assets` of the item which should be used to pay /// fees. + #[pallet::call_index(2)] #[pallet::weight({ let maybe_assets: Result = (*assets.clone()).try_into(); let maybe_dest: Result = (*dest.clone()).try_into(); @@ -874,6 +877,7 @@ pub mod pallet { /// /// NOTE: A successful return to this does *not* imply that the `msg` was executed successfully /// to completion; only that *some* of it was executed. + #[pallet::call_index(3)] #[pallet::weight(max_weight.saturating_add(T::WeightInfo::execute()))] pub fn execute( origin: OriginFor, @@ -905,6 +909,7 @@ pub mod pallet { /// - `origin`: Must be Root. /// - `location`: The destination that is being described. /// - `xcm_version`: The latest version of XCM that `location` supports. + #[pallet::call_index(4)] #[pallet::weight(T::WeightInfo::force_xcm_version())] pub fn force_xcm_version( origin: OriginFor, @@ -927,6 +932,7 @@ pub mod pallet { /// /// - `origin`: Must be Root. /// - `maybe_xcm_version`: The default XCM encoding version, or `None` to disable. + #[pallet::call_index(5)] #[pallet::weight(T::WeightInfo::force_default_xcm_version())] pub fn force_default_xcm_version( origin: OriginFor, @@ -941,6 +947,7 @@ pub mod pallet { /// /// - `origin`: Must be Root. /// - `location`: The location to which we should subscribe for XCM version notifications. + #[pallet::call_index(6)] #[pallet::weight(T::WeightInfo::force_subscribe_version_notify())] pub fn force_subscribe_version_notify( origin: OriginFor, @@ -964,6 +971,7 @@ pub mod pallet { /// - `origin`: Must be Root. /// - `location`: The location to which we are currently subscribed for XCM version /// notifications which we no longer desire. + #[pallet::call_index(7)] #[pallet::weight(T::WeightInfo::force_unsubscribe_version_notify())] pub fn force_unsubscribe_version_notify( origin: OriginFor, @@ -999,6 +1007,7 @@ pub mod pallet { /// - `fee_asset_item`: The index into `assets` of the item which should be used to pay /// fees. /// - `weight_limit`: The remote-side weight limit, if any, for the XCM fee purchase. + #[pallet::call_index(8)] #[pallet::weight({ let maybe_assets: Result = (*assets.clone()).try_into(); let maybe_dest: Result = (*dest.clone()).try_into(); @@ -1048,6 +1057,7 @@ pub mod pallet { /// - `fee_asset_item`: The index into `assets` of the item which should be used to pay /// fees. /// - `weight_limit`: The remote-side weight limit, if any, for the XCM fee purchase. + #[pallet::call_index(9)] #[pallet::weight({ let maybe_assets: Result = (*assets.clone()).try_into(); let maybe_dest: Result = (*dest.clone()).try_into(); diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 0681f77ba314..3c9184898f63 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -78,6 +78,7 @@ pub mod pallet_test_notifier { #[pallet::call] impl Pallet { + #[pallet::call_index(0)] #[pallet::weight(Weight::from_parts(1_000_000, 1_000_000))] pub fn prepare_new_query(origin: OriginFor, querier: MultiLocation) -> DispatchResult { let who = ensure_signed(origin)?; @@ -93,6 +94,7 @@ pub mod pallet_test_notifier { Ok(()) } + #[pallet::call_index(1)] #[pallet::weight(Weight::from_parts(1_000_000, 1_000_000))] pub fn prepare_new_notify_query( origin: OriginFor, @@ -114,6 +116,7 @@ pub mod pallet_test_notifier { Ok(()) } + #[pallet::call_index(2)] #[pallet::weight(Weight::from_parts(1_000_000, 1_000_000))] pub fn notification_received( origin: OriginFor, From 4ccf61a6f867a82100c1054a4e52f1b145d954c8 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 22 Dec 2022 22:26:07 +0900 Subject: [PATCH 200/231] Fixes --- runtime/kusama/src/xcm_config.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index ec9464cddcf5..6d00100617f7 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -17,8 +17,9 @@ //! XCM configurations for the Kusama runtime. use super::{ - parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, ParaId, - Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet, + parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, Fellows, + ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, + XcmPallet, }; use frame_support::{ match_types, parameter_types, From 7218adf67f1c01519ffabf24be5a40f9a8cd0d0c Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 23 Dec 2022 00:18:51 +0100 Subject: [PATCH 201/231] Fix comments (#6470) --- runtime/rococo/src/weights/xcm/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/rococo/src/weights/xcm/mod.rs b/runtime/rococo/src/weights/xcm/mod.rs index 9fb5941b80fe..d1b8afd750ed 100644 --- a/runtime/rococo/src/weights/xcm/mod.rs +++ b/runtime/rococo/src/weights/xcm/mod.rs @@ -217,26 +217,26 @@ impl XcmWeightInfo for RococoXcmWeight { XcmGeneric::::clear_transact_status() } fn universal_origin(_: &Junction) -> Weight { - // Kusama does not currently support universal origin operations + // Rococo does not currently support universal origin operations Weight::MAX } fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { Weight::MAX // todo fix } fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { - // Kusama does not currently support asset locking operations + // Rococo does not currently support asset locking operations Weight::MAX } fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { - // Kusama does not currently support asset locking operations + // Rococo does not currently support asset locking operations Weight::MAX } fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { - // Kusama does not currently support asset locking operations + // Rococo does not currently support asset locking operations Weight::MAX } fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { - // Kusama does not currently support asset locking operations + // Rococo does not currently support asset locking operations Weight::MAX } fn set_fees_mode(_: &bool) -> Weight { From c223f710b39c7708f72eaab9894fdc76ca4673a6 Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Thu, 5 Jan 2023 17:57:56 +0200 Subject: [PATCH 202/231] Specify Ethereum networks by their chain id (#6286) Co-authored-by: Squirrel --- xcm/src/v3/junction.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xcm/src/v3/junction.rs b/xcm/src/v3/junction.rs index e3c8b9a684e2..7c1050624477 100644 --- a/xcm/src/v3/junction.rs +++ b/xcm/src/v3/junction.rs @@ -51,10 +51,12 @@ pub enum NetworkId { Rococo, /// The Wococo testnet Relay-chain. Wococo, - /// The Ethereum network, including hard-forks supported by the Ethereum Foundation. - EthereumFoundation, - /// The Ethereum network, including hard-forks supported by Ethereum Classic developers. - EthereumClassic, + /// An Ethereum network specified by its chain ID. + Ethereum { + /// The EIP-155 chain ID. + #[codec(compact)] + chain_id: u64, + }, /// The Bitcoin network, including hard-forks supported by Bitcoin Core development team. BitcoinCore, /// The Bitcoin network, including hard-forks supported by Bitcoin Cash developers. From 49b1999f20ed37f5f24bd734964ff41e6cf3356e Mon Sep 17 00:00:00 2001 From: Gav Date: Fri, 6 Jan 2023 15:48:13 +0000 Subject: [PATCH 203/231] Use for Kusama --- runtime/kusama/src/xcm_config.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 6d00100617f7..b14576d43c92 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -27,6 +27,7 @@ use frame_support::{ weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; +use sp_core::ConstU32; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -35,6 +36,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, + WithComputedOrigin, }; use xcm_executor::traits::WithOriginFilter; @@ -129,14 +131,20 @@ match_types! { pub type Barrier = ( // Weight that is paid for may be consumed. TakeWeightCredit, - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Messages coming from system parachains need not pay for execution. - AllowExplicitUnpaidExecutionFrom>, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Messages coming from system parachains need not pay for execution. + AllowExplicitUnpaidExecutionFrom>, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); /// A call filter for the XCM Transact instruction. This is a temporary measure until we properly From e3151f3245020a4b78579a1d0c2ff63a77e1ff1e Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 7 Jan 2023 01:23:11 +0900 Subject: [PATCH 204/231] Use WithComputedOrigin for Polkadot, Rococo and Westend --- runtime/kusama/src/xcm_config.rs | 2 +- runtime/polkadot/src/xcm_config.rs | 19 +++++++++++++------ runtime/rococo/src/xcm_config.rs | 23 +++++++++++++++-------- runtime/westend/src/xcm_config.rs | 23 +++++++++++++++-------- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index b14576d43c92..05e99a9b6903 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -444,7 +444,7 @@ impl pallet_xcm::Config for Runtime { type CurrencyMatcher = (); type TrustedLockers = (); type SovereignAccountOf = SovereignAccountOf; - type MaxLockers = frame_support::traits::ConstU32<8>; + type MaxLockers = ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index d609e610bb8b..ee966003134a 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -26,13 +26,14 @@ use frame_support::{ weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; +use sp_core::ConstU32; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin, }; use xcm_executor::traits::WithOriginFilter; @@ -128,12 +129,18 @@ match_types! { pub type Barrier = ( // Weight that is paid for may be consumed. TakeWeightCredit, - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); /// A call filter for the XCM Transact instruction. This is a temporary measure until we @@ -370,7 +377,7 @@ impl pallet_xcm::Config for Runtime { type CurrencyMatcher = (); type TrustedLockers = (); type SovereignAccountOf = SovereignAccountOf; - type MaxLockers = frame_support::traits::ConstU32<8>; + type MaxLockers = ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 6d3f1a540eb1..4b6702afa7b2 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -26,6 +26,7 @@ use frame_support::{ weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; +use sp_core::ConstU32; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -33,7 +34,7 @@ use xcm_builder::{ ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, - TakeWeightCredit, UsingComponents, WeightInfoBounds, + TakeWeightCredit, UsingComponents, WeightInfoBounds, WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -124,14 +125,20 @@ match_types! { pub type Barrier = ( // Weight that is paid for may be consumed. TakeWeightCredit, - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Messages coming from system parachains need not pay for execution. - AllowExplicitUnpaidExecutionFrom>, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Messages coming from system parachains need not pay for execution. + AllowExplicitUnpaidExecutionFrom>, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); /// A call filter for the XCM Transact instruction. This is a temporary measure until we @@ -345,7 +352,7 @@ impl pallet_xcm::Config for Runtime { type CurrencyMatcher = IsConcrete; type TrustedLockers = (); type SovereignAccountOf = LocationConverter; - type MaxLockers = frame_support::traits::ConstU32<8>; + type MaxLockers = ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index b2eaaa4e2057..5e887dafe9a1 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -25,6 +25,7 @@ use frame_support::{ traits::{Contains, Everything, Nothing}, }; use runtime_common::{xcm_sender, ToAuthor}; +use sp_core::ConstU32; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -32,7 +33,7 @@ use xcm_builder::{ ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, + UsingComponents, WeightInfoBounds, WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -96,14 +97,20 @@ pub type TrustedTeleporters = pub type Barrier = ( // Weight that is paid for may be consumed. TakeWeightCredit, - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Messages coming from system parachains need not pay for execution. - AllowExplicitUnpaidExecutionFrom>, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Messages coming from system parachains need not pay for execution. + AllowExplicitUnpaidExecutionFrom>, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); /// A call filter for the XCM Transact instruction. This is a temporary measure until we @@ -260,7 +267,7 @@ impl pallet_xcm::Config for Runtime { type CurrencyMatcher = IsConcrete; type TrustedLockers = (); type SovereignAccountOf = LocationConverter; - type MaxLockers = frame_support::traits::ConstU32<8>; + type MaxLockers = ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; From 61074d18c9c4db813984a813f37e24975b0f17b1 Mon Sep 17 00:00:00 2001 From: Gav Date: Fri, 6 Jan 2023 16:25:27 -0300 Subject: [PATCH 205/231] Update lock --- Cargo.lock | 65 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 772c1d9955c5..40661fc44dd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,7 +42,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", ] [[package]] @@ -51,8 +51,8 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array 0.14.4", - "rand_core 0.6.3", + "generic-array 0.14.6", + "rand_core 0.6.4", ] [[package]] @@ -978,6 +978,7 @@ dependencies = [ "num-integer", "num-traits", "time 0.1.44", + "wasm-bindgen", "winapi", ] @@ -1000,7 +1001,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", ] [[package]] @@ -1429,7 +1430,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", "subtle", ] @@ -1948,7 +1949,7 @@ dependencies = [ "hkdf", "pem-rfc7468", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -3203,6 +3204,30 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -3827,7 +3852,7 @@ dependencies = [ "rand 0.8.5", "rw-stream-sink", "sec1", - "sha2 0.10.2", + "sha2 0.10.6", "smallvec", "thiserror", "unsigned-varint", @@ -4136,7 +4161,7 @@ dependencies = [ "thiserror", "tinytemplate", "tokio", - "tokio-util 0.7.1", + "tokio-util", "webrtc", ] @@ -4407,7 +4432,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66b48670c893079d3c2ed79114e3644b7004df1c361a4e0ad52e2e6940d07c3d" dependencies = [ - "digest 0.10.3", + "digest 0.10.5", ] [[package]] @@ -5101,7 +5126,7 @@ checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ "ecdsa", "elliptic-curve", - "sha2 0.10.2", + "sha2 0.10.6", ] [[package]] @@ -5112,7 +5137,7 @@ checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ "ecdsa", "elliptic-curve", - "sha2 0.10.2", + "sha2 0.10.6", ] [[package]] @@ -12470,7 +12495,7 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.8", ] [[package]] @@ -12981,7 +13006,7 @@ dependencies = [ "sdp", "serde", "serde_json", - "sha2 0.10.2", + "sha2 0.10.6", "stun", "thiserror", "time 0.3.17", @@ -13037,14 +13062,14 @@ dependencies = [ "p256", "p384", "rand 0.8.5", - "rand_core 0.6.3", + "rand_core 0.6.4", "rcgen 0.9.3", "ring", "rustls 0.19.1", "sec1", "serde", "sha-1 0.9.8", - "sha2 0.9.8", + "sha2 0.9.9", "signature", "subtle", "thiserror", @@ -13163,7 +13188,7 @@ dependencies = [ "lazy_static", "libc", "log", - "nix 0.24.1", + "nix 0.24.2", "rand 0.8.5", "thiserror", "tokio", @@ -13524,7 +13549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" dependencies = [ "curve25519-dalek 3.2.0", - "rand_core 0.6.3", + "rand_core 0.6.4", "zeroize", ] @@ -13735,6 +13760,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "yasna" version = "0.5.1" From f1319f116237091253db7602a8a7b53df9a78d90 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 10 Jan 2023 21:23:22 +0900 Subject: [PATCH 206/231] Fix warning --- xcm/xcm-builder/src/universal_exports.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/universal_exports.rs b/xcm/xcm-builder/src/universal_exports.rs index e9600a317fd2..7fe4e2a13cf9 100644 --- a/xcm/xcm-builder/src/universal_exports.rs +++ b/xcm/xcm-builder/src/universal_exports.rs @@ -298,7 +298,7 @@ impl> DispatchBlob let dest = universal_dest.relative_to(&our_universal); let message: Xcm<()> = message.try_into().map_err(|_| DispatchBlobError::UnsupportedXcmVersion)?; - send_xcm::(dest, message).map_err(|_| DispatchBlobError::RoutingError)?; + let _ = send_xcm::(dest, message).map_err(|_| DispatchBlobError::RoutingError)?; Ok(()) } } From 8652bfc658420c77b7a7804fa7d7713146884a22 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 12 Jan 2023 04:26:24 +0900 Subject: [PATCH 207/231] Update xcm/pallet-xcm/src/tests.rs Co-authored-by: Squirrel --- xcm/pallet-xcm/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index 2700124976f1..cbed0f187452 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -1199,7 +1199,7 @@ fn subscription_side_upgrades_work_with_multistage_notify() { ); let mut contents = VersionNotifyTargets::::iter().collect::>(); - contents.sort_by_key(|k| k.2 .0); + contents.sort_by_key(|k| k.2.0); assert_eq!( contents, vec![ From f0b0847240cc00ee7712a77e81985f9963c80a45 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 12 Jan 2023 06:26:50 +0900 Subject: [PATCH 208/231] Update runtime/parachains/src/ump/migration.rs Co-authored-by: Oliver Tale-Yazdi --- runtime/parachains/src/ump/migration.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/parachains/src/ump/migration.rs b/runtime/parachains/src/ump/migration.rs index d791aa863f61..666d224b4b06 100644 --- a/runtime/parachains/src/ump/migration.rs +++ b/runtime/parachains/src/ump/migration.rs @@ -33,6 +33,7 @@ pub mod v1 { let mut weight = T::DbWeight::get().reads(1); let overweight_messages = Overweight::::initialize_counter() as u64; + log::info!("Initialized Overweight to {}", overweight_messages); weight.saturating_accrue(T::DbWeight::get().reads_writes(overweight_messages, 1)); From e430f167e0b7d47009c2841a250af2ad66196175 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 12 Jan 2023 23:41:59 +0900 Subject: [PATCH 209/231] Update xcm/pallet-xcm/src/migration.rs Co-authored-by: Oliver Tale-Yazdi --- xcm/pallet-xcm/src/migration.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xcm/pallet-xcm/src/migration.rs b/xcm/pallet-xcm/src/migration.rs index 9b96306f0d68..c7e8ca786244 100644 --- a/xcm/pallet-xcm/src/migration.rs +++ b/xcm/pallet-xcm/src/migration.rs @@ -43,7 +43,9 @@ pub mod v1 { let translate = |pre: (u64, u64, u32)| -> Option<(u64, Weight, u32)> { weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); - Some((pre.0, Weight::from_parts(pre.1, DEFAULT_PROOF_SIZE), pre.2)) + let translated = (pre.0, Weight::from_parts(pre.1, DEFAULT_PROOF_SIZE), pre.2); + log::info!("Migrated VersionNotifyTarget {:?} to {:?}", pre, translated); + Some(translated) }; as Store>::VersionNotifyTargets::translate_values(translate); From 1efae0375f31a6706ecb5c6a9fa99997d9e6a3f9 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 13 Jan 2023 02:51:29 +0900 Subject: [PATCH 210/231] Fixes --- xcm/xcm-builder/src/barriers.rs | 4 ++-- xcm/xcm-executor/src/lib.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 1e1389489e99..64d133349ee6 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -302,8 +302,8 @@ impl> ShouldExecute for AllowSubscriptionsFrom { origin, instructions, _max_weight, _weight_credit, ); ensure!(T::contains(origin), ()); - match (instructions.len(), instructions.first()) { - (1, Some(SubscribeVersion { .. })) | (1, Some(UnsubscribeVersion)) => Ok(()), + match instructions { + &mut [SubscribeVersion { .. } | UnsubscribeVersion] => Ok(()), _ => Err(()), } } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index e4692058fda9..175f9e54fae7 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -40,8 +40,13 @@ pub use assets::Assets; mod config; pub use config::Config; +/// A struct to specify how fees are being paid. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct FeesMode { + /// If true, then the fee assets are taken directly from the origin's on-chain account, + /// otherwise the fee assets are taken from the holding register. + /// + /// Defaults to false. pub jit_withdraw: bool, } From b85e12f0bea43ded9e853a3aeae33cfa71387823 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 13 Jan 2023 02:54:35 +0900 Subject: [PATCH 211/231] cargo fmt --- xcm/pallet-xcm/src/tests.rs | 2 +- xcm/xcm-builder/src/currency_adapter.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index cbed0f187452..2700124976f1 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -1199,7 +1199,7 @@ fn subscription_side_upgrades_work_with_multistage_notify() { ); let mut contents = VersionNotifyTargets::::iter().collect::>(); - contents.sort_by_key(|k| k.2.0); + contents.sort_by_key(|k| k.2 .0); assert_eq!( contents, vec![ diff --git a/xcm/xcm-builder/src/currency_adapter.rs b/xcm/xcm-builder/src/currency_adapter.rs index 6741b0cd965a..2815d8bd3c47 100644 --- a/xcm/xcm-builder/src/currency_adapter.rs +++ b/xcm/xcm-builder/src/currency_adapter.rs @@ -122,8 +122,11 @@ impl< .is_ok(); if ok { Currency::reactivate(amount); + } else { + frame_support::defensive!( + "`can_check_in` must have returned `true` immediately prior; qed" + ); } - debug_assert!(ok, "`can_check_in` must have returned `true` immediately prior; qed"); } } From 47f972b5c8f347fd9bf1e46ffe02c4021d3e9967 Mon Sep 17 00:00:00 2001 From: Gav Date: Sun, 15 Jan 2023 10:01:05 -0300 Subject: [PATCH 212/231] Typo --- Cargo.lock | 65 +++++++++------------------------ xcm/xcm-builder/src/barriers.rs | 2 +- 2 files changed, 18 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d70693b358d0..af284418ab4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,7 +42,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", ] [[package]] @@ -51,8 +51,8 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array 0.14.6", - "rand_core 0.6.4", + "generic-array 0.14.4", + "rand_core 0.6.3", ] [[package]] @@ -841,7 +841,6 @@ dependencies = [ "num-integer", "num-traits", "time 0.1.44", - "wasm-bindgen", "winapi", ] @@ -864,7 +863,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", ] [[package]] @@ -1285,7 +1284,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", "subtle", ] @@ -1804,7 +1803,7 @@ dependencies = [ "hkdf", "pem-rfc7468", "pkcs8", - "rand_core 0.6.4", + "rand_core 0.6.3", "sec1", "subtle", "zeroize", @@ -3072,30 +3071,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -3701,7 +3676,7 @@ dependencies = [ "rand 0.8.5", "rw-stream-sink", "sec1", - "sha2 0.10.6", + "sha2 0.10.2", "smallvec", "thiserror", "unsigned-varint", @@ -4010,7 +3985,7 @@ dependencies = [ "thiserror", "tinytemplate", "tokio", - "tokio-util", + "tokio-util 0.7.1", "webrtc", ] @@ -4280,7 +4255,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66b48670c893079d3c2ed79114e3644b7004df1c361a4e0ad52e2e6940d07c3d" dependencies = [ - "digest 0.10.5", + "digest 0.10.3", ] [[package]] @@ -4948,7 +4923,7 @@ checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "sha2 0.10.2", ] [[package]] @@ -4959,7 +4934,7 @@ checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "sha2 0.10.2", ] [[package]] @@ -12320,7 +12295,7 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.3", ] [[package]] @@ -12831,7 +12806,7 @@ dependencies = [ "sdp", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.2", "stun", "thiserror", "time 0.3.17", @@ -12887,14 +12862,14 @@ dependencies = [ "p256", "p384", "rand 0.8.5", - "rand_core 0.6.4", + "rand_core 0.6.3", "rcgen 0.9.3", "ring", "rustls 0.19.1", "sec1", "serde", "sha-1 0.9.8", - "sha2 0.9.9", + "sha2 0.9.8", "signature", "subtle", "thiserror", @@ -13013,7 +12988,7 @@ dependencies = [ "lazy_static", "libc", "log", - "nix 0.24.2", + "nix 0.24.1", "rand 0.8.5", "thiserror", "tokio", @@ -13418,7 +13393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" dependencies = [ "curve25519-dalek 3.2.0", - "rand_core 0.6.4", + "rand_core 0.6.3", "zeroize", ] @@ -13629,12 +13604,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "yansi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" - [[package]] name = "yasna" version = "0.5.1" diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 64d133349ee6..bdc7f6811edd 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -286,7 +286,7 @@ impl ShouldExecute for AllowKnownQueryResponses(PhantomData); impl> ShouldExecute for AllowSubscriptionsFrom { From 62752b3481d8aeddebcbf1efb7ccab673a810707 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sun, 15 Jan 2023 10:01:56 -0300 Subject: [PATCH 213/231] Update xcm/src/v3/mod.rs Co-authored-by: Oliver Tale-Yazdi --- xcm/src/v3/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 7b3478507dc7..7f55f27fad28 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -236,7 +236,7 @@ impl PalletInfo { impl MaxEncodedLen for PalletInfo { fn max_encoded_len() -> usize { - parity_scale_codec::Compact::::max_encoded_len() * 4 + MAX_NAME_LEN * 2 + parity_scale_codec::Compact::::max_encoded_len() * 4 + (MAX_NAME_LEN + 1) * 2 } } From 3d0d3e722821d655ab52d1adea56a22bd9ee84af Mon Sep 17 00:00:00 2001 From: Gav Date: Sun, 15 Jan 2023 10:28:54 -0300 Subject: [PATCH 214/231] Docs --- runtime/common/src/xcm_sender.rs | 4 ++++ xcm/src/v3/multiasset.rs | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index bc806d67f2e0..392f0a40a087 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -27,7 +27,10 @@ use sp_std::{marker::PhantomData, prelude::*}; use xcm::prelude::*; use SendError::*; +/// Simple value-bearing trait for determining/expressing the assets required to be paid for a +/// messages to be delivered to a parachain. pub trait PriceForParachainDelivery { + /// Return the assets required to deliver `message` to the given `para` destination. fn price_for_parachain_delivery(para: ParaId, message: &Xcm<()>) -> MultiAssets; } impl PriceForParachainDelivery for () { @@ -36,6 +39,7 @@ impl PriceForParachainDelivery for () { } } +/// Implementation of `PriceForParachainDelivery` which returns a fixed price. pub struct ConstantPrice(sp_std::marker::PhantomData); impl> PriceForParachainDelivery for ConstantPrice { fn price_for_parachain_delivery(_: ParaId, _: &Xcm<()>) -> MultiAssets { diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index 493d7bcfe76c..fd3f7ede4d13 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -441,7 +441,7 @@ impl MultiAsset { Ok(self) } - /// Returns true if `self` is a super-set of the given `inner`. + /// Returns true if `self` is a super-set of the given `inner` asset. pub fn contains(&self, inner: &MultiAsset) -> bool { use Fungibility::*; if self.id == inner.id { @@ -602,7 +602,7 @@ impl MultiAssets { self.0.is_empty() } - /// Returns true if `self` is a super-set of the given `inner`. + /// Returns true if `self` is a super-set of the given `inner` asset. pub fn contains(&self, inner: &MultiAsset) -> bool { self.0.iter().any(|i| i.contains(inner)) } @@ -695,10 +695,7 @@ impl TryFrom<(OldWildMultiAsset, u32)> for WildMultiAsset { } impl WildMultiAsset { - /// Returns true if `self` is a super-set of the given `inner`. - /// - /// Typically, any wildcard is never contained in anything else, and a wildcard can contain any other non-wildcard. - /// For more details, see the implementation and tests. + /// Returns true if `self` is a super-set of the given `inner` asset. pub fn contains(&self, inner: &MultiAsset) -> bool { use WildMultiAsset::*; match self { From 9bc2ddbdf8f58a01e826207d6979e431d2e78014 Mon Sep 17 00:00:00 2001 From: Gav Date: Sun, 15 Jan 2023 10:31:41 -0300 Subject: [PATCH 215/231] Docs --- xcm/src/v3/traits.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index eb5dd37cbc6c..3186b371b874 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -25,6 +25,9 @@ pub use sp_weights::Weight; use super::*; +/// Error codes used in XCM. The first errors codes have explicit indices and are part of the XCM +/// format. Those trailing are merely part of the XCM implementation; there is no expectation that +/// they will retain the same index over time. #[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] pub enum Error { // Errors that happen due to instructions being executed. These alone are defined in the From bbeb790933e9c7d425b48df5ddd75e5d9839d7c5 Mon Sep 17 00:00:00 2001 From: Gav Date: Sun, 15 Jan 2023 10:46:00 -0300 Subject: [PATCH 216/231] Docs --- xcm/xcm-builder/src/fungibles_adapter.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xcm/xcm-builder/src/fungibles_adapter.rs b/xcm/xcm-builder/src/fungibles_adapter.rs index 32cf6f014a5f..c20fc9926712 100644 --- a/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/xcm/xcm-builder/src/fungibles_adapter.rs @@ -21,6 +21,7 @@ use sp_std::{marker::PhantomData, prelude::*, result}; use xcm::latest::prelude::*; use xcm_executor::traits::{Convert, Error as MatchError, MatchesFungibles, TransactAsset}; +/// `TransactAsset` implementation to convert a `fungibles` implementation to become usable in XCM. pub struct FungiblesTransferAdapter( PhantomData<(Assets, Matcher, AccountIdConverter, AccountId)>, ); @@ -65,10 +66,23 @@ pub enum MintLocation { NonLocal, } +/// Simple trait to indicate whether an asset is subject to having its teleportation into and out of +/// this chain recorded and if so in what `MintLocation`. +/// +/// The overall purpose of asset-checking is to ensure either no more assets are teleported into a +/// chain than the outstanding balance of assets which were previously teleported out (as in the +/// case of locally-minted assets); or that no more assets are teleported out of a chain than the +/// outstanding balance of assets which have previously been teleported in (as in the case of chains +/// where the `asset` is not minted locally). pub trait AssetChecking { + /// Return the teleportation asset-checking policy for the given `asset`. `None` implies no + /// checking. Otherwise the policy detailed by the inner `MintLocation` should be respected by + /// teleportation. fn asset_checking(asset: &AssetId) -> Option; } +/// Implementation of `AssetChecking` which subjects no assets to having their teleportations +/// recorded. pub struct NoChecking; impl AssetChecking for NoChecking { fn asset_checking(_: &AssetId) -> Option { @@ -76,6 +90,8 @@ impl AssetChecking for NoChecking { } } +/// Implementation of `AssetChecking` which subjects a given set of assets `T` to having their +/// teleportations recorded with a `MintLocation::Local`. pub struct LocalMint(sp_std::marker::PhantomData); impl> AssetChecking for LocalMint { fn asset_checking(asset: &AssetId) -> Option { @@ -86,6 +102,8 @@ impl> AssetChecking for LocalMint { } } +/// Implementation of `AssetChecking` which subjects a given set of assets `T` to having their +/// teleportations recorded with a `MintLocation::NonLocal`. pub struct NonLocalMint(sp_std::marker::PhantomData); impl> AssetChecking for NonLocalMint { fn asset_checking(asset: &AssetId) -> Option { @@ -96,6 +114,9 @@ impl> AssetChecking for NonLocalMint { } } +/// Implementation of `AssetChecking` which subjects a given set of assets `L` to having their +/// teleportations recorded with a `MintLocation::Local` and a second set of assets `R` to having +/// their teleportations recorded with a `MintLocation::NonLocal`. pub struct DualMint(sp_std::marker::PhantomData<(L, R)>); impl, R: Contains> AssetChecking for DualMint From 6c8fb236757f88e885666cbd359387117f47368e Mon Sep 17 00:00:00 2001 From: Gav Date: Sun, 15 Jan 2023 11:11:48 -0300 Subject: [PATCH 217/231] Docs --- xcm/src/v3/multiasset.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index fd3f7ede4d13..22cba98d63df 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -238,7 +238,10 @@ impl TryFrom for u128 { #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Fungibility { + /// A fungible asset; we record a number of units, as a `u128` in the inner item. Fungible(#[codec(compact)] u128), + /// A non-fungible asset. We record the instance identifier in the inner item. Only one asset + /// of each instance identifier may ever be in existence at once. NonFungible(AssetInstance), } @@ -287,7 +290,9 @@ impl TryFrom for Fungibility { )] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum WildFungibility { + /// The asset is fungible. Fungible, + /// The asset is not fungible. NonFungible, } @@ -308,7 +313,10 @@ impl TryFrom for WildFungibility { )] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum AssetId { + /// A specific location identifying an asset. Concrete(MultiLocation), + /// An abstract location; this is a name which may mean different specific locations on + /// different chains at different times. Abstract([u8; 32]), } @@ -375,10 +383,14 @@ impl AssetId { } } +/// Either an amount of a single fungible asset, or a single well-identified non-fungible asset. #[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct MultiAsset { + /// The overall asset identity (aka *class*, in the case of a non-fungible). pub id: AssetId, + /// The fungibility of the asset, which contains either the amount (in the case of a fungible + /// asset) or the *insance ID`, the secondary asset identifier. pub fun: Fungibility, } @@ -462,10 +474,15 @@ impl TryFrom for MultiAsset { } } -/// A `Vec` of `MultiAsset`s. There may be no duplicate fungible items in here and when decoding, they must be sorted. +/// A `Vec` of `MultiAsset`s. +/// +/// There are a number of invariants which the construction and mutation functions must ensure are +/// maintained: +/// - It may contain no items of duplicate asset class; +/// - All items must be ordered; +/// - The number of items should grow no larger than `MAX_ITEMS_IN_MULTIASSETS`. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo, Default)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] -// TODO: Change to a `BoundedVec`. pub struct MultiAssets(Vec); /// Maximum number of items we expect in a single `MultiAssets` value. Note this is not (yet) @@ -761,11 +778,13 @@ impl, B: Into> From<(A, B)> for WildMultiAsset } } -/// `MultiAsset` collection, either `MultiAssets` or a single wildcard. +/// `MultiAsset` collection, defined either by a number of `MultiAssets` or a single wildcard. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum MultiAssetFilter { + /// Specify the filter as being everything contained by the given `MultiAssets` inner. Definite(MultiAssets), + /// Specify the filter as the given `WildMultiAsset` wildcard. Wild(WildMultiAsset), } From ff59e4c4b480b3b68dfdf996688b5f47df8c19ad Mon Sep 17 00:00:00 2001 From: Gav Date: Sun, 15 Jan 2023 11:32:44 -0300 Subject: [PATCH 218/231] Docs --- xcm/src/v3/traits.rs | 10 +++++----- xcm/xcm-executor/src/traits/export.rs | 27 +++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 3186b371b874..6ccf01ad06c3 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -382,12 +382,11 @@ impl Unwrappable for Option { } } -/// Utility for sending an XCM message. -/// -/// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each router might return -/// `NotApplicable` to pass the execution to the next sender item. Note that each `NotApplicable` -/// might alter the destination and the XCM message for to the next router. +/// Utility for sending an XCM message to a given location. /// +/// These can be amalgamated in tuples to form sophisticated routing systems. In tuple format, each +/// router might return `NotApplicable` to pass the execution to the next sender item. Note that +/// each `NotApplicable` might alter the destination and the XCM message for to the next router. /// /// # Example /// ```rust @@ -456,6 +455,7 @@ impl Unwrappable for Option { /// # } /// ``` pub trait SendXcm { + /// Intermediate value which connects the two phaases of the send operation. type Ticket; /// Check whether the given `_message` is deliverable to the given `_destination` and if so diff --git a/xcm/xcm-executor/src/traits/export.rs b/xcm/xcm-executor/src/traits/export.rs index 498cea4bce56..61b76addfe4c 100644 --- a/xcm/xcm-executor/src/traits/export.rs +++ b/xcm/xcm-executor/src/traits/export.rs @@ -16,19 +16,38 @@ use xcm::latest::prelude::*; +/// Utility for delivering a message to a system under a different (non-local) consensus with a +/// spoofed origin. This essentially defines the behaviour of the `ExportMessage` XCM instruction. +/// +/// This is quite different to `SendXcm`; `SendXcm` assumes that the local side's location will be +/// preserved to be represented as the value of the Origin register in the messages execution. +/// +/// This trait on the other hand assumes that we do not necessarily want the Origin register to +/// contain the local (i.e. the caller chain's) location, since it will generally be exporting a +/// message on behalf of another consensus system. Therefore in addition to the message, the +/// destination must be given in two parts: the network and the interior location within it. +/// +/// We also require the caller to state exactly what location they purport to be representing. The +/// destination must accept the local location to represent that location or the operation will +/// fail. pub trait ExportXcm { + /// Intermediate value which connects the two phaases of the export operation. type Ticket; - /// Check whether the given `message` is deliverable to the given `destination` spoofing - /// its source as `universal_source` and if so determine the cost which will be paid by this - /// chain to do so, returning a `Validated` token which can be used to enact delivery. + /// Check whether the given `message` is deliverable to the given `destination` on `network`, + /// spoofing its source as `universal_source` and if so determine the cost which will be paid by + /// this chain to do so, returning a `Ticket` token which can be used to enact delivery. + /// + /// The `channel` to be used on the `network`'s export mechanism (bridge, probably) must also + /// be provided. /// /// The `destination` and `message` must be `Some` (or else an error will be returned) and they /// may only be consumed if the `Err` is not `NotApplicable`. /// /// If it is not a destination which can be reached with this type but possibly could by others, /// then this *MUST* return `NotApplicable`. Any other error will cause the tuple - /// implementation to exit early without trying other type fields. + /// implementation (used to compose routing systems from different delivery agents) to exit + /// early without trying alternative means of delivery. fn validate( network: NetworkId, channel: u32, From 76e658133cf239a46629d88a9105c0e46ff10917 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 16 Jan 2023 14:35:10 +0900 Subject: [PATCH 219/231] Update xcm/src/v3/multiasset.rs Co-authored-by: Oliver Tale-Yazdi --- xcm/src/v3/multiasset.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index 22cba98d63df..aa8b27f4666b 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -340,8 +340,7 @@ impl TryFrom for AssetId { Concrete(l) => Self::Concrete(l.try_into()?), Abstract(v) if v.len() <= 32 => { let mut r = [0u8; 32]; - let (left, _right) = r.split_at_mut(v.len()); - left.copy_from_slice(&v[..]); + r[..v.len()].copy_from_slice(&v[..]); Self::Abstract(r) }, _ => return Err(()), From 6308804e34349384bd0a6a6ee8b530a3b2d88fab Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 16 Jan 2023 15:24:34 +0900 Subject: [PATCH 220/231] Add tests for MultiAssets::from_sorted_and_deduplicated --- xcm/src/v3/multiasset.rs | 69 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index aa8b27f4666b..704c6885feac 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -878,9 +878,70 @@ impl TryFrom<(OldMultiAssetFilter, u32)> for MultiAssetFilter { } } -#[test] -fn conversion_works() { - use super::prelude::*; +#[cfg(test)] +mod tests { + use super::super::prelude::*; - let _: MultiAssets = (Here, 1u128).into(); + #[test] + fn conversion_works() { + let _: MultiAssets = (Here, 1u128).into(); + } + + #[test] + fn from_sorted_and_deduplicated_works() { + use alloc::vec; + use super::*; + + let empty = vec![]; + let r = MultiAssets::from_sorted_and_deduplicated(empty); + assert_eq!(r, Ok(MultiAssets(vec![]))); + + let dup_fun = vec![(Here, 100).into(), (Here, 10).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(dup_fun); + assert!(r.is_err()); + + let dup_nft = vec![(Here, *b"notgood!").into(), (Here, *b"notgood!").into()]; + let r = MultiAssets::from_sorted_and_deduplicated(dup_nft); + assert!(r.is_err()); + + let good_fun = vec![(Here, 10).into(), (Parent, 10).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(good_fun.clone()); + assert_eq!(r, Ok(MultiAssets(good_fun))); + + let bad_fun = vec![(Parent, 10).into(), (Here, 10).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(bad_fun); + assert!(r.is_err()); + + let good_abstract_fun = vec![(Here, 100).into(), ([0u8; 32], 10).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(good_abstract_fun.clone()); + assert_eq!(r, Ok(MultiAssets(good_abstract_fun))); + + let bad_abstract_fun = vec![([0u8; 32], 10).into(), (Here, 10).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(bad_abstract_fun); + assert!(r.is_err()); + + let good_nft = vec![(Here, ()).into(), (Here, *b"good").into()]; + let r = MultiAssets::from_sorted_and_deduplicated(good_nft.clone()); + assert_eq!(r, Ok(MultiAssets(good_nft))); + + let bad_nft = vec![(Here, *b"bad!").into(), (Here, ()).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(bad_nft); + assert!(r.is_err()); + + let good_abstract_nft = vec![(Here, ()).into(), ([0u8; 32], ()).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(good_abstract_nft.clone()); + assert_eq!(r, Ok(MultiAssets(good_abstract_nft))); + + let bad_abstract_nft = vec![([0u8; 32], ()).into(), (Here, ()).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(bad_abstract_nft); + assert!(r.is_err()); + + let mixed_good = vec![(Here, 10).into(), (Here, *b"good").into()]; + let r = MultiAssets::from_sorted_and_deduplicated(mixed_good.clone()); + assert_eq!(r, Ok(MultiAssets(mixed_good))); + + let mixed_bad = vec![(Here, *b"bad!").into(), (Here, 10).into()]; + let r = MultiAssets::from_sorted_and_deduplicated(mixed_bad); + assert!(r.is_err()); + } } From 88b187ced92fed9cb9b6c1b8292cc6b946937ed1 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 16 Jan 2023 15:38:27 +0900 Subject: [PATCH 221/231] Fail gracefully when same instance NFTs are detected during push --- xcm/src/v3/multiasset.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xcm/src/v3/multiasset.rs b/xcm/src/v3/multiasset.rs index 704c6885feac..0dd6b55826c8 100644 --- a/xcm/src/v3/multiasset.rs +++ b/xcm/src/v3/multiasset.rs @@ -601,12 +601,16 @@ impl MultiAssets { /// Add some asset onto the list, saturating. This is quite a laborious operation since it maintains the ordering. pub fn push(&mut self, a: MultiAsset) { - if let Fungibility::Fungible(ref amount) = a.fun { - for asset in self.0.iter_mut().filter(|x| x.id == a.id) { - if let Fungibility::Fungible(ref mut balance) = asset.fun { + for asset in self.0.iter_mut().filter(|x| x.id == a.id) { + match (&a.fun, &mut asset.fun) { + (Fungibility::Fungible(amount), Fungibility::Fungible(balance)) => { *balance = balance.saturating_add(*amount); return - } + }, + (Fungibility::NonFungible(inst1), Fungibility::NonFungible(inst2)) + if inst1 == inst2 => + return, + _ => (), } } self.0.push(a); @@ -889,8 +893,8 @@ mod tests { #[test] fn from_sorted_and_deduplicated_works() { - use alloc::vec; use super::*; + use alloc::vec; let empty = vec![]; let r = MultiAssets::from_sorted_and_deduplicated(empty); From 0dc2643c3e1742ea38c23080d5f5d62fd34c7712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 16 Jan 2023 13:54:36 +0100 Subject: [PATCH 222/231] Update Substrate to fix benchmarks --- Cargo.lock | 371 +++++++++++++++++++++++++++-------------------------- 1 file changed, 186 insertions(+), 185 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af284418ab4a..b3c344bc6aaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -437,7 +437,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "async-trait", @@ -471,7 +471,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "beefy-gadget", "futures", @@ -490,7 +490,7 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "sp-api", "sp-beefy", @@ -2174,7 +2174,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", ] @@ -2198,7 +2198,7 @@ checksum = "85dcb89d2b10c5f6133de2efd8c11959ce9dbb46a2f7a4cab208c4eeda6ce1ab" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -2221,7 +2221,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "Inflector", "array-bytes", @@ -2268,7 +2268,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2279,7 +2279,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2296,7 +2296,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -2325,7 +2325,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "log", @@ -2341,7 +2341,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "bitflags", "frame-metadata", @@ -2373,7 +2373,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "Inflector", "cfg-expr", @@ -2387,7 +2387,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2399,7 +2399,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "proc-macro2", "quote", @@ -2409,7 +2409,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2432,7 +2432,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -2443,7 +2443,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "log", @@ -2461,7 +2461,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -2476,7 +2476,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "sp-api", @@ -2485,7 +2485,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "parity-scale-codec", @@ -2656,7 +2656,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "chrono", "frame-election-provider-support", @@ -2757,9 +2757,9 @@ checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" [[package]] name = "git2" -version = "0.14.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3826a6e0e2215d7a41c2bfc7c9244123969273f3476b939a226aac0ab56e9e3c" +checksum = "be36bc9e0546df253c0cc41fd0af34f5e92845ad8509462ec76672fac6997f5b" dependencies = [ "bitflags", "libc", @@ -3590,9 +3590,9 @@ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "libgit2-sys" -version = "0.13.2+1.4.2" +version = "0.14.1+1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a42de9a51a5c12e00fc0e4ca6bc2ea43582fc6418488e8f615e905d886f258b" +checksum = "4a07fb2692bc3593bda59de45a502bb3071659f2c515e28c71e728306b038e17" dependencies = [ "cc", "libc", @@ -4376,7 +4376,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "log", @@ -4395,7 +4395,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "anyhow", "jsonrpsee", @@ -4940,7 +4940,7 @@ dependencies = [ [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -4955,7 +4955,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -4971,7 +4971,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -4986,7 +4986,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5010,7 +5010,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5030,7 +5030,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-election-provider-support", "frame-remote-externalities", @@ -5049,7 +5049,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5064,7 +5064,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -5080,7 +5080,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "beefy-merkle-tree", @@ -5103,7 +5103,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5121,7 +5121,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5140,7 +5140,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5157,7 +5157,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5174,7 +5174,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5192,7 +5192,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5215,7 +5215,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5228,7 +5228,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5246,7 +5246,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5264,7 +5264,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5287,7 +5287,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5303,7 +5303,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5323,7 +5323,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5340,7 +5340,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5357,7 +5357,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5374,7 +5374,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5390,7 +5390,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5406,7 +5406,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -5423,7 +5423,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5443,7 +5443,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "sp-api", @@ -5453,7 +5453,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -5470,12 +5470,13 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", + "log", "pallet-babe", "pallet-balances", "pallet-grandpa", @@ -5493,7 +5494,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5510,7 +5511,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5525,7 +5526,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5543,7 +5544,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5558,7 +5559,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5577,7 +5578,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5594,7 +5595,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -5615,7 +5616,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5631,7 +5632,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -5645,7 +5646,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5668,7 +5669,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5679,7 +5680,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "log", "sp-arithmetic", @@ -5688,7 +5689,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5705,7 +5706,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -5719,7 +5720,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5737,7 +5738,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5756,7 +5757,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-support", "frame-system", @@ -5772,7 +5773,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -5788,7 +5789,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5800,7 +5801,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5817,7 +5818,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5832,7 +5833,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5848,7 +5849,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5863,7 +5864,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8753,7 +8754,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "log", "sp-core", @@ -8764,7 +8765,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "futures", @@ -8791,7 +8792,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "futures-timer", @@ -8814,7 +8815,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8830,7 +8831,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -8845,7 +8846,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8856,7 +8857,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "chrono", @@ -8896,7 +8897,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "fnv", "futures", @@ -8922,7 +8923,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "hash-db", "kvdb", @@ -8947,7 +8948,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "futures", @@ -8972,7 +8973,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "fork-tree", @@ -9010,7 +9011,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "jsonrpsee", @@ -9032,7 +9033,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "fork-tree", "parity-scale-codec", @@ -9045,7 +9046,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "futures", @@ -9068,7 +9069,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "lru", "parity-scale-codec", @@ -9092,7 +9093,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -9105,7 +9106,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "log", "sc-allocator", @@ -9118,7 +9119,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "cfg-if", "libc", @@ -9135,7 +9136,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "ahash", "array-bytes", @@ -9175,7 +9176,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "finality-grandpa", "futures", @@ -9195,7 +9196,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "ansi_term", "futures", @@ -9210,7 +9211,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "async-trait", @@ -9225,7 +9226,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "async-trait", @@ -9267,7 +9268,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "cid", "futures", @@ -9286,7 +9287,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "bitflags", @@ -9312,7 +9313,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "ahash", "futures", @@ -9330,7 +9331,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "futures", @@ -9351,7 +9352,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "async-trait", @@ -9383,7 +9384,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "futures", @@ -9402,7 +9403,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "bytes", @@ -9432,7 +9433,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "libp2p", @@ -9445,7 +9446,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9454,7 +9455,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "jsonrpsee", @@ -9483,7 +9484,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9502,7 +9503,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "http", "jsonrpsee", @@ -9517,7 +9518,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "futures", @@ -9543,7 +9544,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "directories", @@ -9608,7 +9609,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "log", "parity-scale-codec", @@ -9619,7 +9620,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9638,7 +9639,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "libc", @@ -9657,7 +9658,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "chrono", "futures", @@ -9676,7 +9677,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "ansi_term", "atty", @@ -9707,7 +9708,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9718,7 +9719,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "futures", @@ -9744,7 +9745,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "futures", @@ -9758,7 +9759,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "backtrace", "futures", @@ -10254,7 +10255,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "hash-db", "log", @@ -10272,7 +10273,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "blake2", "proc-macro-crate", @@ -10284,7 +10285,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -10297,7 +10298,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "integer-sqrt", "num-traits", @@ -10311,7 +10312,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -10324,7 +10325,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "parity-scale-codec", @@ -10336,7 +10337,7 @@ dependencies = [ [[package]] name = "sp-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -10353,7 +10354,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "sp-api", @@ -10365,7 +10366,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "log", @@ -10383,7 +10384,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "futures", @@ -10401,7 +10402,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "merlin", @@ -10424,7 +10425,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -10436,7 +10437,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -10449,7 +10450,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "base58", @@ -10491,7 +10492,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "blake2", "byteorder", @@ -10505,7 +10506,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "proc-macro2", "quote", @@ -10516,7 +10517,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10525,7 +10526,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "proc-macro2", "quote", @@ -10535,7 +10536,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "environmental", "parity-scale-codec", @@ -10546,7 +10547,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "finality-grandpa", "log", @@ -10564,7 +10565,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10578,7 +10579,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "bytes", "ed25519", @@ -10603,7 +10604,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "lazy_static", "sp-core", @@ -10614,7 +10615,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "futures", @@ -10631,7 +10632,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "thiserror", "zstd", @@ -10640,7 +10641,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -10658,7 +10659,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -10672,7 +10673,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "sp-api", "sp-core", @@ -10682,7 +10683,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "backtrace", "lazy_static", @@ -10692,7 +10693,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "rustc-hash", "serde", @@ -10702,7 +10703,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "either", "hash256-std-hasher", @@ -10724,7 +10725,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10742,7 +10743,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "Inflector", "proc-macro-crate", @@ -10754,7 +10755,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -10768,7 +10769,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -10780,7 +10781,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "hash-db", "log", @@ -10800,12 +10801,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10818,7 +10819,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "futures-timer", @@ -10833,7 +10834,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "sp-std", @@ -10845,7 +10846,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "sp-api", "sp-runtime", @@ -10854,7 +10855,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "log", @@ -10870,7 +10871,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "ahash", "hash-db", @@ -10893,7 +10894,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10910,7 +10911,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10921,7 +10922,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "impl-trait-for-tuples", "log", @@ -10934,7 +10935,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "parity-scale-codec", "scale-info", @@ -11167,7 +11168,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "platforms", ] @@ -11175,7 +11176,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -11194,7 +11195,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "hyper", "log", @@ -11206,7 +11207,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "async-trait", "jsonrpsee", @@ -11219,7 +11220,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "jsonrpsee", "log", @@ -11238,7 +11239,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "array-bytes", "async-trait", @@ -11264,7 +11265,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "futures", "substrate-test-utils-derive", @@ -11274,7 +11275,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11285,7 +11286,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "ansi_term", "build-helper", @@ -12080,7 +12081,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4e383428ffc6d4eba173ca257c1aaf53d1ec339c" +source = "git+https://github.com/paritytech/substrate?branch=master#70f2e364ab1ad57ce8d3abe228222b299393c5c0" dependencies = [ "clap", "frame-remote-externalities", From 40e004725013ff7fc624de65061a0f50491cd0f1 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 16 Jan 2023 14:14:54 -0300 Subject: [PATCH 223/231] Apply suggestions from code review --- runtime/polkadot/src/xcm_config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index ee966003134a..abdd850f9e61 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -46,9 +46,9 @@ parameter_types! { pub const ThisNetwork: NetworkId = NetworkId::Polkadot; /// Our location in the universe of consensus systems. pub const UniversalLocation: InteriorMultiLocation = X1(GlobalConsensus(ThisNetwork::get())); - /// The check account, which holds any native assets that have been teleported out and not back in (yet). + /// The Checking Account, which holds any native assets that have been teleported out and not back in (yet). pub CheckAccount: AccountId = XcmPallet::check_account(); - /// The check account that is allowed to mint assets locally. + /// The Checking Account along with the indication that the local chain is able to mint tokens. pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); } From 5184e73e13e2ebcd363cbbd499fd038cb528a2eb Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 17 Jan 2023 06:03:48 +0900 Subject: [PATCH 224/231] Update runtime/kusama/src/xcm_config.rs --- runtime/kusama/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 05e99a9b6903..96679c3919a4 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -135,7 +135,7 @@ pub type Barrier = ( AllowKnownQueryResponses, WithComputedOrigin< ( - // If the message is one that immediately attemps to pay for execution, then allow it. + // If the message is one that immediately attempts to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, // Messages coming from system parachains need not pay for execution. AllowExplicitUnpaidExecutionFrom>, From 1d76ac43506c69c5c92df73b79931298738fac07 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 17 Jan 2023 06:08:31 +0900 Subject: [PATCH 225/231] Rename arguments --- runtime/kusama/src/weights/xcm/mod.rs | 2 +- runtime/rococo/src/weights/xcm/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index ffda76ce83de..74c67c175785 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -96,7 +96,7 @@ impl XcmWeightInfo for KusamaXcmWeight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( - _origin_type: &OriginKind, + _origin_kind: &OriginKind, _require_weight_at_most: &Weight, _call: &DoubleEncoded, ) -> Weight { diff --git a/runtime/rococo/src/weights/xcm/mod.rs b/runtime/rococo/src/weights/xcm/mod.rs index d1b8afd750ed..49252e3662fb 100644 --- a/runtime/rococo/src/weights/xcm/mod.rs +++ b/runtime/rococo/src/weights/xcm/mod.rs @@ -96,7 +96,7 @@ impl XcmWeightInfo for RococoXcmWeight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( - _origin_type: &OriginKind, + _origin_kind: &OriginKind, _require_weight_at_most: &Weight, _call: &DoubleEncoded, ) -> Weight { From 8ef427dbd5ba09fdfda9644d41306c0e91bf9237 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 17 Jan 2023 06:08:52 +0900 Subject: [PATCH 226/231] Attempt to fix benchmark --- runtime/parachains/src/ump/benchmarking.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/parachains/src/ump/benchmarking.rs b/runtime/parachains/src/ump/benchmarking.rs index e326ddeaf8d7..91f3d4ac7ec2 100644 --- a/runtime/parachains/src/ump/benchmarking.rs +++ b/runtime/parachains/src/ump/benchmarking.rs @@ -65,12 +65,11 @@ fn create_message_min_size(size: u32) -> Vec { } fn create_message_overweight() -> Vec { - let max_block_weight = T::BlockWeights::get().max_block; // We use a `set_code` Call because it let call = frame_system::Call::::set_code { code: vec![] }; VersionedXcm::::from(Xcm::(vec![Transact { origin_kind: OriginKind::Superuser, - require_weight_at_most: max_block_weight, + require_weight_at_most: Weight::MAX / 2, call: call.encode().into(), }])) .encode() From 9780e01531be4e46f11f554b5f1a1adbcb95e021 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 16 Jan 2023 21:39:43 +0000 Subject: [PATCH 227/231] ".git/.scripts/commands/bench/bench.sh" runtime polkadot-dev runtime_parachains::ump --- .../src/weights/runtime_parachains_ump.rs | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 runtime/polkadot/src/weights/runtime_parachains_ump.rs diff --git a/runtime/polkadot/src/weights/runtime_parachains_ump.rs b/runtime/polkadot/src/weights/runtime_parachains_ump.rs new file mode 100644 index 000000000000..8f1eb2d54749 --- /dev/null +++ b/runtime/polkadot/src/weights/runtime_parachains_ump.rs @@ -0,0 +1,74 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `runtime_parachains::ump` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-01-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=runtime_parachains::ump +// --chain=polkadot-dev +// --header=./file_header.txt +// --output=./runtime/polkadot/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `runtime_parachains::ump`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::ump::WeightInfo for WeightInfo { + /// The range of component `s` is `[0, 51200]`. + fn process_upward_message(s: u32, ) -> Weight { + // Minimum execution time: 10_291 nanoseconds. + Weight::from_ref_time(4_272_368) + // Standard Error: 12 + .saturating_add(Weight::from_ref_time(1_872).saturating_mul(s.into())) + } + // Storage: Ump NeedsDispatch (r:1 w:1) + // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) + // Storage: Ump RelayDispatchQueues (r:0 w:1) + // Storage: Ump RelayDispatchQueueSize (r:0 w:1) + fn clean_ump_after_outgoing() -> Weight { + // Minimum execution time: 9_837 nanoseconds. + Weight::from_ref_time(9_951_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: Ump Overweight (r:1 w:1) + // Storage: Ump CounterForOverweight (r:1 w:1) + fn service_overweight() -> Weight { + // Minimum execution time: 29_540 nanoseconds. + Weight::from_ref_time(29_889_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } +} From ae4a28a3655cecc8ddb8d7e7827831c311508610 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 17 Jan 2023 06:44:04 +0900 Subject: [PATCH 228/231] Use actual weights for UMP pallet in Polkadot --- runtime/polkadot/src/lib.rs | 2 +- runtime/polkadot/src/weights/mod.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index c1227a0aabf3..086f713ae0db 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1303,7 +1303,7 @@ impl parachains_ump::Config for Runtime { crate::parachains_ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = EnsureRoot; - type WeightInfo = parachains_ump::TestWeightInfo; + type WeightInfo = weights::runtime_parachains_ump::WeightInfo; } impl parachains_dmp::Config for Runtime {} diff --git a/runtime/polkadot/src/weights/mod.rs b/runtime/polkadot/src/weights/mod.rs index 606dc93a92bc..cef8d5d00aa0 100644 --- a/runtime/polkadot/src/weights/mod.rs +++ b/runtime/polkadot/src/weights/mod.rs @@ -55,3 +55,4 @@ pub mod runtime_parachains_hrmp; pub mod runtime_parachains_initializer; pub mod runtime_parachains_paras; pub mod runtime_parachains_paras_inherent; +pub mod runtime_parachains_ump; From 135393250061c1f2a61460dc4e279eb5b4bcc731 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 16 Jan 2023 22:15:54 +0000 Subject: [PATCH 229/231] ".git/.scripts/commands/bench/bench.sh" runtime kusama-dev runtime_parachains::ump --- .../src/weights/runtime_parachains_ump.rs | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/runtime/kusama/src/weights/runtime_parachains_ump.rs b/runtime/kusama/src/weights/runtime_parachains_ump.rs index 1473eeac063b..bbdc0a9b5d8f 100644 --- a/runtime/kusama/src/weights/runtime_parachains_ump.rs +++ b/runtime/kusama/src/weights/runtime_parachains_ump.rs @@ -16,23 +16,25 @@ //! Autogenerated weights for `runtime_parachains::ump` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// /home/benchbot/cargo_target_dir/production/polkadot // benchmark // pallet -// --chain=kusama-dev // --steps=50 // --repeat=20 -// --pallet=runtime_parachains::ump // --extrinsic=* // --execution=wasm // --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=runtime_parachains::ump +// --chain=kusama-dev // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/runtime_parachains_ump.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,26 +48,27 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::ump::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 51200]`. fn process_upward_message(s: u32, ) -> Weight { - // Minimum execution time: 10_348 nanoseconds. - Weight::from_ref_time(5_121_205 as u64) - // Standard Error: 12 - .saturating_add(Weight::from_ref_time(1_934 as u64).saturating_mul(s as u64)) + // Minimum execution time: 10_393 nanoseconds. + Weight::from_ref_time(2_845_995) + // Standard Error: 21 + .saturating_add(Weight::from_ref_time(2_016).saturating_mul(s.into())) } // Storage: Ump NeedsDispatch (r:1 w:1) // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) // Storage: Ump RelayDispatchQueues (r:0 w:1) // Storage: Ump RelayDispatchQueueSize (r:0 w:1) fn clean_ump_after_outgoing() -> Weight { - // Minimum execution time: 9_800 nanoseconds. - Weight::from_ref_time(10_025_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Minimum execution time: 9_686 nanoseconds. + Weight::from_ref_time(9_920_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: Ump Overweight (r:1 w:1) + // Storage: Ump CounterForOverweight (r:1 w:1) fn service_overweight() -> Weight { - // Minimum execution time: 26_272 nanoseconds. - Weight::from_ref_time(26_790_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 28_502 nanoseconds. + Weight::from_ref_time(28_900_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } From e80c1420cfbd5eca0c4f3a6af289b01faea0b9e3 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 16 Jan 2023 22:42:07 +0000 Subject: [PATCH 230/231] ".git/.scripts/commands/bench/bench.sh" runtime westend-dev runtime_parachains::ump --- .../src/weights/runtime_parachains_ump.rs | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/runtime/westend/src/weights/runtime_parachains_ump.rs b/runtime/westend/src/weights/runtime_parachains_ump.rs index 6afe1a8685dc..6f42ca36e287 100644 --- a/runtime/westend/src/weights/runtime_parachains_ump.rs +++ b/runtime/westend/src/weights/runtime_parachains_ump.rs @@ -16,23 +16,25 @@ //! Autogenerated weights for `runtime_parachains::ump` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// /home/benchbot/cargo_target_dir/production/polkadot // benchmark // pallet -// --chain=westend-dev // --steps=50 // --repeat=20 -// --pallet=runtime_parachains::ump // --extrinsic=* // --execution=wasm // --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=runtime_parachains::ump +// --chain=westend-dev // --header=./file_header.txt -// --output=./runtime/westend/src/weights/runtime_parachains_ump.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,26 +48,27 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::ump::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 51200]`. fn process_upward_message(s: u32, ) -> Weight { - // Minimum execution time: 10_921 nanoseconds. - Weight::from_ref_time(5_417_303 as u64) - // Standard Error: 13 - .saturating_add(Weight::from_ref_time(1_939 as u64).saturating_mul(s as u64)) + // Minimum execution time: 10_155 nanoseconds. + Weight::from_ref_time(4_325_532) + // Standard Error: 11 + .saturating_add(Weight::from_ref_time(1_926).saturating_mul(s.into())) } // Storage: Ump NeedsDispatch (r:1 w:1) // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) // Storage: Ump RelayDispatchQueues (r:0 w:1) // Storage: Ump RelayDispatchQueueSize (r:0 w:1) fn clean_ump_after_outgoing() -> Weight { - // Minimum execution time: 9_499 nanoseconds. - Weight::from_ref_time(9_800_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Minimum execution time: 9_674 nanoseconds. + Weight::from_ref_time(9_964_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: Ump Overweight (r:1 w:1) + // Storage: Ump CounterForOverweight (r:1 w:1) fn service_overweight() -> Weight { - // Minimum execution time: 26_656 nanoseconds. - Weight::from_ref_time(27_122_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 29_605 nanoseconds. + Weight::from_ref_time(30_173_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } From 05dc8f0daaec1a328bc6bc685ebe3f0cf78db568 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 16 Jan 2023 23:24:46 +0000 Subject: [PATCH 231/231] ".git/.scripts/commands/bench/bench.sh" runtime rococo-dev runtime_parachains::ump --- .../src/weights/runtime_parachains_ump.rs | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/runtime/rococo/src/weights/runtime_parachains_ump.rs b/runtime/rococo/src/weights/runtime_parachains_ump.rs index a82fd5dbee60..734554e8aa3a 100644 --- a/runtime/rococo/src/weights/runtime_parachains_ump.rs +++ b/runtime/rococo/src/weights/runtime_parachains_ump.rs @@ -16,23 +16,25 @@ //! Autogenerated weights for `runtime_parachains::ump` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// /home/benchbot/cargo_target_dir/production/polkadot // benchmark // pallet -// --chain=rococo-dev // --steps=50 // --repeat=20 -// --pallet=runtime_parachains::ump // --extrinsic=* // --execution=wasm // --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json +// --pallet=runtime_parachains::ump +// --chain=rococo-dev // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/runtime_parachains_ump.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,26 +48,27 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::ump::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 51200]`. fn process_upward_message(s: u32, ) -> Weight { - // Minimum execution time: 10_433 nanoseconds. - Weight::from_ref_time(6_809_084 as u64) - // Standard Error: 12 - .saturating_add(Weight::from_ref_time(1_973 as u64).saturating_mul(s as u64)) + // Minimum execution time: 10_224 nanoseconds. + Weight::from_ref_time(4_699_572) + // Standard Error: 11 + .saturating_add(Weight::from_ref_time(1_907).saturating_mul(s.into())) } // Storage: Ump NeedsDispatch (r:1 w:1) // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) // Storage: Ump RelayDispatchQueues (r:0 w:1) // Storage: Ump RelayDispatchQueueSize (r:0 w:1) fn clean_ump_after_outgoing() -> Weight { - // Minimum execution time: 8_932 nanoseconds. - Weight::from_ref_time(9_171_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Minimum execution time: 9_180 nanoseconds. + Weight::from_ref_time(9_354_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: Ump Overweight (r:1 w:1) + // Storage: Ump CounterForOverweight (r:1 w:1) fn service_overweight() -> Weight { - // Minimum execution time: 25_129 nanoseconds. - Weight::from_ref_time(25_441_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 28_704 nanoseconds. + Weight::from_ref_time(29_057_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } }