From d8b784e86fdc5cb58f8862d8eb49b281518f945b Mon Sep 17 00:00:00 2001 From: Valentin Fernandez Date: Mon, 22 May 2023 16:00:12 -0300 Subject: [PATCH 1/4] Drop Asset Benchmarks --- Cargo.lock | 17 ++++ pallets/benchmarks/Cargo.toml | 35 +++++++ pallets/benchmarks/src/benchmarking.rs | 57 +++++++++++ pallets/benchmarks/src/lib.rs | 43 ++++++++ pallets/benchmarks/src/weights.rs | 7 ++ primitives/xcm/src/lib.rs | 98 +++++++++++-------- runtime/trappist/Cargo.toml | 4 +- runtime/trappist/src/lib.rs | 20 +++- runtime/trappist/src/weights/mod.rs | 21 ++++ .../weights/trappist_runtime_benchmarks.rs | 66 +++++++++++++ runtime/trappist/src/xcm_config.rs | 4 +- 11 files changed, 330 insertions(+), 42 deletions(-) create mode 100644 pallets/benchmarks/Cargo.toml create mode 100644 pallets/benchmarks/src/benchmarking.rs create mode 100644 pallets/benchmarks/src/lib.rs create mode 100644 pallets/benchmarks/src/weights.rs create mode 100644 runtime/trappist/src/weights/mod.rs create mode 100644 runtime/trappist/src/weights/trappist_runtime_benchmarks.rs diff --git a/Cargo.lock b/Cargo.lock index da99bd55..8dd40b1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12412,12 +12412,29 @@ dependencies = [ "sp-transaction-pool", "sp-version", "substrate-wasm-builder", + "trappist-runtime-benchmarks", "xcm", "xcm-builder", "xcm-executor", "xcm-primitives", ] +[[package]] +name = "trappist-runtime-benchmarks" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", + "xcm", + "xcm-executor", +] + [[package]] name = "trappist-service" version = "1.0.0" diff --git a/pallets/benchmarks/Cargo.toml b/pallets/benchmarks/Cargo.toml new file mode 100644 index 00000000..37a06362 --- /dev/null +++ b/pallets/benchmarks/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "trappist-runtime-benchmarks" +version = "0.1.0" +edition = "2021" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", ] } +scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } + +xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } +xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } + +[dev-dependencies] +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } + +[features] +default = ["std"] +std = [ + "codec/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "sp-runtime/std", + "sp-std/std", + "xcm-executor/std" +] +runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] \ No newline at end of file diff --git a/pallets/benchmarks/src/benchmarking.rs b/pallets/benchmarks/src/benchmarking.rs new file mode 100644 index 00000000..ea5cfdf8 --- /dev/null +++ b/pallets/benchmarks/src/benchmarking.rs @@ -0,0 +1,57 @@ +use frame_benchmarking::benchmarks; +use sp_runtime::SaturatedConversion; +use xcm::prelude::AssetId as XcmAssetId; + +use crate::*; + +benchmarks! { + drop_assets_fungible { + let origin = MultiLocation::default(); + let asset_id = 1; + let location: MultiLocation = Parachain(asset_id).into(); + T::register_asset(asset_id.into(), location.clone()); + let asset = MultiAsset { id: XcmAssetId::Concrete(location), fun: Fungibility::Fungible(100) }; + } : { + T::DropAssets::drop_assets( + &origin, + asset.into(), + &XcmContext { + origin: Some(origin.clone()), + message_hash: [0; 32], + topic: None, + }, + ); + } + + drop_assets_native { + let origin = MultiLocation::default(); + let location = MultiLocation { parents: 0, interior: Here }; + let amount = T::ExistentialDeposit::get().saturated_into(); + let asset = MultiAsset { id: XcmAssetId::Concrete(location), fun: Fungibility::Fungible(amount) }; + } : { + T::DropAssets::drop_assets( + &origin, + asset.into(), + &XcmContext { + origin: Some(origin.clone()), + message_hash: [0; 32], + topic: None, + }, + ); + } + + drop_assets_default { + let origin = MultiLocation::default(); + let asset = MultiAsset { id: XcmAssetId::Abstract(Default::default()), fun: Fungibility::Fungible(0) }; + } : { + T::DropAssets::drop_assets( + &origin, + asset.into(), + &XcmContext { + origin: Some(origin.clone()), + message_hash: [0; 32], + topic: None, + }, + ); + } +} \ No newline at end of file diff --git a/pallets/benchmarks/src/lib.rs b/pallets/benchmarks/src/lib.rs new file mode 100644 index 00000000..ff13c555 --- /dev/null +++ b/pallets/benchmarks/src/lib.rs @@ -0,0 +1,43 @@ +//! Pallet for benchmarking. + +#![cfg_attr(not(feature = "std"), no_std)] + +use codec::Codec; +use frame_support::{pallet_prelude::*, traits::tokens::AssetId}; +use sp_runtime::traits::AtLeast32BitUnsigned; +use xcm::prelude::*; +use xcm_executor::traits::DropAssets; + +pub use pallet::*; +pub use weights::*; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; +pub mod weights; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + + #[pallet::config] + pub trait Config: frame_system::Config { + /// Identifier for the class of asset. + type AssetId: AssetId + From; + + /// The balance of an account. + type Balance: Parameter + Member + AtLeast32BitUnsigned + Codec + TypeInfo; + + /// The minimum amount required to keep an account open. + #[pallet::constant] + type ExistentialDeposit: Get; + + /// Handler for when some non-empty `Assets` value should be dropped. + type DropAssets: DropAssets; + + /// Handler to register an asset. + fn register_asset(asset_id: Self::AssetId, location: MultiLocation); + } + + #[pallet::pallet] + pub struct Pallet(_); +} \ No newline at end of file diff --git a/pallets/benchmarks/src/weights.rs b/pallets/benchmarks/src/weights.rs new file mode 100644 index 00000000..6c72e902 --- /dev/null +++ b/pallets/benchmarks/src/weights.rs @@ -0,0 +1,7 @@ +use frame_support::weights::Weight; + +pub trait WeightInfo { + fn drop_assets_fungible() -> Weight; + fn drop_assets_native() -> Weight; + fn drop_assets_default() -> Weight; +} \ No newline at end of file diff --git a/primitives/xcm/src/lib.rs b/primitives/xcm/src/lib.rs index 45a9a0b1..523d90a9 100644 --- a/primitives/xcm/src/lib.rs +++ b/primitives/xcm/src/lib.rs @@ -2,13 +2,12 @@ use frame_support::{ sp_runtime::SaturatedConversion, - traits::{fungibles::Inspect, Currency}, + traits::{fungibles::Inspect, Currency}, weights::Weight, }; -use sp_std::{borrow::Borrow, marker::PhantomData, vec::Vec}; +use sp_std::{borrow::Borrow, marker::PhantomData}; use xcm::{ latest::{ AssetId::Concrete, Fungibility::Fungible, Junctions::Here, MultiAsset, MultiLocation, - Weight, }, v3::XcmContext, }; @@ -63,15 +62,34 @@ impl< } } +pub trait DropAssetsWeigher { + fn fungible() -> Weight; + fn native() -> Weight; + fn default() -> Weight; +} + pub struct TrappistDropAssets< AssetId, AssetIdInfoGetter, AssetsPallet, BalancesPallet, XcmPallet, - AccoundId, ->(PhantomData<(AssetId, AssetIdInfoGetter, AssetsPallet, BalancesPallet, XcmPallet, AccoundId)>); -impl DropAssets + AccountId, + Weigher, +>( + PhantomData<( + AssetId, + AssetIdInfoGetter, + AssetsPallet, + BalancesPallet, + XcmPallet, + AccountId, + Weigher, + )>, +); + +impl + DropAssets for TrappistDropAssets< AssetId, AssetIdInfoGetter, @@ -79,52 +97,54 @@ impl where AssetId: Clone, AssetIdInfoGetter: AssetMultiLocationGetter, AssetsPallet: Inspect, BalancesPallet: Currency, XcmPallet: DropAssets, -{ + Weigher: DropAssetsWeigher, + { // assets are whatever the Holding Register had when XCVM halts - fn drop_assets(origin: &MultiLocation, assets: Assets, context: &XcmContext) -> Weight { - let multi_assets: Vec = assets.into(); - let mut trap: Vec = Vec::new(); + fn drop_assets(origin: &MultiLocation, mut assets: Assets, context: &XcmContext) -> Weight { + const NATIVE_LOCATION: MultiLocation = MultiLocation { parents: 0, interior: Here }; - for asset in multi_assets { - if let MultiAsset { id: Concrete(location), fun: Fungible(amount) } = asset.clone() { - // is location a fungible on AssetRegistry? - if let Some(asset_id) = AssetIdInfoGetter::get_asset_id(location.clone()) { - let min_balance = AssetsPallet::minimum_balance(asset_id); + let mut weight: Weight = { + assets.non_fungible.clear(); + Weigher::default() + }; - // only trap if amount ≥ min_balance - // do nothing otherwise (asset is lost) - if min_balance <= amount.saturated_into::() { - trap.push(asset); - } + assets.fungible.retain(|id, &mut amount| { + if let Concrete(location) = id { + match AssetIdInfoGetter::get_asset_id(*location) { + Some(asset_id) => { + weight.saturating_accrue(Weigher::fungible()); - // is location the native token? - } else if location == (MultiLocation { parents: 0, interior: Here }) { - let min_balance = BalancesPallet::minimum_balance(); + // only trap if amount ≥ min_balance + // do nothing otherwise (asset is lost) + amount.saturated_into::() >= + AssetsPallet::minimum_balance(asset_id) + }, + None => { + weight.saturating_accrue(Weigher::native()); - // only trap if amount ≥ min_balance - // do nothing otherwise (asset is lost) - if min_balance <= amount.saturated_into::() { - trap.push(asset); - } + // only trap if native token and amount ≥ min_balance + // do nothing otherwise (asset is lost) + *location == NATIVE_LOCATION && + amount.saturated_into::() >= + BalancesPallet::minimum_balance() + }, } + } else { + weight.saturating_accrue(Weigher::default()); + false } - } + }); - // TODO: put real weight of execution up until this point here - let mut weight: Weight = Weight::from_parts(0, 0); - - if !trap.is_empty() { - // we have filtered out non-compliant assets - // insert valid assets into the asset trap implemented by XcmPallet - weight += XcmPallet::drop_assets(origin, trap.into(), context); - } - - weight + // we have filtered out non-compliant assets + // insert valid assets into the asset trap implemented by XcmPallet + weight.saturating_add(XcmPallet::drop_assets(origin, assets, context)) } } + diff --git a/runtime/trappist/Cargo.toml b/runtime/trappist/Cargo.toml index fb1a7ecf..aa72d28d 100644 --- a/runtime/trappist/Cargo.toml +++ b/runtime/trappist/Cargo.toml @@ -104,7 +104,8 @@ pallet-dex-rpc-runtime-api = { version = "0.0.1", git = "https://github.com/pari pallet-chess = { git = "https://github.com/SubstrateChess/pallet-chess.git", default-features = false, branch = "polkadot-v0.9.40" } # Trappist Pallets -pallet-asset-registry = { version = "0.0.1", default-features = false, path = "../../pallets/asset-registry" } +pallet-asset-registry = { default-features = false, path = "../../pallets/asset-registry" } +trappist-runtime-benchmarks = { default-features = false, path = "../../pallets/benchmarks" } [features] default = ["std"] @@ -180,6 +181,7 @@ runtime-benchmarks = [ "frame-system-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "trappist-runtime-benchmarks/runtime-benchmarks", "pallet-assets/runtime-benchmarks", "pallet-asset-registry/runtime-benchmarks", "pallet-balances/runtime-benchmarks", diff --git a/runtime/trappist/src/lib.rs b/runtime/trappist/src/lib.rs index c76bcbc6..00244c93 100644 --- a/runtime/trappist/src/lib.rs +++ b/runtime/trappist/src/lib.rs @@ -25,9 +25,11 @@ pub mod constants; mod contracts; pub mod impls; pub mod xcm_config; +mod weights; pub use common::AssetIdForTrustBackedAssets; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; +use cumulus_primitives_core::BodyId; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, ConstU8, OpaqueMetadata}; use sp_runtime::{ @@ -62,6 +64,7 @@ use frame_system::{ EnsureRoot, EnsureSigned, }; +// Polkadot imports pub use parachains_common as common; pub use parachains_common::{ impls::AssetsToBlockAuthor, opaque, AccountId, AuraId, Balance, BlockNumber, Hash, Header, @@ -79,7 +82,6 @@ pub use sp_runtime::BuildStorage; // Polkadot imports use pallet_xcm::{EnsureXcm, IsMajorityOfBody}; use polkadot_runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; -use xcm::latest::prelude::BodyId; pub const MICROUNIT: Balance = 1_000_000; @@ -700,6 +702,7 @@ mod benches { define_benchmarks!( [frame_system, SystemBench::] [pallet_asset_registry, AssetRegistry] + [trappist_runtime_benchmarks, trappist_runtime_benchmarks::Pallet::] [pallet_balances, Balances] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] @@ -974,6 +977,21 @@ impl_runtime_apis! { use cumulus_pallet_session_benchmarking::Pallet as SessionBench; impl cumulus_pallet_session_benchmarking::Config for Runtime {} + use xcm_primitives::TrappistDropAssets; + use xcm::prelude::MultiLocation; + use crate::weights::TrappistDropAssetsWeigher; + impl trappist_runtime_benchmarks::Config for Runtime { + type AssetId = AssetIdForTrustBackedAssets; + type Balance = Balance; + type ExistentialDeposit = ConstU128; + type DropAssets = TrappistDropAssets; + + fn register_asset(asset_id: Self::AssetId, location: MultiLocation) { + pallet_asset_registry::AssetMultiLocationId::::insert(&location, asset_id); + pallet_asset_registry::AssetIdMultiLocation::::insert(asset_id, location); + } + } + let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), diff --git a/runtime/trappist/src/weights/mod.rs b/runtime/trappist/src/weights/mod.rs new file mode 100644 index 00000000..2d658f1f --- /dev/null +++ b/runtime/trappist/src/weights/mod.rs @@ -0,0 +1,21 @@ +use ::trappist_runtime_benchmarks::WeightInfo; +use xcm_primitives::DropAssetsWeigher; + +use crate::{Runtime, Weight}; + +mod trappist_runtime_benchmarks; + +pub struct TrappistDropAssetsWeigher(); +impl DropAssetsWeigher for TrappistDropAssetsWeigher { + fn fungible() -> Weight { + trappist_runtime_benchmarks::WeightInfo::::drop_assets_fungible() + } + + fn native() -> Weight { + trappist_runtime_benchmarks::WeightInfo::::drop_assets_native() + } + + fn default() -> Weight { + trappist_runtime_benchmarks::WeightInfo::::drop_assets_default() + } +} \ No newline at end of file diff --git a/runtime/trappist/src/weights/trappist_runtime_benchmarks.rs b/runtime/trappist/src/weights/trappist_runtime_benchmarks.rs new file mode 100644 index 00000000..49149203 --- /dev/null +++ b/runtime/trappist/src/weights/trappist_runtime_benchmarks.rs @@ -0,0 +1,66 @@ + +//! Autogenerated weights for `trappist_runtime_benchmarks` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-08, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `kalan-x1x`, CPU: `12th Gen Intel(R) Core(TM) i7-12800H` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/trappist-collator +// benchmark +// pallet +// --chain +// dev +// --pallet +// trappist_runtime_benchmarks +// --extrinsic +// * +// --steps +// 20 +// --repeat +// 10 +// --output +// runtime/trappist/src/weights/trappist_runtime_benchmarks.rs + +#![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 `trappist_runtime_benchmarks`. +pub struct WeightInfo(PhantomData); +impl trappist_runtime_benchmarks::WeightInfo for WeightInfo { + // Storage: AssetRegistry AssetMultiLocationId (r:1 w:0) + // Storage: Assets Asset (r:1 w:0) + fn drop_assets_fungible() -> Weight { + // Proof Size summary in bytes: + // Measured: `131` + // Estimated: `7762` + // Minimum execution time: 9_674_000 picoseconds. + Weight::from_parts(9_953_000, 0) + .saturating_add(Weight::from_parts(0, 7762)) + .saturating_add(T::DbWeight::get().reads(2)) + } + /// Storage: AssetRegistry AssetMultiLocationId (r:1 w:0) + /// Proof: AssetRegistry AssetMultiLocationId (max_values: None, max_size: Some(622), added: 3097, mode: MaxEncodedLen) + fn drop_assets_native() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `4087` + // Minimum execution time: 5_313_000 picoseconds. + Weight::from_parts(5_537_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + .saturating_add(T::DbWeight::get().reads(1)) + } + fn drop_assets_default() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_539_000 picoseconds. + Weight::from_parts(1_632_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } +} \ No newline at end of file diff --git a/runtime/trappist/src/xcm_config.rs b/runtime/trappist/src/xcm_config.rs index 7ef445fb..73ecb7f8 100644 --- a/runtime/trappist/src/xcm_config.rs +++ b/runtime/trappist/src/xcm_config.rs @@ -13,7 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{constants::fee::default_fee_per_second, impls::ToAuthor, AllPalletsWithSystem}; +use crate::{ + constants::fee::default_fee_per_second, impls::ToAuthor, AllPalletsWithSystem, weights::TrappistDropAssetsWeigher}; use super::{ AccountId, AssetRegistry, Assets, Balance, Balances, ParachainInfo, ParachainSystem, @@ -276,6 +277,7 @@ impl xcm_executor::Config for XcmConfig { Balances, PolkadotXcm, AccountId, + TrappistDropAssetsWeigher, >; type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; From 4bcd1599d196655198c22ee611d6135edd50424a Mon Sep 17 00:00:00 2001 From: Valentin Fernandez Date: Mon, 22 May 2023 16:00:32 -0300 Subject: [PATCH 2/4] fmt --- pallets/benchmarks/src/benchmarking.rs | 8 ++++---- pallets/benchmarks/src/lib.rs | 2 +- pallets/benchmarks/src/weights.rs | 2 +- primitives/xcm/src/lib.rs | 8 ++++---- runtime/trappist/src/lib.rs | 2 +- runtime/trappist/src/weights/mod.rs | 2 +- runtime/trappist/src/xcm_config.rs | 4 +++- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pallets/benchmarks/src/benchmarking.rs b/pallets/benchmarks/src/benchmarking.rs index ea5cfdf8..7d6da011 100644 --- a/pallets/benchmarks/src/benchmarking.rs +++ b/pallets/benchmarks/src/benchmarking.rs @@ -13,7 +13,7 @@ benchmarks! { let asset = MultiAsset { id: XcmAssetId::Concrete(location), fun: Fungibility::Fungible(100) }; } : { T::DropAssets::drop_assets( - &origin, + &origin, asset.into(), &XcmContext { origin: Some(origin.clone()), @@ -30,7 +30,7 @@ benchmarks! { let asset = MultiAsset { id: XcmAssetId::Concrete(location), fun: Fungibility::Fungible(amount) }; } : { T::DropAssets::drop_assets( - &origin, + &origin, asset.into(), &XcmContext { origin: Some(origin.clone()), @@ -45,7 +45,7 @@ benchmarks! { let asset = MultiAsset { id: XcmAssetId::Abstract(Default::default()), fun: Fungibility::Fungible(0) }; } : { T::DropAssets::drop_assets( - &origin, + &origin, asset.into(), &XcmContext { origin: Some(origin.clone()), @@ -54,4 +54,4 @@ benchmarks! { }, ); } -} \ No newline at end of file +} diff --git a/pallets/benchmarks/src/lib.rs b/pallets/benchmarks/src/lib.rs index ff13c555..34427034 100644 --- a/pallets/benchmarks/src/lib.rs +++ b/pallets/benchmarks/src/lib.rs @@ -40,4 +40,4 @@ pub mod pallet { #[pallet::pallet] pub struct Pallet(_); -} \ No newline at end of file +} diff --git a/pallets/benchmarks/src/weights.rs b/pallets/benchmarks/src/weights.rs index 6c72e902..411eef76 100644 --- a/pallets/benchmarks/src/weights.rs +++ b/pallets/benchmarks/src/weights.rs @@ -4,4 +4,4 @@ pub trait WeightInfo { fn drop_assets_fungible() -> Weight; fn drop_assets_native() -> Weight; fn drop_assets_default() -> Weight; -} \ No newline at end of file +} diff --git a/primitives/xcm/src/lib.rs b/primitives/xcm/src/lib.rs index 523d90a9..1b40305d 100644 --- a/primitives/xcm/src/lib.rs +++ b/primitives/xcm/src/lib.rs @@ -2,7 +2,8 @@ use frame_support::{ sp_runtime::SaturatedConversion, - traits::{fungibles::Inspect, Currency}, weights::Weight, + traits::{fungibles::Inspect, Currency}, + weights::Weight, }; use sp_std::{borrow::Borrow, marker::PhantomData}; use xcm::{ @@ -97,7 +98,7 @@ impl where AssetId: Clone, AssetIdInfoGetter: AssetMultiLocationGetter, @@ -105,7 +106,7 @@ impl, XcmPallet: DropAssets, Weigher: DropAssetsWeigher, - { +{ // assets are whatever the Holding Register had when XCVM halts fn drop_assets(origin: &MultiLocation, mut assets: Assets, context: &XcmContext) -> Weight { const NATIVE_LOCATION: MultiLocation = MultiLocation { parents: 0, interior: Here }; @@ -147,4 +148,3 @@ impl Weight { trappist_runtime_benchmarks::WeightInfo::::drop_assets_default() } -} \ No newline at end of file +} diff --git a/runtime/trappist/src/xcm_config.rs b/runtime/trappist/src/xcm_config.rs index 73ecb7f8..e24ae670 100644 --- a/runtime/trappist/src/xcm_config.rs +++ b/runtime/trappist/src/xcm_config.rs @@ -14,7 +14,9 @@ // limitations under the License. use crate::{ - constants::fee::default_fee_per_second, impls::ToAuthor, AllPalletsWithSystem, weights::TrappistDropAssetsWeigher}; + constants::fee::default_fee_per_second, impls::ToAuthor, weights::TrappistDropAssetsWeigher, + AllPalletsWithSystem, +}; use super::{ AccountId, AssetRegistry, Assets, Balance, Balances, ParachainInfo, ParachainSystem, From 8db6d1b3b8a9350b456f8e08d1a9072691b9e0b7 Mon Sep 17 00:00:00 2001 From: Valentin Fernandez Date: Tue, 23 May 2023 08:48:49 -0300 Subject: [PATCH 3/4] fmt --- runtime/trappist/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/runtime/trappist/src/lib.rs b/runtime/trappist/src/lib.rs index 214ab8fd..1586e18d 100644 --- a/runtime/trappist/src/lib.rs +++ b/runtime/trappist/src/lib.rs @@ -32,13 +32,14 @@ use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use cumulus_primitives_core::BodyId; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, ConstU8, OpaqueMetadata}; +#[cfg(any(feature = "std", test))] +pub use sp_runtime::BuildStorage; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Perbill, Percent, Permill, }; - use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; @@ -76,9 +77,6 @@ use impls::DealWithFees; use xcm_config::{CollatorSelectionUpdateOrigin, RelayLocation}; -#[cfg(any(feature = "std", test))] -pub use sp_runtime::BuildStorage; - // Polkadot imports use pallet_xcm::{EnsureXcm, IsMajorityOfBody}; use polkadot_runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; From a93bfba331b6812858fe4f38a84fa53664999036 Mon Sep 17 00:00:00 2001 From: Valentin Fernandez Date: Tue, 23 May 2023 10:20:18 -0300 Subject: [PATCH 4/4] asset-registry fix --- pallets/asset-registry/src/lib.rs | 2 +- primitives/xcm/src/lib.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index 24ccc330..7aa2eb7f 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -136,7 +136,7 @@ pub mod pallet { AssetIdMultiLocation::::get(asset_id) } - fn get_asset_id(asset_type: MultiLocation) -> Option> { + fn get_asset_id(asset_type: &MultiLocation) -> Option> { AssetMultiLocationId::::get(asset_type) } } diff --git a/primitives/xcm/src/lib.rs b/primitives/xcm/src/lib.rs index 1b40305d..f30a4f55 100644 --- a/primitives/xcm/src/lib.rs +++ b/primitives/xcm/src/lib.rs @@ -27,7 +27,7 @@ where AssetIdInfoGetter: AssetMultiLocationGetter, { fn convert_ref(asset_multi_location: impl Borrow) -> Result { - AssetIdInfoGetter::get_asset_id(asset_multi_location.borrow().clone()).ok_or(()) + AssetIdInfoGetter::get_asset_id(asset_multi_location.borrow()).ok_or(()) } fn reverse_ref(asset_id: impl Borrow) -> Result { @@ -37,7 +37,7 @@ where pub trait AssetMultiLocationGetter { fn get_asset_multi_location(asset_id: AssetId) -> Option; - fn get_asset_id(asset_multi_location: MultiLocation) -> Option; + fn get_asset_id(asset_multi_location: &MultiLocation) -> Option; } pub struct ConvertedRegisteredAssetId( @@ -118,7 +118,7 @@ impl { weight.saturating_accrue(Weigher::fungible());