From 2c3ff59e53ff2f061b12043cc3691dd4c4aabd05 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Fri, 22 Jul 2022 15:06:03 +0300 Subject: [PATCH 01/22] Compiles, but doens't work Signed-off-by: Georgi Zlatarev --- Cargo.lock | 1 + pallets/asset-manager/src/lib.rs | 8 +++ primitives/manta/src/assets.rs | 4 ++ runtime/calamari/Cargo.toml | 2 + runtime/calamari/src/assets_config.rs | 18 ++++++- runtime/calamari/src/lib.rs | 70 ++++++++++++++++++++++++++- runtime/dolphin/src/assets_config.rs | 18 ++++++- 7 files changed, 118 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f31472b99..821acf927 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1174,6 +1174,7 @@ dependencies = [ "pallet-tx-pause", "pallet-utility", "pallet-xcm", + "pallet-xcm-benchmarks", "parachain-info", "parity-scale-codec", "polkadot-parachain", diff --git a/pallets/asset-manager/src/lib.rs b/pallets/asset-manager/src/lib.rs index fe773b66c..ebd7beb2b 100644 --- a/pallets/asset-manager/src/lib.rs +++ b/pallets/asset-manager/src/lib.rs @@ -138,6 +138,14 @@ pub mod pallet { AssetIdLocation::::insert(&asset_id, &location); AssetIdMetadata::::insert(&asset_id, &metadata); LocationAssetId::::insert(&location, &asset_id); + + let asset_id = self.start_id; + let metadata = >::RelayAssetMetadata::get(); + let location = >::RelayAssetLocation::get(); + AssetIdLocation::::insert(&asset_id, &location); + AssetIdMetadata::::insert(&asset_id, &metadata); + LocationAssetId::::insert(&location, &asset_id); + NextAssetId::::set(self.start_id + 1); } } diff --git a/primitives/manta/src/assets.rs b/primitives/manta/src/assets.rs index ccf28e2e9..f41a33f57 100644 --- a/primitives/manta/src/assets.rs +++ b/primitives/manta/src/assets.rs @@ -94,9 +94,13 @@ where /// Native Asset Location type NativeAssetLocation: Get; + type RelayAssetLocation: Get; + /// Native Asset Metadata type NativeAssetMetadata: Get; + type RelayAssetMetadata: Get; + /// The trait we use to register Assets and mint assets type AssetRegistrar: AssetRegistrar; diff --git a/runtime/calamari/Cargo.toml b/runtime/calamari/Cargo.toml index 78dac8c0f..09d22d1bb 100644 --- a/runtime/calamari/Cargo.toml +++ b/runtime/calamari/Cargo.toml @@ -80,6 +80,7 @@ polkadot-primitives = { git = 'https://github.com/paritytech/polkadot.git', defa xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.22" } xcm-builder = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.22" } xcm-executor = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.22" } +pallet-xcm-benchmarks = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.22", optional = true } # Third party (vendored) dependencies orml-traits = { git = "https://github.com/manta-network/open-runtime-module-library.git", default-features = false, rev = "cc26ffa" } @@ -132,6 +133,7 @@ runtime-benchmarks = [ 'pallet-assets/runtime-benchmarks', 'pallet-asset-manager/runtime-benchmarks', 'cumulus-pallet-xcmp-queue/runtime-benchmarks', + 'pallet-xcm-benchmarks', ] try-runtime = [ 'frame-executive/try-runtime', diff --git a/runtime/calamari/src/assets_config.rs b/runtime/calamari/src/assets_config.rs index 602699210..feb850af0 100644 --- a/runtime/calamari/src/assets_config.rs +++ b/runtime/calamari/src/assets_config.rs @@ -32,7 +32,10 @@ use frame_support::{pallet_prelude::DispatchResult, parameter_types, traits::Con use frame_system::EnsureRoot; -use xcm::VersionedMultiLocation; +use xcm::{ + v1::{Junctions::Here, MultiLocation}, + VersionedMultiLocation, +}; parameter_types! { // Does not really matter as this will be only called by root @@ -113,6 +116,17 @@ parameter_types! { is_frozen: false, is_sufficient: true, }; + pub RelayAssetLocation: AssetLocation = AssetLocation( + VersionedMultiLocation::V1(MultiLocation::new(1, Here))); + pub RelayAssetMetadata: AssetRegistrarMetadata = AssetRegistrarMetadata { + name: b"KSM".to_vec(), + symbol: b"Kusama".to_vec(), + decimals: 12, + min_balance: 1, + evm_address: None, + is_frozen: false, + is_sufficient: true, + }; pub const AssetManagerPalletId: PalletId = ASSET_MANAGER_PALLET_ID; } @@ -128,7 +142,9 @@ impl AssetConfig for CalamariAssetConfig { type StartNonNativeAssetId = StartNonNativeAssetId; type AssetRegistrarMetadata = AssetRegistrarMetadata; type NativeAssetLocation = NativeAssetLocation; + type RelayAssetLocation = RelayAssetLocation; type NativeAssetMetadata = NativeAssetMetadata; + type RelayAssetMetadata = RelayAssetMetadata; type StorageMetadata = AssetStorageMetadata; type AssetLocation = AssetLocation; type AssetRegistrar = CalamariAssetRegistrar; diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index 8f7155b24..d273f3458 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -57,6 +57,7 @@ use manta_primitives::{ use runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; use session_key_primitives::{AuraId, NimbusId, VrfId}; use sp_runtime::{Perbill, Permill}; +use xcm_config::{CheckingAccount, LocationToAccountId, XcmExecutorConfig}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -841,6 +842,8 @@ mod benches { [pallet_assets, Assets] // XCM [cumulus_pallet_xcmp_queue, XcmpQueue] + [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::] + [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::] // Manta pallets [calamari_vesting, CalamariVesting] [pallet_tx_pause, TransactionPause] @@ -989,7 +992,7 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError}; use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} @@ -997,6 +1000,71 @@ impl_runtime_apis! { use cumulus_pallet_session_benchmarking::Pallet as SessionBench; impl cumulus_pallet_session_benchmarking::Config for Runtime {} + impl pallet_xcm_benchmarks::Config for Runtime { + type XcmConfig = XcmExecutorConfig; + type AccountIdConverter = LocationToAccountId; + + fn valid_destination() -> Result { + Ok(MultiLocation::new(1, X1(Parachain(3000)))) + } + fn worst_case_holding() -> MultiAssets { + // Kusama only knows about KSM. + vec![MultiAsset{ + id: Concrete(MultiLocation { parents: 1, interior: Here }), + fun: Fungible(1_000_000 * KMA), + }].into() + } + } + + parameter_types! { + pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( + MultiLocation { parents: 1, interior: X1(Parachain(1000)) }, + MultiAsset { fun: Fungible(1 * KMA), id: Concrete(MultiLocation { parents: 1, interior: Here }) }, + )); + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( + MultiLocation { parents: 1, interior: X1(Parachain(1000)) }, + MultiAsset { fun: Fungible(1 * KMA), id: Concrete(MultiLocation { parents: 1, interior: Here }) }, + )); + } + + impl pallet_xcm_benchmarks::fungible::Config for Runtime { + type TransactAsset = Balances; + + type CheckedAccount = CheckingAccount; + type TrustedTeleporter = TrustedTeleporter; + type TrustedReserve = TrustedReserve; + + fn get_multi_asset() -> MultiAsset { + MultiAsset { + id: Concrete(MultiLocation { parents: 1, interior: X1(Parachain(2084)) }), + fun: Fungible(1 * KMA), + } + } + } + + impl pallet_xcm_benchmarks::generic::Config for Runtime { + type Call = Call; + + fn worst_case_response() -> (u64, Response) { + (0u64, Response::Version(Default::default())) + } + + fn transact_origin() -> Result { + Ok(MultiLocation::new(1, X1(Parachain(1000)))) + } + + fn subscribe_origin() -> Result { + Ok(MultiLocation::new(1, X1(Parachain(1000)))) + } + + fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { + let origin = MultiLocation::new(1, X1(Parachain(1000))); + let assets: MultiAssets = (Concrete(MultiLocation { parents: 1, interior: Here }), 1_000 * KMA).into(); + let ticket = MultiLocation { parents: 0, interior: Here }; + Ok((origin, ticket, assets)) + } + } + let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), diff --git a/runtime/dolphin/src/assets_config.rs b/runtime/dolphin/src/assets_config.rs index c81603836..d37b6e239 100644 --- a/runtime/dolphin/src/assets_config.rs +++ b/runtime/dolphin/src/assets_config.rs @@ -30,7 +30,10 @@ use manta_primitives::{ use frame_support::{pallet_prelude::DispatchResult, parameter_types, PalletId}; use frame_system::EnsureRoot; -use xcm::VersionedMultiLocation; +use xcm::{ + v1::{Junctions::Here, MultiLocation}, + VersionedMultiLocation, +}; parameter_types! { pub const AssetDeposit: Balance = 0; // Does not really matter as this will be only called by root @@ -123,6 +126,17 @@ parameter_types! { is_frozen: false, is_sufficient: true, }; + pub RelayAssetLocation: AssetLocation = AssetLocation( + VersionedMultiLocation::V1(MultiLocation::new(1, Here))); + pub RelayAssetMetadata: AssetRegistrarMetadata = AssetRegistrarMetadata { + name: b"KSM".to_vec(), + symbol: b"Kusama".to_vec(), + decimals: 12, + min_balance: 1, + evm_address: None, + is_frozen: false, + is_sufficient: true, + }; pub const AssetManagerPalletId: PalletId = ASSET_MANAGER_PALLET_ID; } @@ -139,6 +153,8 @@ impl AssetConfig for DolphinAssetConfig { type AssetRegistrarMetadata = AssetRegistrarMetadata; type NativeAssetLocation = NativeAssetLocation; type NativeAssetMetadata = NativeAssetMetadata; + type RelayAssetLocation = RelayAssetLocation; + type RelayAssetMetadata = RelayAssetMetadata; type StorageMetadata = AssetStorageMetadata; type AssetLocation = AssetLocation; type AssetRegistrar = MantaAssetRegistrar; From 89bec655e28b95bcbbe493421cf3c43f86201cb5 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 10:22:44 +0300 Subject: [PATCH 02/22] Compiles and works Signed-off-by: Georgi Zlatarev --- runtime/calamari/src/lib.rs | 68 +++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index d273f3458..63bccca7d 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -57,7 +57,7 @@ use manta_primitives::{ use runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; use session_key_primitives::{AuraId, NimbusId, VrfId}; use sp_runtime::{Perbill, Permill}; -use xcm_config::{CheckingAccount, LocationToAccountId, XcmExecutorConfig}; +use xcm_config::{LocationToAccountId, XcmExecutorConfig}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -1000,44 +1000,69 @@ impl_runtime_apis! { use cumulus_pallet_session_benchmarking::Pallet as SessionBench; impl cumulus_pallet_session_benchmarking::Config for Runtime {} + use pallet_xcm_benchmarks::asset_instance_from; + impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = XcmExecutorConfig; type AccountIdConverter = LocationToAccountId; fn valid_destination() -> Result { - Ok(MultiLocation::new(1, X1(Parachain(3000)))) + Ok( MultiLocation { parents: 1, interior: Here }) } fn worst_case_holding() -> MultiAssets { - // Kusama only knows about KSM. - vec![MultiAsset{ - id: Concrete(MultiLocation { parents: 1, interior: Here }), - fun: Fungible(1_000_000 * KMA), - }].into() + // // Kusama only knows about KSM. + // vec![MultiAsset{ + // id: Concrete(MultiLocation { parents: 1, interior: Here }), + // fun: Fungible(1_000_000 * KMA), + // }].into() + + // A mix of fungible, non-fungible, and concrete assets. + const HOLDING_FUNGIBLES: u32 = 100; + const HOLDING_NON_FUNGIBLES: u32 = 100; + let fungibles_amount: u128 = 100; + let mut assets = (0..HOLDING_FUNGIBLES) + .map(|i| { + MultiAsset { + id: Concrete(GeneralIndex(i as u128).into()), + fun: Fungible(fungibles_amount * i as u128), + } + .into() + }) + .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) + .chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset { + id: Concrete(GeneralIndex(i as u128).into()), + fun: NonFungible(asset_instance_from(i)), + })) + .collect::>(); + + assets.push(MultiAsset{ + id: Concrete(MultiLocation { parents: 1, interior: X1(Parachain(2084)) }), + fun: Fungible(1_000_000 * KMA), + }); + assets.into() } } parameter_types! { - pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( - MultiLocation { parents: 1, interior: X1(Parachain(1000)) }, - MultiAsset { fun: Fungible(1 * KMA), id: Concrete(MultiLocation { parents: 1, interior: Here }) }, - )); + pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = None; pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( - MultiLocation { parents: 1, interior: X1(Parachain(1000)) }, - MultiAsset { fun: Fungible(1 * KMA), id: Concrete(MultiLocation { parents: 1, interior: Here }) }, + MultiLocation { parents: 1, interior: Here }, + MultiAsset { fun: Fungible(1_000_000_000_000), id: Concrete(MultiLocation { parents: 1, interior: Here }) }, )); + pub const CheckedAccount: Option = None; } impl pallet_xcm_benchmarks::fungible::Config for Runtime { type TransactAsset = Balances; - type CheckedAccount = CheckingAccount; + type CheckedAccount = CheckedAccount; type TrustedTeleporter = TrustedTeleporter; type TrustedReserve = TrustedReserve; fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(MultiLocation { parents: 1, interior: X1(Parachain(2084)) }), - fun: Fungible(1 * KMA), + fun: Fungible(1_000_000_000_000), } } } @@ -1050,16 +1075,16 @@ impl_runtime_apis! { } fn transact_origin() -> Result { - Ok(MultiLocation::new(1, X1(Parachain(1000)))) + Ok(MultiLocation { parents: 1, interior: Here }) } fn subscribe_origin() -> Result { - Ok(MultiLocation::new(1, X1(Parachain(1000)))) + Ok(MultiLocation { parents: 1, interior: Here }) } fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { - let origin = MultiLocation::new(1, X1(Parachain(1000))); - let assets: MultiAssets = (Concrete(MultiLocation { parents: 1, interior: Here }), 1_000 * KMA).into(); + let origin = MultiLocation { parents: 1, interior: X1(Parachain(2084)) }; + let assets: MultiAssets = (Concrete(MultiLocation { parents: 1, interior: X1(Parachain(2084)) }), 1_000_000_000_000_000).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } @@ -1078,13 +1103,14 @@ impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), // Treasury Account hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(), - ]; + hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385").to_vec().into(), + ]; let mut batches = Vec::::new(); let params = (&config, &whitelist); add_benchmarks!(params, batches); - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + // if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } } From ec3a9486f08b65130d86da61bf8919de7d5898d3 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 10:39:20 +0300 Subject: [PATCH 03/22] Clean up Signed-off-by: Georgi Zlatarev --- runtime/calamari/src/lib.rs | 46 ++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index 63bccca7d..d27b83d2d 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -57,7 +57,7 @@ use manta_primitives::{ use runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; use session_key_primitives::{AuraId, NimbusId, VrfId}; use sp_runtime::{Perbill, Permill}; -use xcm_config::{LocationToAccountId, XcmExecutorConfig}; +use xcm_config::{KsmLocation, LocationToAccountId, XcmExecutorConfig}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -1002,20 +1002,25 @@ impl_runtime_apis! { use pallet_xcm_benchmarks::asset_instance_from; + parameter_types! { + pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = None; + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( + KsmLocation::get(), + MultiAsset { fun: Fungible(1_000_000_000_000), id: Concrete(KsmLocation::get()) }, + )); + pub const CheckedAccount: Option = None; + pub KmaLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(2084))); + } + impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = XcmExecutorConfig; type AccountIdConverter = LocationToAccountId; fn valid_destination() -> Result { - Ok( MultiLocation { parents: 1, interior: Here }) + Ok(KsmLocation::get()) } - fn worst_case_holding() -> MultiAssets { - // // Kusama only knows about KSM. - // vec![MultiAsset{ - // id: Concrete(MultiLocation { parents: 1, interior: Here }), - // fun: Fungible(1_000_000 * KMA), - // }].into() + fn worst_case_holding() -> MultiAssets { // A mix of fungible, non-fungible, and concrete assets. const HOLDING_FUNGIBLES: u32 = 100; const HOLDING_NON_FUNGIBLES: u32 = 100; @@ -1036,22 +1041,13 @@ impl_runtime_apis! { .collect::>(); assets.push(MultiAsset{ - id: Concrete(MultiLocation { parents: 1, interior: X1(Parachain(2084)) }), + id: Concrete(KmaLocation::get()), fun: Fungible(1_000_000 * KMA), }); assets.into() } } - parameter_types! { - pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = None; - pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( - MultiLocation { parents: 1, interior: Here }, - MultiAsset { fun: Fungible(1_000_000_000_000), id: Concrete(MultiLocation { parents: 1, interior: Here }) }, - )); - pub const CheckedAccount: Option = None; - } - impl pallet_xcm_benchmarks::fungible::Config for Runtime { type TransactAsset = Balances; @@ -1061,8 +1057,8 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { - id: Concrete(MultiLocation { parents: 1, interior: X1(Parachain(2084)) }), - fun: Fungible(1_000_000_000_000), + id: Concrete(KmaLocation::get()), + fun: Fungible(1 * KMA), } } } @@ -1075,16 +1071,16 @@ impl_runtime_apis! { } fn transact_origin() -> Result { - Ok(MultiLocation { parents: 1, interior: Here }) + Ok(KsmLocation::get()) } fn subscribe_origin() -> Result { - Ok(MultiLocation { parents: 1, interior: Here }) + Ok(KsmLocation::get()) } fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { - let origin = MultiLocation { parents: 1, interior: X1(Parachain(2084)) }; - let assets: MultiAssets = (Concrete(MultiLocation { parents: 1, interior: X1(Parachain(2084)) }), 1_000_000_000_000_000).into(); + let origin = KmaLocation::get(); + let assets: MultiAssets = (Concrete(KmaLocation::get()), 1_000 * KMA).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } @@ -1103,14 +1099,12 @@ impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), // Treasury Account hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(), - hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385").to_vec().into(), ]; let mut batches = Vec::::new(); let params = (&config, &whitelist); add_benchmarks!(params, batches); - // if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } } From 8556789c92614db5326900438b0807d3da7b1a55 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 11:05:19 +0300 Subject: [PATCH 04/22] Use new weights Signed-off-by: Georgi Zlatarev --- .github/resources/xcm-weight-template.hbs | 68 +++++++ runtime/calamari/Cargo.toml | 1 + runtime/calamari/src/weights/mod.rs | 1 + runtime/calamari/src/weights/xcm/mod.rs | 179 ++++++++++++++++++ .../xcm/pallet_xcm_benchmarks_fungible.rs | 114 +++++++++++ .../xcm/pallet_xcm_benchmarks_generic.rs | 136 +++++++++++++ runtime/calamari/src/xcm_config.rs | 15 +- 7 files changed, 508 insertions(+), 6 deletions(-) create mode 100644 .github/resources/xcm-weight-template.hbs create mode 100644 runtime/calamari/src/weights/xcm/mod.rs create mode 100644 runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs create mode 100644 runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs diff --git a/.github/resources/xcm-weight-template.hbs b/.github/resources/xcm-weight-template.hbs new file mode 100644 index 000000000..6cfe4fdf4 --- /dev/null +++ b/.github/resources/xcm-weight-template.hbs @@ -0,0 +1,68 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 . + + +//! Autogenerated weights for `{{pallet}}` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} +//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}` +//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} + +// Executed Command: +{{#each args as |arg|}} +// {{arg}} +{{/each}} + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weights for `{{pallet}}`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + {{#each benchmarks as |benchmark|}} + {{#each benchmark.comments as |comment|}} + // {{comment}} + {{/each}} + pub(crate) fn {{benchmark.name~}} + ( + {{~#each benchmark.components as |c| ~}} + {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} + ) -> Weight { + ({{underscore benchmark.base_weight}} as Weight) + {{#each benchmark.component_weight as |cw|}} + // Standard Error: {{underscore cw.error}} + .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + {{/each}} + {{#if (ne benchmark.base_reads "0")}} + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + {{/if}} + {{#each benchmark.component_reads as |cr|}} + .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + {{/each}} + {{#if (ne benchmark.base_writes "0")}} + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + {{/if}} + {{#each benchmark.component_writes as |cw|}} + .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + {{/each}} + } + {{/each}} +} \ No newline at end of file diff --git a/runtime/calamari/Cargo.toml b/runtime/calamari/Cargo.toml index 09d22d1bb..d4f028fbf 100644 --- a/runtime/calamari/Cargo.toml +++ b/runtime/calamari/Cargo.toml @@ -221,4 +221,5 @@ std = [ 'pallet-asset-manager/std', 'orml-traits/std', 'orml-xtokens/std', + 'pallet-xcm-benchmarks/std', ] diff --git a/runtime/calamari/src/weights/mod.rs b/runtime/calamari/src/weights/mod.rs index 908bd831e..7c0f11c28 100644 --- a/runtime/calamari/src/weights/mod.rs +++ b/runtime/calamari/src/weights/mod.rs @@ -34,3 +34,4 @@ pub mod pallet_timestamp; pub mod pallet_treasury; pub mod pallet_tx_pause; pub mod pallet_utility; +pub mod xcm; diff --git a/runtime/calamari/src/weights/xcm/mod.rs b/runtime/calamari/src/weights/xcm/mod.rs new file mode 100644 index 000000000..e41f4c4d3 --- /dev/null +++ b/runtime/calamari/src/weights/xcm/mod.rs @@ -0,0 +1,179 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 . + +mod pallet_xcm_benchmarks_fungible; +mod pallet_xcm_benchmarks_generic; + +use crate::Runtime; +use frame_support::weights::Weight; +use sp_std::prelude::*; +use xcm::{latest::prelude::*, DoubleEncoded}; + +use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; +use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; + +trait WeighMultiAssets { + fn weigh_multi_assets(&self, weight: Weight) -> Weight; +} + +const MAX_ASSETS: u32 = 100; + +impl WeighMultiAssets for MultiAssetFilter { + fn weigh_multi_assets(&self, weight: Weight) -> Weight { + match self { + Self::Definite(assets) => { + (assets.inner().into_iter().count() as Weight).saturating_mul(weight) + } + Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(weight), + } + } +} + +impl WeighMultiAssets for MultiAssets { + fn weigh_multi_assets(&self, weight: Weight) -> Weight { + (self.inner().into_iter().count() as Weight).saturating_mul(weight) + } +} + +pub struct CalamariXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for CalamariXcmWeight { + fn withdraw_asset(assets: &MultiAssets) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) + } + fn reserve_asset_deposited(assets: &MultiAssets) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited()) + } + fn receive_teleported_asset(_assets: &MultiAssets) -> Weight { + unimplemented!() + } + fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> Weight { + XcmGeneric::::query_response() + } + fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::transfer_asset()) + } + fn transfer_reserve_asset( + assets: &MultiAssets, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::transfer_reserve_asset()) + } + fn transact( + _origin_type: &OriginKind, + _require_weight_at_most: &u64, + _call: &DoubleEncoded, + ) -> Weight { + XcmGeneric::::transact() + } + fn hrmp_new_channel_open_request( + _sender: &u32, + _max_message_size: &u32, + _max_capacity: &u32, + ) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn hrmp_channel_accepted(_recipient: &u32) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn clear_origin() -> Weight { + XcmGeneric::::clear_origin() + } + fn descend_origin(_who: &InteriorMultiLocation) -> Weight { + XcmGeneric::::descend_origin() + } + fn report_error( + _query_id: &QueryId, + _dest: &MultiLocation, + _max_response_weight: &u64, + ) -> Weight { + XcmGeneric::::report_error() + } + + fn deposit_asset( + assets: &MultiAssetFilter, + _max_assets: &u32, + _dest: &MultiLocation, + ) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()) + } + fn deposit_reserve_asset( + assets: &MultiAssetFilter, + _max_assets: &u32, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::deposit_reserve_asset()) + } + fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> Weight { + Weight::MAX + } + fn initiate_reserve_withdraw( + assets: &MultiAssetFilter, + _reserve: &MultiLocation, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_multi_assets(XcmGeneric::::initiate_reserve_withdraw()) + } + fn initiate_teleport( + assets: &MultiAssetFilter, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()) + } + fn query_holding( + _query_id: &u64, + _dest: &MultiLocation, + _assets: &MultiAssetFilter, + _max_response_weight: &u64, + ) -> Weight { + XcmGeneric::::query_holding() + } + fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { + XcmGeneric::::buy_execution() + } + fn refund_surplus() -> Weight { + XcmGeneric::::refund_surplus() + } + fn set_error_handler(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_error_handler() + } + fn set_appendix(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_appendix() + } + fn clear_error() -> Weight { + XcmGeneric::::clear_error() + } + fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight { + XcmGeneric::::claim_asset() + } + fn trap(_code: &u64) -> Weight { + XcmGeneric::::trap() + } + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> Weight { + XcmGeneric::::subscribe_version() + } + fn unsubscribe_version() -> Weight { + XcmGeneric::::unsubscribe_version() + } +} diff --git a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs new file mode 100644 index 000000000..9ef6db537 --- /dev/null +++ b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -0,0 +1,114 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 . + + +//! Autogenerated weights for `pallet_xcm_benchmarks::fungible` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: ``, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("calamari-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/manta +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --pallet=pallet_xcm_benchmarks::fungible +// --chain=calamari-dev +// --template=.github/resources/xcm-weight-template.hbs +// --output=pallet_xcm_benchmarks_fungible.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weights for `pallet_xcm_benchmarks::fungible`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:1 w:1) + pub(crate) fn withdraw_asset() -> Weight { + (36_899_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:2 w:2) + pub(crate) fn transfer_asset() -> Weight { + (55_634_000 as Weight) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn transfer_reserve_asset() -> Weight { + (71_444_000 as Weight) + .saturating_add(T::DbWeight::get().reads(9 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + pub(crate) fn reserve_asset_deposited() -> Weight { + (1_634_000 as Weight) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:1 w:1) + pub(crate) fn deposit_asset() -> Weight { + (38_853_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn deposit_reserve_asset() -> Weight { + (55_815_000 as Weight) + .saturating_add(T::DbWeight::get().reads(8 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn initiate_teleport() -> Weight { + (23_524_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} \ No newline at end of file diff --git a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs new file mode 100644 index 000000000..2fb076e53 --- /dev/null +++ b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -0,0 +1,136 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 . + + +//! Autogenerated weights for `pallet_xcm_benchmarks::generic` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: ``, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("calamari-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/manta +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --pallet=pallet_xcm_benchmarks::generic +// --chain=calamari-dev +// --template=.github/resources/xcm-weight-template.hbs +// --output=pallet_xcm_benchmarks_generic.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weights for `pallet_xcm_benchmarks::generic`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn query_holding() -> Weight { + (638_329_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + pub(crate) fn buy_execution() -> Weight { + (3_046_000 as Weight) + } + // Storage: PolkadotXcm Queries (r:1 w:0) + pub(crate) fn query_response() -> Weight { + (10_800_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + pub(crate) fn transact() -> Weight { + (11_201_000 as Weight) + } + pub(crate) fn refund_surplus() -> Weight { + (3_316_000 as Weight) + } + pub(crate) fn set_error_handler() -> Weight { + (671_000 as Weight) + } + pub(crate) fn set_appendix() -> Weight { + (681_000 as Weight) + } + pub(crate) fn clear_error() -> Weight { + (661_000 as Weight) + } + pub(crate) fn descend_origin() -> Weight { + (1_382_000 as Weight) + } + pub(crate) fn clear_origin() -> Weight { + (672_000 as Weight) + } + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn report_error() -> Weight { + (12_543_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: PolkadotXcm AssetTraps (r:1 w:1) + pub(crate) fn claim_asset() -> Weight { + (5_871_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 { + (691_000 as Weight) + } + // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn subscribe_version() -> Weight { + (16_621_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1) + pub(crate) fn unsubscribe_version() -> Weight { + (2_756_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn initiate_reserve_withdraw() -> Weight { + (805_984_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} \ No newline at end of file diff --git a/runtime/calamari/src/xcm_config.rs b/runtime/calamari/src/xcm_config.rs index 4eda6d942..ee24a44fc 100644 --- a/runtime/calamari/src/xcm_config.rs +++ b/runtime/calamari/src/xcm_config.rs @@ -53,9 +53,9 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ConvertedConcreteAssetId, - EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, LocationInverter, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, + EnsureXcmOrigin, FixedRateOfFungible, LocationInverter, ParentAsSuperuser, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, WeightInfoBounds, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -213,7 +213,8 @@ impl Config for XcmExecutorConfig { type IsTeleporter = (); type LocationInverter = LocationInverter; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = + WeightInfoBounds, Call, MaxInstructions>; // Trader is the means to purchasing weight credit for XCM execution. // We define two traders: // The first one will charge parachain's native currency, who's `MultiLocation` @@ -258,7 +259,8 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; - type Weigher = FixedWeightBounds; + type Weigher = + WeightInfoBounds, Call, MaxInstructions>; type LocationInverter = LocationInverter; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } @@ -325,7 +327,8 @@ impl orml_xtokens::Config for Runtime { // Take note that this pallet does not have the typical configurable WeightInfo. // It uses the Weigher configuration to calculate weights for the user callable extrinsics on this chain, // as well as weights for execution on the destination chain. Both based on the composed xcm messages. - type Weigher = FixedWeightBounds; + type Weigher = + WeightInfoBounds, Call, MaxInstructions>; type BaseXcmWeight = BaseXcmWeight; type LocationInverter = LocationInverter; type MaxAssetsForTransfer = MaxAssetsForTransfer; From 0e9b87914eb793b9ab6a0894f95c39dfb642b1a5 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 12:56:27 +0300 Subject: [PATCH 05/22] Remove new relaychain asset config, tests pass Signed-off-by: Georgi Zlatarev --- pallets/asset-manager/src/lib.rs | 9 +-------- pallets/asset-manager/src/mock.rs | 15 +-------------- pallets/manta-pay/src/mock.rs | 15 +-------------- primitives/manta/src/assets.rs | 4 ---- runtime/calamari/src/assets_config.rs | 18 +----------------- runtime/common/tests/xcm_mock/parachain.rs | 14 -------------- runtime/dolphin/src/assets_config.rs | 18 +----------------- 7 files changed, 5 insertions(+), 88 deletions(-) diff --git a/pallets/asset-manager/src/lib.rs b/pallets/asset-manager/src/lib.rs index 9c8af490b..67eee56a9 100644 --- a/pallets/asset-manager/src/lib.rs +++ b/pallets/asset-manager/src/lib.rs @@ -144,14 +144,7 @@ pub mod pallet { AssetIdLocation::::insert(&asset_id, &location); AssetIdMetadata::::insert(&asset_id, &metadata); LocationAssetId::::insert(&location, &asset_id); - - let asset_id = self.start_id; - let metadata = >::RelayAssetMetadata::get(); - let location = >::RelayAssetLocation::get(); - AssetIdLocation::::insert(&asset_id, &location); - AssetIdMetadata::::insert(&asset_id, &metadata); - LocationAssetId::::insert(&location, &asset_id); - NextAssetId::::set(self.start_id + 1); + NextAssetId::::set(self.start_id); } } diff --git a/pallets/asset-manager/src/mock.rs b/pallets/asset-manager/src/mock.rs index 9f37b07ae..73403f98e 100644 --- a/pallets/asset-manager/src/mock.rs +++ b/pallets/asset-manager/src/mock.rs @@ -41,7 +41,7 @@ use sp_runtime::{ use sp_std::marker::PhantomData; use xcm::{ prelude::{Parachain, X1}, - v1::{Junctions::Here, MultiLocation}, + v1::MultiLocation, VersionedMultiLocation, }; @@ -175,17 +175,6 @@ parameter_types! { is_sufficient: true, }; pub const AssetManagerPalletId: PalletId = ASSET_MANAGER_PALLET_ID; - pub RelayAssetLocation: AssetLocation = AssetLocation( - VersionedMultiLocation::V1(MultiLocation::new(1, Here))); - pub RelayAssetMetadata: AssetRegistrarMetadata = AssetRegistrarMetadata { - name: b"KSM".to_vec(), - symbol: b"Kusama".to_vec(), - decimals: 12, - min_balance: 1, - evm_address: None, - is_frozen: false, - is_sufficient: true, - }; } #[derive(Clone, Eq, PartialEq)] @@ -200,8 +189,6 @@ impl AssetConfig for MantaAssetConfig { type NativeAssetMetadata = NativeAssetMetadata; type StorageMetadata = AssetStorageMetadata; type AssetLocation = AssetLocation; - type RelayAssetLocation = RelayAssetLocation; - type RelayAssetMetadata = RelayAssetMetadata; type AssetRegistrar = MantaAssetRegistrar; type FungibleLedger = ConcreteFungibleLedger; } diff --git a/pallets/manta-pay/src/mock.rs b/pallets/manta-pay/src/mock.rs index c26dee09a..4580d02cf 100644 --- a/pallets/manta-pay/src/mock.rs +++ b/pallets/manta-pay/src/mock.rs @@ -37,7 +37,7 @@ use sp_runtime::{ }; use xcm::{ prelude::{Parachain, X1}, - v1::{Junctions::Here, MultiLocation}, + v1::MultiLocation, VersionedMultiLocation, }; @@ -202,17 +202,6 @@ parameter_types! { is_sufficient: true, }; pub const AssetManagerPalletId: PalletId = ASSET_MANAGER_PALLET_ID; - pub RelayAssetLocation: AssetLocation = AssetLocation( - VersionedMultiLocation::V1(MultiLocation::new(1, Here))); - pub RelayAssetMetadata: AssetRegistrarMetadata = AssetRegistrarMetadata { - name: b"KSM".to_vec(), - symbol: b"Kusama".to_vec(), - decimals: 12, - min_balance: 1, - evm_address: None, - is_frozen: false, - is_sufficient: true, - }; } #[derive(Clone, Eq, PartialEq)] @@ -227,8 +216,6 @@ impl AssetConfig for MantaAssetConfig { type NativeAssetMetadata = NativeAssetMetadata; type StorageMetadata = AssetStorageMetadata; type AssetLocation = AssetLocation; - type RelayAssetLocation = RelayAssetLocation; - type RelayAssetMetadata = RelayAssetMetadata; type AssetRegistrar = MantaAssetRegistrar; type FungibleLedger = ConcreteFungibleLedger; } diff --git a/primitives/manta/src/assets.rs b/primitives/manta/src/assets.rs index 913897657..ae55c6d15 100644 --- a/primitives/manta/src/assets.rs +++ b/primitives/manta/src/assets.rs @@ -94,13 +94,9 @@ where /// Native Asset Location type NativeAssetLocation: Get; - type RelayAssetLocation: Get; - /// Native Asset Metadata type NativeAssetMetadata: Get; - type RelayAssetMetadata: Get; - /// The trait we use to register Assets and mint assets type AssetRegistrar: AssetRegistrar; diff --git a/runtime/calamari/src/assets_config.rs b/runtime/calamari/src/assets_config.rs index feb850af0..602699210 100644 --- a/runtime/calamari/src/assets_config.rs +++ b/runtime/calamari/src/assets_config.rs @@ -32,10 +32,7 @@ use frame_support::{pallet_prelude::DispatchResult, parameter_types, traits::Con use frame_system::EnsureRoot; -use xcm::{ - v1::{Junctions::Here, MultiLocation}, - VersionedMultiLocation, -}; +use xcm::VersionedMultiLocation; parameter_types! { // Does not really matter as this will be only called by root @@ -116,17 +113,6 @@ parameter_types! { is_frozen: false, is_sufficient: true, }; - pub RelayAssetLocation: AssetLocation = AssetLocation( - VersionedMultiLocation::V1(MultiLocation::new(1, Here))); - pub RelayAssetMetadata: AssetRegistrarMetadata = AssetRegistrarMetadata { - name: b"KSM".to_vec(), - symbol: b"Kusama".to_vec(), - decimals: 12, - min_balance: 1, - evm_address: None, - is_frozen: false, - is_sufficient: true, - }; pub const AssetManagerPalletId: PalletId = ASSET_MANAGER_PALLET_ID; } @@ -142,9 +128,7 @@ impl AssetConfig for CalamariAssetConfig { type StartNonNativeAssetId = StartNonNativeAssetId; type AssetRegistrarMetadata = AssetRegistrarMetadata; type NativeAssetLocation = NativeAssetLocation; - type RelayAssetLocation = RelayAssetLocation; type NativeAssetMetadata = NativeAssetMetadata; - type RelayAssetMetadata = RelayAssetMetadata; type StorageMetadata = AssetStorageMetadata; type AssetLocation = AssetLocation; type AssetRegistrar = CalamariAssetRegistrar; diff --git a/runtime/common/tests/xcm_mock/parachain.rs b/runtime/common/tests/xcm_mock/parachain.rs index 3500b83cd..7c484af34 100644 --- a/runtime/common/tests/xcm_mock/parachain.rs +++ b/runtime/common/tests/xcm_mock/parachain.rs @@ -543,18 +543,6 @@ parameter_types! { is_sufficient: true, }; pub const AssetManagerPalletId: PalletId = ASSET_MANAGER_PALLET_ID; - pub RelayAssetLocation: AssetLocation = AssetLocation( - VersionedMultiLocation::V1(MultiLocation::new(1, Here))); - pub RelayAssetMetadata: AssetRegistrarMetadata = AssetRegistrarMetadata { - name: b"KSM".to_vec(), - symbol: b"Kusama".to_vec(), - decimals: 12, - min_balance: 1, - evm_address: None, - is_frozen: false, - is_sufficient: true, - }; - } #[derive(Clone, Eq, PartialEq)] @@ -569,8 +557,6 @@ impl AssetConfig for ParachainAssetConfig { type NativeAssetMetadata = NativeAssetMetadata; type StorageMetadata = AssetStorageMetadata; type AssetLocation = AssetLocation; - type RelayAssetLocation = RelayAssetLocation; - type RelayAssetMetadata = RelayAssetMetadata; type AssetRegistrar = CalamariAssetRegistrar; type FungibleLedger = ConcreteFungibleLedger; } diff --git a/runtime/dolphin/src/assets_config.rs b/runtime/dolphin/src/assets_config.rs index d37b6e239..c81603836 100644 --- a/runtime/dolphin/src/assets_config.rs +++ b/runtime/dolphin/src/assets_config.rs @@ -30,10 +30,7 @@ use manta_primitives::{ use frame_support::{pallet_prelude::DispatchResult, parameter_types, PalletId}; use frame_system::EnsureRoot; -use xcm::{ - v1::{Junctions::Here, MultiLocation}, - VersionedMultiLocation, -}; +use xcm::VersionedMultiLocation; parameter_types! { pub const AssetDeposit: Balance = 0; // Does not really matter as this will be only called by root @@ -126,17 +123,6 @@ parameter_types! { is_frozen: false, is_sufficient: true, }; - pub RelayAssetLocation: AssetLocation = AssetLocation( - VersionedMultiLocation::V1(MultiLocation::new(1, Here))); - pub RelayAssetMetadata: AssetRegistrarMetadata = AssetRegistrarMetadata { - name: b"KSM".to_vec(), - symbol: b"Kusama".to_vec(), - decimals: 12, - min_balance: 1, - evm_address: None, - is_frozen: false, - is_sufficient: true, - }; pub const AssetManagerPalletId: PalletId = ASSET_MANAGER_PALLET_ID; } @@ -153,8 +139,6 @@ impl AssetConfig for DolphinAssetConfig { type AssetRegistrarMetadata = AssetRegistrarMetadata; type NativeAssetLocation = NativeAssetLocation; type NativeAssetMetadata = NativeAssetMetadata; - type RelayAssetLocation = RelayAssetLocation; - type RelayAssetMetadata = RelayAssetMetadata; type StorageMetadata = AssetStorageMetadata; type AssetLocation = AssetLocation; type AssetRegistrar = MantaAssetRegistrar; From fad69ff265b04ed1f390d13dc7cb11d780c104b1 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 13:58:57 +0300 Subject: [PATCH 06/22] Update benchmarking script Signed-off-by: Georgi Zlatarev --- .github/resources/xcm-weight-template.hbs | 17 +++--- .gitignore | 3 +- ....rs => pallet_xcm_benchmarks::fungible.rs} | 39 +++++++------ ...c.rs => pallet_xcm_benchmarks::generic.rs} | 57 +++++++++---------- scripts/benchmarking/run_all_benchmarks.sh | 51 ++++++++++++++--- 5 files changed, 100 insertions(+), 67 deletions(-) rename runtime/calamari/src/weights/xcm/{pallet_xcm_benchmarks_fungible.rs => pallet_xcm_benchmarks::fungible.rs} (86%) rename runtime/calamari/src/weights/xcm/{pallet_xcm_benchmarks_generic.rs => pallet_xcm_benchmarks::generic.rs} (83%) diff --git a/.github/resources/xcm-weight-template.hbs b/.github/resources/xcm-weight-template.hbs index 6cfe4fdf4..5ba58616e 100644 --- a/.github/resources/xcm-weight-template.hbs +++ b/.github/resources/xcm-weight-template.hbs @@ -1,19 +1,18 @@ -// Copyright 2022 Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. - -// Cumulus is distributed in the hope that it will be useful, +// +// Manta 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 . - +// along with Manta. If not, see . //! Autogenerated weights for `{{pallet}}` //! diff --git a/.gitignore b/.gitignore index 62d7814fb..f80b7ceea 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ runtime/**/target /scripts/benchmarking/benchmarking_errors.txt /scripts/benchmarking/machine_benchmark_result.txt /scripts/benchmarking/rocksdb_weights.rs -/scripts/benchmarking/weights-output/ +/scripts/benchmarking/frame-weights-output/ +/scripts/benchmarking/xcm-weights-output/ diff --git a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::fungible.rs similarity index 86% rename from runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs rename to runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::fungible.rs index 9ef6db537..b083af12c 100644 --- a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::fungible.rs @@ -1,41 +1,40 @@ -// Copyright 2022 Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. - -// Cumulus is distributed in the hope that it will be useful, +// +// Manta 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 . - +// along with Manta. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::fungible` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: ``, CPU: `` +//! HOSTNAME: `georgi-desktop`, CPU: `AMD Ryzen 9 5900X 12-Core Processor` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("calamari-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/manta // benchmark // pallet +// --chain=calamari-dev // --steps=50 // --repeat=20 +// --pallet=pallet_xcm_benchmarks::fungible // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --pallet=pallet_xcm_benchmarks::fungible -// --chain=calamari-dev +// --output=./scripts/benchmarking/xcm-weights-output/pallet_xcm_benchmarks::fungible.rs // --template=.github/resources/xcm-weight-template.hbs -// --output=pallet_xcm_benchmarks_fungible.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -51,7 +50,7 @@ impl WeightInfo { // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:1 w:1) pub(crate) fn withdraw_asset() -> Weight { - (36_899_000 as Weight) + (34_745_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -59,7 +58,7 @@ impl WeightInfo { // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:2 w:2) pub(crate) fn transfer_asset() -> Weight { - (55_634_000 as Weight) + (52_369_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -72,18 +71,18 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn transfer_reserve_asset() -> Weight { - (71_444_000 as Weight) + (67_026_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } pub(crate) fn reserve_asset_deposited() -> Weight { - (1_634_000 as Weight) + (1_693_000 as Weight) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:1 w:1) pub(crate) fn deposit_asset() -> Weight { - (38_853_000 as Weight) + (36_729_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -96,7 +95,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn deposit_reserve_asset() -> Weight { - (55_815_000 as Weight) + (54_382_000 as Weight) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -107,7 +106,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn initiate_teleport() -> Weight { - (23_524_000 as Weight) + (23_223_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } diff --git a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::generic.rs similarity index 83% rename from runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs rename to runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::generic.rs index 2fb076e53..ba9d4b94e 100644 --- a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::generic.rs @@ -1,41 +1,40 @@ -// Copyright 2022 Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. - -// Cumulus is distributed in the hope that it will be useful, +// +// Manta 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 . - +// along with Manta. If not, see . //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: ``, CPU: `` +//! HOSTNAME: `georgi-desktop`, CPU: `AMD Ryzen 9 5900X 12-Core Processor` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("calamari-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/manta // benchmark // pallet +// --chain=calamari-dev // --steps=50 // --repeat=20 +// --pallet=pallet_xcm_benchmarks::generic // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --pallet=pallet_xcm_benchmarks::generic -// --chain=calamari-dev +// --output=./scripts/benchmarking/xcm-weights-output/pallet_xcm_benchmarks::generic.rs // --template=.github/resources/xcm-weight-template.hbs -// --output=pallet_xcm_benchmarks_generic.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -54,38 +53,38 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn query_holding() -> Weight { - (638_329_000 as Weight) + (661_042_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } pub(crate) fn buy_execution() -> Weight { - (3_046_000 as Weight) + (3_336_000 as Weight) } // Storage: PolkadotXcm Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (10_800_000 as Weight) + (11_231_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } pub(crate) fn transact() -> Weight { - (11_201_000 as Weight) + (14_858_000 as Weight) } pub(crate) fn refund_surplus() -> Weight { - (3_316_000 as Weight) + (3_226_000 as Weight) } pub(crate) fn set_error_handler() -> Weight { - (671_000 as Weight) + (731_000 as Weight) } pub(crate) fn set_appendix() -> Weight { - (681_000 as Weight) + (742_000 as Weight) } pub(crate) fn clear_error() -> Weight { - (661_000 as Weight) + (712_000 as Weight) } pub(crate) fn descend_origin() -> Weight { - (1_382_000 as Weight) + (1_462_000 as Weight) } pub(crate) fn clear_origin() -> Weight { - (672_000 as Weight) + (721_000 as Weight) } // Storage: PolkadotXcm SupportedVersion (r:1 w:0) // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) @@ -93,18 +92,18 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn report_error() -> Weight { - (12_543_000 as Weight) + (13_465_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: PolkadotXcm AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (5_871_000 as Weight) + (6_322_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 { - (691_000 as Weight) + (711_000 as Weight) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Storage: PolkadotXcm SupportedVersion (r:1 w:0) @@ -113,13 +112,13 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (16_621_000 as Weight) + (17_824_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (2_756_000 as Weight) + (2_875_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -129,7 +128,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (805_984_000 as Weight) + (835_721_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } diff --git a/scripts/benchmarking/run_all_benchmarks.sh b/scripts/benchmarking/run_all_benchmarks.sh index 3b241ba5d..b7a552ab3 100755 --- a/scripts/benchmarking/run_all_benchmarks.sh +++ b/scripts/benchmarking/run_all_benchmarks.sh @@ -79,6 +79,11 @@ MANTA=./target/production/manta EXCLUDED_PALLETS=( ) +XCM_BENCHMARKS=( + "pallet_xcm_benchmarks::fungible" + "pallet_xcm_benchmarks::generic" +) + # Load all pallet names in an array. ALL_PALLETS=($( $MANTA benchmark pallet --list --chain=$chain_spec |\ @@ -98,19 +103,23 @@ ERR_FILE="scripts/benchmarking/benchmarking_errors.txt" # Delete the error file before each run. rm -f $ERR_FILE -WEIGHTS_OUTPUT="scripts/benchmarking/weights-output" +FRAME_WEIGHTS_OUTPUT="scripts/benchmarking/frame-weights-output" # Delete the weights output folders before each run. -rm -R ${WEIGHTS_OUTPUT} +rm -R ${FRAME_WEIGHTS_OUTPUT} # Create the weights output folders. -mkdir ${WEIGHTS_OUTPUT} +mkdir ${FRAME_WEIGHTS_OUTPUT} -STORAGE_OUTPUT="scripts/benchmarking/rocksdb_weights.rs" -rm -f ${STORAGE_OUTPUT} +XCM_WEIGHTS_OUTPUT="scripts/benchmarking/xcm-weights-output" +rm -R ${XCM_WEIGHTS_OUTPUT} +mkdir ${XCM_WEIGHTS_OUTPUT} + +STORAGE_WEIGHTS_OUTPUT="scripts/benchmarking/rocksdb_weights.rs" +rm -f ${STORAGE_WEIGHTS_OUTPUT} MACHINE_OUTPUT="scripts/benchmarking/machine_benchmark_result.txt" rm -f $MACHINE_OUTPUT -# Benchmark each pallet. +# Benchmark each frame pallet. for PALLET in "${PALLETS[@]}"; do # If `-p` is used, skip benchmarks until the start pallet. if [ ! -z "$start_pallet" ] && [ "$start_pallet" != "$PALLET" ] @@ -122,7 +131,7 @@ for PALLET in "${PALLETS[@]}"; do fi FOLDER="$(echo "${PALLET#*_}" | tr '_' '-')"; - WEIGHT_FILE="./${WEIGHTS_OUTPUT}/${PALLET}.rs" + WEIGHT_FILE="./${FRAME_WEIGHTS_OUTPUT}/${PALLET}.rs" echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE"; OUTPUT=$( @@ -144,6 +153,32 @@ for PALLET in "${PALLETS[@]}"; do fi done +# Benchmark xcm. +for PALLET in "${XCM_BENCHMARKS[@]}"; do + + FOLDER="$(echo "${PALLET#*_}" | tr '_' '-')"; + WEIGHT_FILE="./${XCM_WEIGHTS_OUTPUT}/${PALLET}.rs" + echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE"; + + OUTPUT=$( + $MANTA benchmark pallet \ + --chain=$chain_spec \ + --steps=50 \ + --repeat=20 \ + --pallet="$PALLET" \ + --extrinsic="*" \ + --execution=wasm \ + --wasm-execution=compiled \ + --heap-pages=4096 \ + --output="$WEIGHT_FILE" \ + --template=.github/resources/xcm-weight-template.hbs 2>&1 + ) + if [ $? -ne 0 ]; then + echo "$OUTPUT" >> "$ERR_FILE" + echo "[-] Failed to benchmark $PALLET. Error written to $ERR_FILE; continuing..." + fi +done + echo "[+] Benchmarking the machine..." OUTPUT=$( $MANTA benchmark machine --chain=$chain_spec --allow-fail 2>&1 @@ -160,7 +195,7 @@ if [ ! -z "$storage_folder" ]; then --state-version=1 \ --warmups=10 \ --base-path=$storage_folder \ - --weight-path=./$STORAGE_OUTPUT 2>&1 + --weight-path=./$STORAGE_WEIGHTS_OUTPUT 2>&1 ) if [ $? -ne 0 ]; then echo "$OUTPUT" >> "$ERR_FILE" From d6ce433b4b91ec41f73e7820650eb450a64e2f67 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 14:05:03 +0300 Subject: [PATCH 07/22] Clean up Signed-off-by: Georgi Zlatarev --- pallets/asset-manager/src/lib.rs | 1 - runtime/calamari/src/lib.rs | 2 +- runtime/calamari/src/weights/xcm/mod.rs | 16 ++++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pallets/asset-manager/src/lib.rs b/pallets/asset-manager/src/lib.rs index 67eee56a9..74da16e16 100644 --- a/pallets/asset-manager/src/lib.rs +++ b/pallets/asset-manager/src/lib.rs @@ -144,7 +144,6 @@ pub mod pallet { AssetIdLocation::::insert(&asset_id, &location); AssetIdMetadata::::insert(&asset_id, &metadata); LocationAssetId::::insert(&location, &asset_id); - NextAssetId::::set(self.start_id); } } diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index fc647fdfa..2a185877b 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -1108,7 +1108,7 @@ impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), // Treasury Account hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(), - ]; + ]; let mut batches = Vec::::new(); let params = (&config, &whitelist); diff --git a/runtime/calamari/src/weights/xcm/mod.rs b/runtime/calamari/src/weights/xcm/mod.rs index e41f4c4d3..b080c09ee 100644 --- a/runtime/calamari/src/weights/xcm/mod.rs +++ b/runtime/calamari/src/weights/xcm/mod.rs @@ -1,18 +1,18 @@ -// Copyright 2022 Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. - -// Cumulus is distributed in the hope that it will be useful, +// +// Manta 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 . +// along with Manta. If not, see . mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; From cab81989f038d323cbc6fd3c6f3fc8e131af4370 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 14:17:46 +0300 Subject: [PATCH 08/22] Stop integration test jobs with the same condition as with starting them Signed-off-by: Georgi Zlatarev --- .github/workflows/integration_test_calamari.yml | 6 +++--- .github/workflows/integration_test_dolphin.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration_test_calamari.yml b/.github/workflows/integration_test_calamari.yml index cd03b2080..9dd28f340 100644 --- a/.github/workflows/integration_test_calamari.yml +++ b/.github/workflows/integration_test_calamari.yml @@ -431,7 +431,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-node-builder-current: - if: ${{ always() }} + if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') needs: [start-node-builder-current, build-node-current] runs-on: ubuntu-20.04 steps: @@ -468,7 +468,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-calamari-integration-tester: - if: ${{ always() }} + if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') needs: [start-calamari-integration-tester, calamari-integration-test] runs-on: ubuntu-20.04 steps: @@ -505,7 +505,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-docker-image-tester: - if: ${{ always() }} + if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') needs: [start-docker-image-tester, docker-image-test] runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/integration_test_dolphin.yml b/.github/workflows/integration_test_dolphin.yml index ac45a7422..ce19e1a58 100644 --- a/.github/workflows/integration_test_dolphin.yml +++ b/.github/workflows/integration_test_dolphin.yml @@ -394,7 +394,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-node-builder-current: - if: ${{ always() }} + if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') needs: [start-node-builder-current, build-node-current] runs-on: ubuntu-20.04 steps: @@ -431,7 +431,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-dolphin-integration-tester: - if: ${{ always() }} + if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') needs: [start-dolphin-integration-tester, dolphin-integration-test] runs-on: ubuntu-20.04 steps: From 5db22b38170a82a4ce9bf9a5e53d5d9afcb99e1c Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 14:19:25 +0300 Subject: [PATCH 09/22] Fix fmt Signed-off-by: Georgi Zlatarev --- ..._benchmarks::fungible.rs => pallet_xcm_benchmarks_fungible.rs} | 0 ...cm_benchmarks::generic.rs => pallet_xcm_benchmarks_generic.rs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename runtime/calamari/src/weights/xcm/{pallet_xcm_benchmarks::fungible.rs => pallet_xcm_benchmarks_fungible.rs} (100%) rename runtime/calamari/src/weights/xcm/{pallet_xcm_benchmarks::generic.rs => pallet_xcm_benchmarks_generic.rs} (100%) diff --git a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::fungible.rs b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs similarity index 100% rename from runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::fungible.rs rename to runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs diff --git a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::generic.rs b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs similarity index 100% rename from runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks::generic.rs rename to runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs From 078febc46ed0b20f5f0efcbcab3bba6b1271c73f Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 14:31:16 +0300 Subject: [PATCH 10/22] Fix toml lint Signed-off-by: Georgi Zlatarev --- runtime/calamari/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/calamari/Cargo.toml b/runtime/calamari/Cargo.toml index 9eef3581d..273e59f4f 100644 --- a/runtime/calamari/Cargo.toml +++ b/runtime/calamari/Cargo.toml @@ -77,12 +77,12 @@ pallet-author-inherent = { git = "https://github.com/manta-network/nimbus.git", # Polkadot dependencies pallet-xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } +pallet-xcm-benchmarks = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26", optional = true } polkadot-parachain = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } polkadot-primitives = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } xcm-builder = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } xcm-executor = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } -pallet-xcm-benchmarks = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26", optional = true } # Third party (vendored) dependencies orml-traits = { git = 'https://github.com/manta-network/open-runtime-module-library.git', default-features = false, branch = "polkadot-v0.9.26" } From 40b5d7ff9ee8699e5f73214f40d9222ab73b5e93 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 14:57:01 +0300 Subject: [PATCH 11/22] Implement for Dolphin Signed-off-by: Georgi Zlatarev --- Cargo.lock | 1 + runtime/calamari/src/lib.rs | 3 +- runtime/dolphin/Cargo.toml | 2 + runtime/dolphin/src/lib.rs | 93 ++++++++- runtime/dolphin/src/weights/mod.rs | 1 + runtime/dolphin/src/weights/xcm/mod.rs | 179 ++++++++++++++++++ .../xcm/pallet_xcm_benchmarks_fungible.rs | 113 +++++++++++ .../xcm/pallet_xcm_benchmarks_generic.rs | 135 +++++++++++++ runtime/dolphin/src/xcm_config.rs | 16 +- 9 files changed, 533 insertions(+), 10 deletions(-) create mode 100644 runtime/dolphin/src/weights/xcm/mod.rs create mode 100644 runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs create mode 100644 runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_generic.rs diff --git a/Cargo.lock b/Cargo.lock index 9518f23da..51add0c83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2399,6 +2399,7 @@ dependencies = [ "pallet-tx-pause", "pallet-utility", "pallet-xcm", + "pallet-xcm-benchmarks", "parachain-info", "parity-scale-codec", "polkadot-parachain", diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index 2a185877b..cf1bf805c 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -1009,7 +1009,7 @@ impl_runtime_apis! { impl cumulus_pallet_session_benchmarking::Config for Runtime {} use pallet_xcm_benchmarks::asset_instance_from; - use xcm_config::{KsmLocation, LocationToAccountId, XcmExecutorConfig}; + use xcm_config::{LocationToAccountId, XcmExecutorConfig}; parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = None; @@ -1018,6 +1018,7 @@ impl_runtime_apis! { MultiAsset { fun: Fungible(1_000_000_000_000), id: Concrete(KsmLocation::get()) }, )); pub const CheckedAccount: Option = None; + pub const KsmLocation: MultiLocation = MultiLocation::parent(); pub KmaLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(2084))); } diff --git a/runtime/dolphin/Cargo.toml b/runtime/dolphin/Cargo.toml index f5ea7ce91..8006fef98 100644 --- a/runtime/dolphin/Cargo.toml +++ b/runtime/dolphin/Cargo.toml @@ -78,6 +78,7 @@ pallet-author-inherent = { git = "https://github.com/manta-network/nimbus.git", # Polkadot dependencies pallet-xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } +pallet-xcm-benchmarks = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26", optional = true } polkadot-parachain = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } polkadot-primitives = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" } @@ -134,6 +135,7 @@ runtime-benchmarks = [ 'pallet-asset-manager/runtime-benchmarks', 'cumulus-pallet-xcmp-queue/runtime-benchmarks', 'cumulus-pallet-parachain-system/runtime-benchmarks', + 'pallet-xcm-benchmarks', ] try-runtime = [ 'frame-executive/try-runtime', diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index 80305564b..c47920680 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -816,6 +816,8 @@ mod benches { [pallet_assets, Assets] // XCM [cumulus_pallet_xcmp_queue, XcmpQueue] + [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::] + [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::] // Manta pallets [pallet_tx_pause, TransactionPause] [manta_collator_selection, CollatorSelection] @@ -995,7 +997,7 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError}; use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} @@ -1003,6 +1005,94 @@ impl_runtime_apis! { use cumulus_pallet_session_benchmarking::Pallet as SessionBench; impl cumulus_pallet_session_benchmarking::Config for Runtime {} + use pallet_xcm_benchmarks::asset_instance_from; + use xcm_config::{LocationToAccountId, XcmExecutorConfig}; + + parameter_types! { + pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = None; + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( + RocLocation::get(), + MultiAsset { fun: Fungible(1_000_000_000_000_000_000), id: Concrete(RocLocation::get()) }, + )); + pub const CheckedAccount: Option = None; + pub const RocLocation: MultiLocation = MultiLocation::parent(); + pub DolLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(2084))); + } + + impl pallet_xcm_benchmarks::Config for Runtime { + type XcmConfig = XcmExecutorConfig; + type AccountIdConverter = LocationToAccountId; + + fn valid_destination() -> Result { + Ok(RocLocation::get()) + } + + fn worst_case_holding() -> MultiAssets { + // A mix of fungible, non-fungible, and concrete assets. + const HOLDING_FUNGIBLES: u32 = 100; + const HOLDING_NON_FUNGIBLES: u32 = 100; + let fungibles_amount: u128 = 100; + let mut assets = (0..HOLDING_FUNGIBLES) + .map(|i| { + MultiAsset { + id: Concrete(GeneralIndex(i as u128).into()), + fun: Fungible(fungibles_amount * i as u128), + } + .into() + }) + .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) + .chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset { + id: Concrete(GeneralIndex(i as u128).into()), + fun: NonFungible(asset_instance_from(i)), + })) + .collect::>(); + + assets.push(MultiAsset{ + id: Concrete(DolLocation::get()), + fun: Fungible(1_000_000 * DOL), + }); + assets.into() + } + } + + impl pallet_xcm_benchmarks::fungible::Config for Runtime { + type TransactAsset = Balances; + + type CheckedAccount = CheckedAccount; + type TrustedTeleporter = TrustedTeleporter; + type TrustedReserve = TrustedReserve; + + fn get_multi_asset() -> MultiAsset { + MultiAsset { + id: Concrete(DolLocation::get()), + fun: Fungible(1 * DOL), + } + } + } + + impl pallet_xcm_benchmarks::generic::Config for Runtime { + type Call = Call; + + fn worst_case_response() -> (u64, Response) { + (0u64, Response::Version(Default::default())) + } + + fn transact_origin() -> Result { + Ok(RocLocation::get()) + } + + fn subscribe_origin() -> Result { + Ok(RocLocation::get()) + } + + fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { + let origin = DolLocation::get(); + let assets: MultiAssets = (Concrete(DolLocation::get()), 1_000 * DOL).into(); + let ticket = MultiLocation { parents: 0, interior: Here }; + Ok((origin, ticket, assets)) + } + } + let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), @@ -1022,7 +1112,6 @@ impl_runtime_apis! { let params = (&config, &whitelist); add_benchmarks!(params, batches); - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } } diff --git a/runtime/dolphin/src/weights/mod.rs b/runtime/dolphin/src/weights/mod.rs index 7d587c666..28d13b477 100644 --- a/runtime/dolphin/src/weights/mod.rs +++ b/runtime/dolphin/src/weights/mod.rs @@ -35,3 +35,4 @@ pub mod pallet_timestamp; pub mod pallet_treasury; pub mod pallet_tx_pause; pub mod pallet_utility; +pub mod xcm; diff --git a/runtime/dolphin/src/weights/xcm/mod.rs b/runtime/dolphin/src/weights/xcm/mod.rs new file mode 100644 index 000000000..d6288345c --- /dev/null +++ b/runtime/dolphin/src/weights/xcm/mod.rs @@ -0,0 +1,179 @@ +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. +// +// Manta 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 Manta. If not, see . + +mod pallet_xcm_benchmarks_fungible; +mod pallet_xcm_benchmarks_generic; + +use crate::Runtime; +use frame_support::weights::Weight; +use sp_std::prelude::*; +use xcm::{latest::prelude::*, DoubleEncoded}; + +use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; +use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; + +trait WeighMultiAssets { + fn weigh_multi_assets(&self, weight: Weight) -> Weight; +} + +const MAX_ASSETS: u32 = 100; + +impl WeighMultiAssets for MultiAssetFilter { + fn weigh_multi_assets(&self, weight: Weight) -> Weight { + match self { + Self::Definite(assets) => { + (assets.inner().into_iter().count() as Weight).saturating_mul(weight) + } + Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(weight), + } + } +} + +impl WeighMultiAssets for MultiAssets { + fn weigh_multi_assets(&self, weight: Weight) -> Weight { + (self.inner().into_iter().count() as Weight).saturating_mul(weight) + } +} + +pub struct DolphinXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for DolphinXcmWeight { + fn withdraw_asset(assets: &MultiAssets) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) + } + fn reserve_asset_deposited(assets: &MultiAssets) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited()) + } + fn receive_teleported_asset(_assets: &MultiAssets) -> Weight { + unimplemented!() + } + fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> Weight { + XcmGeneric::::query_response() + } + fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::transfer_asset()) + } + fn transfer_reserve_asset( + assets: &MultiAssets, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::transfer_reserve_asset()) + } + fn transact( + _origin_type: &OriginKind, + _require_weight_at_most: &u64, + _call: &DoubleEncoded, + ) -> Weight { + XcmGeneric::::transact() + } + fn hrmp_new_channel_open_request( + _sender: &u32, + _max_message_size: &u32, + _max_capacity: &u32, + ) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn hrmp_channel_accepted(_recipient: &u32) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn clear_origin() -> Weight { + XcmGeneric::::clear_origin() + } + fn descend_origin(_who: &InteriorMultiLocation) -> Weight { + XcmGeneric::::descend_origin() + } + fn report_error( + _query_id: &QueryId, + _dest: &MultiLocation, + _max_response_weight: &u64, + ) -> Weight { + XcmGeneric::::report_error() + } + + fn deposit_asset( + assets: &MultiAssetFilter, + _max_assets: &u32, + _dest: &MultiLocation, + ) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()) + } + fn deposit_reserve_asset( + assets: &MultiAssetFilter, + _max_assets: &u32, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::deposit_reserve_asset()) + } + fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> Weight { + Weight::MAX + } + fn initiate_reserve_withdraw( + assets: &MultiAssetFilter, + _reserve: &MultiLocation, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_multi_assets(XcmGeneric::::initiate_reserve_withdraw()) + } + fn initiate_teleport( + assets: &MultiAssetFilter, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()) + } + fn query_holding( + _query_id: &u64, + _dest: &MultiLocation, + _assets: &MultiAssetFilter, + _max_response_weight: &u64, + ) -> Weight { + XcmGeneric::::query_holding() + } + fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { + XcmGeneric::::buy_execution() + } + fn refund_surplus() -> Weight { + XcmGeneric::::refund_surplus() + } + fn set_error_handler(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_error_handler() + } + fn set_appendix(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_appendix() + } + fn clear_error() -> Weight { + XcmGeneric::::clear_error() + } + fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight { + XcmGeneric::::claim_asset() + } + fn trap(_code: &u64) -> Weight { + XcmGeneric::::trap() + } + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> Weight { + XcmGeneric::::subscribe_version() + } + fn unsubscribe_version() -> Weight { + XcmGeneric::::unsubscribe_version() + } +} diff --git a/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs new file mode 100644 index 000000000..650deddb2 --- /dev/null +++ b/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -0,0 +1,113 @@ +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. +// +// Manta 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 Manta. If not, see . + +//! Autogenerated weights for `pallet_xcm_benchmarks::fungible` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `georgi-desktop`, CPU: `AMD Ryzen 9 5900X 12-Core Processor` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dolphin-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/manta +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --pallet=pallet_xcm_benchmarks::fungible +// --chain=dolphin-dev +// --template=.github/resources/xcm-weight-template.hbs +// --output=pallet_xcm_benchmarks_fungible.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weights for `pallet_xcm_benchmarks::fungible`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:1 w:1) + pub(crate) fn withdraw_asset() -> Weight { + (35_256_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:2 w:2) + pub(crate) fn transfer_asset() -> Weight { + (54_002_000 as Weight) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn transfer_reserve_asset() -> Weight { + (68_439_000 as Weight) + .saturating_add(T::DbWeight::get().reads(9 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + pub(crate) fn reserve_asset_deposited() -> Weight { + (1_733_000 as Weight) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:1 w:1) + pub(crate) fn deposit_asset() -> Weight { + (38_241_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: AssetManager LocationAssetId (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn deposit_reserve_asset() -> Weight { + (57_307_000 as Weight) + .saturating_add(T::DbWeight::get().reads(8 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn initiate_teleport() -> Weight { + (23_594_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} \ No newline at end of file diff --git a/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_generic.rs new file mode 100644 index 000000000..e76c612b3 --- /dev/null +++ b/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -0,0 +1,135 @@ +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. +// +// Manta 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 Manta. If not, see . + +//! Autogenerated weights for `pallet_xcm_benchmarks::generic` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `georgi-desktop`, CPU: `AMD Ryzen 9 5900X 12-Core Processor` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dolphin-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/manta +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --pallet=pallet_xcm_benchmarks::generic +// --chain=dolphin-dev +// --template=.github/resources/xcm-weight-template.hbs +// --output=pallet_xcm_benchmarks_generic.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weights for `pallet_xcm_benchmarks::generic`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn query_holding() -> Weight { + (661_704_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + pub(crate) fn buy_execution() -> Weight { + (3_316_000 as Weight) + } + // Storage: PolkadotXcm Queries (r:1 w:0) + pub(crate) fn query_response() -> Weight { + (23_294_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } + pub(crate) fn transact() -> Weight { + (30_467_000 as Weight) + } + pub(crate) fn refund_surplus() -> Weight { + (5_671_000 as Weight) + } + pub(crate) fn set_error_handler() -> Weight { + (702_000 as Weight) + } + pub(crate) fn set_appendix() -> Weight { + (711_000 as Weight) + } + pub(crate) fn clear_error() -> Weight { + (692_000 as Weight) + } + pub(crate) fn descend_origin() -> Weight { + (1_413_000 as Weight) + } + pub(crate) fn clear_origin() -> Weight { + (681_000 as Weight) + } + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn report_error() -> Weight { + (13_305_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: PolkadotXcm AssetTraps (r:1 w:1) + pub(crate) fn claim_asset() -> Weight { + (6_492_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 { + (691_000 as Weight) + } + // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn subscribe_version() -> Weight { + (17_373_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1) + pub(crate) fn unsubscribe_version() -> Weight { + (2_916_000 as Weight) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Storage: PolkadotXcm SupportedVersion (r:1 w:0) + // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + // Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + // Storage: ParachainSystem HostConfiguration (r:1 w:0) + // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) + pub(crate) fn initiate_reserve_withdraw() -> Weight { + (836_421_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} \ No newline at end of file diff --git a/runtime/dolphin/src/xcm_config.rs b/runtime/dolphin/src/xcm_config.rs index 2280cac87..1dc8b7895 100644 --- a/runtime/dolphin/src/xcm_config.rs +++ b/runtime/dolphin/src/xcm_config.rs @@ -53,9 +53,9 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ConvertedConcreteAssetId, - EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, LocationInverter, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, + EnsureXcmOrigin, FixedRateOfFungible, LocationInverter, ParentAsSuperuser, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, WeightInfoBounds, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -79,7 +79,6 @@ impl cumulus_pallet_parachain_system::Config for Runtime { impl parachain_info::Config for Runtime {} parameter_types! { - pub const KsmLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); @@ -212,7 +211,8 @@ impl Config for XcmExecutorConfig { type IsTeleporter = (); type LocationInverter = LocationInverter; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = + WeightInfoBounds, Call, MaxInstructions>; // Trader is the means to purchasing weight credit for XCM execution. // We define two traders: // The first one will charge parachain's native currency, who's `MultiLocation` @@ -257,7 +257,8 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; - type Weigher = FixedWeightBounds; + type Weigher = + WeightInfoBounds, Call, MaxInstructions>; type LocationInverter = LocationInverter; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } @@ -324,7 +325,8 @@ impl orml_xtokens::Config for Runtime { // Take note that this pallet does not have the typical configurable WeightInfo. // It uses the Weigher configuration to calculate weights for the user callable extrinsics on this chain, // as well as weights for execution on the destination chain. Both based on the composed xcm messages. - type Weigher = FixedWeightBounds; + type Weigher = + WeightInfoBounds, Call, MaxInstructions>; type BaseXcmWeight = BaseXcmWeight; type LocationInverter = LocationInverter; type MaxAssetsForTransfer = MaxAssetsForTransfer; From dc50af26b4a934bdb5471d3a95fac292483216a0 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 15:20:41 +0300 Subject: [PATCH 12/22] Update header and reference-machine link in all-benchmarks script Signed-off-by: Georgi Zlatarev --- runtime/calamari/src/xcm_config.rs | 1 - scripts/benchmarking/run_all_benchmarks.sh | 30 +++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/runtime/calamari/src/xcm_config.rs b/runtime/calamari/src/xcm_config.rs index 29935d7dc..e7419167c 100644 --- a/runtime/calamari/src/xcm_config.rs +++ b/runtime/calamari/src/xcm_config.rs @@ -80,7 +80,6 @@ impl cumulus_pallet_parachain_system::Config for Runtime { impl parachain_info::Config for Runtime {} parameter_types! { - pub const KsmLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); diff --git a/scripts/benchmarking/run_all_benchmarks.sh b/scripts/benchmarking/run_all_benchmarks.sh index b7a552ab3..4ae334367 100755 --- a/scripts/benchmarking/run_all_benchmarks.sh +++ b/scripts/benchmarking/run_all_benchmarks.sh @@ -1,19 +1,18 @@ -#!/usr/bin/env bash - -# This file is part of Substrate. -# Copyright (C) 2022 Parity Technologies (UK) Ltd. -# SPDX-License-Identifier: Apache-2.0 -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2020-2022 Manta Network. +# This file is part of Manta. # -# http://www.apache.org/licenses/LICENSE-2.0 +# Manta 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. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Manta 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 Manta. If not, see . # This script has three parts which all use the Substrate runtime: # - Pallet benchmarking to update the pallet weights @@ -21,7 +20,8 @@ # - Machine benchmarking # # Should be run on a reference machine to gain accurate benchmarks -# current reference machine: https://github.com/paritytech/substrate/pull/5848 +# current reference machine: +# https://github.com/Manta-Network/Manta/blob/manta/.github/workflows/run_all_benchmarks.yml#L15 # # Should be run from the root of the repo. From 8cb7271dbc40b441e2ab1fe0702f092571d62e83 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 15:40:18 +0300 Subject: [PATCH 13/22] Fix clippy Signed-off-by: Georgi Zlatarev --- runtime/calamari/src/lib.rs | 1 - runtime/calamari/src/weights/xcm/mod.rs | 5 ++--- runtime/dolphin/src/lib.rs | 1 - runtime/dolphin/src/weights/xcm/mod.rs | 5 ++--- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index cf1bf805c..1f2cdb06f 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -1041,7 +1041,6 @@ impl_runtime_apis! { id: Concrete(GeneralIndex(i as u128).into()), fun: Fungible(fungibles_amount * i as u128), } - .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) .chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset { diff --git a/runtime/calamari/src/weights/xcm/mod.rs b/runtime/calamari/src/weights/xcm/mod.rs index b080c09ee..40c5923a3 100644 --- a/runtime/calamari/src/weights/xcm/mod.rs +++ b/runtime/calamari/src/weights/xcm/mod.rs @@ -19,7 +19,6 @@ mod pallet_xcm_benchmarks_generic; use crate::Runtime; use frame_support::weights::Weight; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; @@ -35,7 +34,7 @@ impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => { - (assets.inner().into_iter().count() as Weight).saturating_mul(weight) + (assets.inner().iter().count() as Weight).saturating_mul(weight) } Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(weight), } @@ -44,7 +43,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - (self.inner().into_iter().count() as Weight).saturating_mul(weight) + (self.inner().iter().count() as Weight).saturating_mul(weight) } } diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index c47920680..cb2b4ac1f 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -1038,7 +1038,6 @@ impl_runtime_apis! { id: Concrete(GeneralIndex(i as u128).into()), fun: Fungible(fungibles_amount * i as u128), } - .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) .chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset { diff --git a/runtime/dolphin/src/weights/xcm/mod.rs b/runtime/dolphin/src/weights/xcm/mod.rs index d6288345c..deffdd03d 100644 --- a/runtime/dolphin/src/weights/xcm/mod.rs +++ b/runtime/dolphin/src/weights/xcm/mod.rs @@ -19,7 +19,6 @@ mod pallet_xcm_benchmarks_generic; use crate::Runtime; use frame_support::weights::Weight; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; @@ -35,7 +34,7 @@ impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => { - (assets.inner().into_iter().count() as Weight).saturating_mul(weight) + (assets.inner().iter().count() as Weight).saturating_mul(weight) } Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(weight), } @@ -44,7 +43,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - (self.inner().into_iter().count() as Weight).saturating_mul(weight) + (self.inner().iter().count() as Weight).saturating_mul(weight) } } From 253f989379339b34dca80e2fd5b833ceb8b26d61 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 16:36:58 +0300 Subject: [PATCH 14/22] Upload correct benchmarking output folders Signed-off-by: Georgi Zlatarev --- .github/workflows/run_all_benchmarks.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_all_benchmarks.yml b/.github/workflows/run_all_benchmarks.yml index 5c3be5976..2687e81cf 100644 --- a/.github/workflows/run_all_benchmarks.yml +++ b/.github/workflows/run_all_benchmarks.yml @@ -94,11 +94,17 @@ jobs: name: manta path: ./target/production/manta - if: always() - name: upload pallets' weights + name: upload frame weights uses: actions/upload-artifact@v3 with: name: weights-output - path: ./scripts/benchmarking/weights-output/ + path: ./scripts/benchmarking/frame-weights-output/ + - if: always() + name: upload xcm weights + uses: actions/upload-artifact@v3 + with: + name: weights-output + path: ./scripts/benchmarking/xcm-weights-output/ - if: always() name: upload benchmarking errors uses: actions/upload-artifact@v3 From 6cde174be5f20b6a9ebb70d85d27d276293a7055 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 16:48:55 +0300 Subject: [PATCH 15/22] Dedupe artifacts names Signed-off-by: Georgi Zlatarev --- .github/workflows/run_all_benchmarks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_all_benchmarks.yml b/.github/workflows/run_all_benchmarks.yml index 2687e81cf..527483712 100644 --- a/.github/workflows/run_all_benchmarks.yml +++ b/.github/workflows/run_all_benchmarks.yml @@ -97,13 +97,13 @@ jobs: name: upload frame weights uses: actions/upload-artifact@v3 with: - name: weights-output + name: frame-weights-output path: ./scripts/benchmarking/frame-weights-output/ - if: always() name: upload xcm weights uses: actions/upload-artifact@v3 with: - name: weights-output + name: xcm-weights-output path: ./scripts/benchmarking/xcm-weights-output/ - if: always() name: upload benchmarking errors From 1ced65a790b91468d674e63cab1629aab3622f91 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 18:50:22 +0300 Subject: [PATCH 16/22] Fix xcm benchmark output files name Signed-off-by: Georgi Zlatarev --- scripts/benchmarking/run_all_benchmarks.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/benchmarking/run_all_benchmarks.sh b/scripts/benchmarking/run_all_benchmarks.sh index 4ae334367..d62390e25 100755 --- a/scripts/benchmarking/run_all_benchmarks.sh +++ b/scripts/benchmarking/run_all_benchmarks.sh @@ -80,8 +80,8 @@ EXCLUDED_PALLETS=( ) XCM_BENCHMARKS=( - "pallet_xcm_benchmarks::fungible" - "pallet_xcm_benchmarks::generic" + "pallet_xcm_benchmarks_fungible" + "pallet_xcm_benchmarks_generic" ) # Load all pallet names in an array. From 2fdf3b5bb032651b82709d0fc92a3d79570035d5 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Wed, 31 Aug 2022 23:31:46 +0300 Subject: [PATCH 17/22] Update all-benchmarks script to replace :: with _ in pallet names Signed-off-by: Georgi Zlatarev --- scripts/benchmarking/run_all_benchmarks.sh | 37 ++++------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/scripts/benchmarking/run_all_benchmarks.sh b/scripts/benchmarking/run_all_benchmarks.sh index d62390e25..6c6384e04 100755 --- a/scripts/benchmarking/run_all_benchmarks.sh +++ b/scripts/benchmarking/run_all_benchmarks.sh @@ -79,11 +79,6 @@ MANTA=./target/production/manta EXCLUDED_PALLETS=( ) -XCM_BENCHMARKS=( - "pallet_xcm_benchmarks_fungible" - "pallet_xcm_benchmarks_generic" -) - # Load all pallet names in an array. ALL_PALLETS=($( $MANTA benchmark pallet --list --chain=$chain_spec |\ @@ -132,33 +127,15 @@ for PALLET in "${PALLETS[@]}"; do FOLDER="$(echo "${PALLET#*_}" | tr '_' '-')"; WEIGHT_FILE="./${FRAME_WEIGHTS_OUTPUT}/${PALLET}.rs" + TEMPLATE_FILE=".github/resources/frame-weight-template.hbs" echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE"; - OUTPUT=$( - $MANTA benchmark pallet \ - --chain=$chain_spec \ - --steps=50 \ - --repeat=20 \ - --pallet="$PALLET" \ - --extrinsic="*" \ - --execution=wasm \ - --wasm-execution=compiled \ - --heap-pages=4096 \ - --output="$WEIGHT_FILE" \ - --template=.github/resources/frame-weight-template.hbs 2>&1 - ) - if [ $? -ne 0 ]; then - echo "$OUTPUT" >> "$ERR_FILE" - echo "[-] Failed to benchmark $PALLET. Error written to $ERR_FILE; continuing..." + if [ "$PALLET" == "pallet_xcm_benchmarks::fungible" ] || [ "$PALLET" == "pallet_xcm_benchmarks::generic" ] + then + OUTPUT_NAME=$(echo $PALLET | sed -r 's/[:]+/_/g') + WEIGHT_FILE="./${XCM_WEIGHTS_OUTPUT}/$OUTPUT_NAME" + TEMPLATE_FILE=".github/resources/xcm-weight-template.hbs" fi -done - -# Benchmark xcm. -for PALLET in "${XCM_BENCHMARKS[@]}"; do - - FOLDER="$(echo "${PALLET#*_}" | tr '_' '-')"; - WEIGHT_FILE="./${XCM_WEIGHTS_OUTPUT}/${PALLET}.rs" - echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE"; OUTPUT=$( $MANTA benchmark pallet \ @@ -171,7 +148,7 @@ for PALLET in "${XCM_BENCHMARKS[@]}"; do --wasm-execution=compiled \ --heap-pages=4096 \ --output="$WEIGHT_FILE" \ - --template=.github/resources/xcm-weight-template.hbs 2>&1 + --template="$TEMPLATE_FILE" 2>&1 ) if [ $? -ne 0 ]; then echo "$OUTPUT" >> "$ERR_FILE" From f42bc289413736a60f88b75c27e9a065709bb6d3 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Thu, 1 Sep 2022 08:29:44 +0300 Subject: [PATCH 18/22] Add real weights benchmarked by the benchmarking machine Signed-off-by: Georgi Zlatarev --- .../xcm/pallet_xcm_benchmarks_fungible.rs | 20 ++++----- .../xcm/pallet_xcm_benchmarks_generic.rs | 38 ++++++++--------- .../xcm/pallet_xcm_benchmarks_fungible.rs | 24 +++++------ .../xcm/pallet_xcm_benchmarks_generic.rs | 42 +++++++++---------- 4 files changed, 62 insertions(+), 62 deletions(-) diff --git a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index b083af12c..05d4cfa52 100644 --- a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -18,11 +18,11 @@ //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `georgi-desktop`, CPU: `AMD Ryzen 9 5900X 12-Core Processor` +//! HOSTNAME: `ip-172-31-13-155`, CPU: `Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("calamari-dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/manta +// ./target/production/manta // benchmark // pallet // --chain=calamari-dev @@ -33,7 +33,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./scripts/benchmarking/xcm-weights-output/pallet_xcm_benchmarks::fungible.rs +// --output=./scripts/benchmarking/xcm-weights-output/pallet_xcm_benchmarks_fungible // --template=.github/resources/xcm-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -50,7 +50,7 @@ impl WeightInfo { // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:1 w:1) pub(crate) fn withdraw_asset() -> Weight { - (34_745_000 as Weight) + (37_177_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -58,7 +58,7 @@ impl WeightInfo { // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:2 w:2) pub(crate) fn transfer_asset() -> Weight { - (52_369_000 as Weight) + (54_187_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -71,18 +71,18 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn transfer_reserve_asset() -> Weight { - (67_026_000 as Weight) + (70_475_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } pub(crate) fn reserve_asset_deposited() -> Weight { - (1_693_000 as Weight) + (1_831_000 as Weight) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:1 w:1) pub(crate) fn deposit_asset() -> Weight { - (36_729_000 as Weight) + (38_096_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -95,7 +95,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn deposit_reserve_asset() -> Weight { - (54_382_000 as Weight) + (56_044_000 as Weight) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -106,7 +106,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn initiate_teleport() -> Weight { - (23_223_000 as Weight) + (24_460_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } diff --git a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index ba9d4b94e..b735eaf62 100644 --- a/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/calamari/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -18,11 +18,11 @@ //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `georgi-desktop`, CPU: `AMD Ryzen 9 5900X 12-Core Processor` +//! HOSTNAME: `ip-172-31-13-155`, CPU: `Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("calamari-dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/manta +// ./target/production/manta // benchmark // pallet // --chain=calamari-dev @@ -33,7 +33,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./scripts/benchmarking/xcm-weights-output/pallet_xcm_benchmarks::generic.rs +// --output=./scripts/benchmarking/xcm-weights-output/pallet_xcm_benchmarks_generic // --template=.github/resources/xcm-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -53,38 +53,38 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn query_holding() -> Weight { - (661_042_000 as Weight) + (819_954_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } pub(crate) fn buy_execution() -> Weight { - (3_336_000 as Weight) + (4_520_000 as Weight) } // Storage: PolkadotXcm Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (11_231_000 as Weight) + (11_807_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } pub(crate) fn transact() -> Weight { - (14_858_000 as Weight) + (15_624_000 as Weight) } pub(crate) fn refund_surplus() -> Weight { - (3_226_000 as Weight) + (4_373_000 as Weight) } pub(crate) fn set_error_handler() -> Weight { - (731_000 as Weight) + (788_000 as Weight) } pub(crate) fn set_appendix() -> Weight { - (742_000 as Weight) + (799_000 as Weight) } pub(crate) fn clear_error() -> Weight { - (712_000 as Weight) + (818_000 as Weight) } pub(crate) fn descend_origin() -> Weight { - (1_462_000 as Weight) + (1_564_000 as Weight) } pub(crate) fn clear_origin() -> Weight { - (721_000 as Weight) + (796_000 as Weight) } // Storage: PolkadotXcm SupportedVersion (r:1 w:0) // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) @@ -92,18 +92,18 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn report_error() -> Weight { - (13_465_000 as Weight) + (13_437_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: PolkadotXcm AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (6_322_000 as Weight) + (6_558_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 { - (711_000 as Weight) + (798_000 as Weight) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Storage: PolkadotXcm SupportedVersion (r:1 w:0) @@ -112,13 +112,13 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (17_824_000 as Weight) + (17_478_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (2_875_000 as Weight) + (3_059_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -128,7 +128,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (835_721_000 as Weight) + (1_059_801_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } diff --git a/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 650deddb2..63eaad44f 100644 --- a/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -18,23 +18,23 @@ //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `georgi-desktop`, CPU: `AMD Ryzen 9 5900X 12-Core Processor` +//! HOSTNAME: `ip-172-31-0-42`, CPU: `Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dolphin-dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/manta +// ./target/production/manta // benchmark // pallet +// --chain=dolphin-dev // --steps=50 // --repeat=20 +// --pallet=pallet_xcm_benchmarks::fungible // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --pallet=pallet_xcm_benchmarks::fungible -// --chain=dolphin-dev +// --output=./scripts/benchmarking/xcm-weights-output/pallet_xcm_benchmarks_fungible // --template=.github/resources/xcm-weight-template.hbs -// --output=pallet_xcm_benchmarks_fungible.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,7 +50,7 @@ impl WeightInfo { // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:1 w:1) pub(crate) fn withdraw_asset() -> Weight { - (35_256_000 as Weight) + (38_493_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -58,7 +58,7 @@ impl WeightInfo { // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:2 w:2) pub(crate) fn transfer_asset() -> Weight { - (54_002_000 as Weight) + (55_134_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -71,18 +71,18 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn transfer_reserve_asset() -> Weight { - (68_439_000 as Weight) + (68_586_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } pub(crate) fn reserve_asset_deposited() -> Weight { - (1_733_000 as Weight) + (2_284_000 as Weight) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Storage: AssetManager LocationAssetId (r:1 w:0) // Storage: System Account (r:1 w:1) pub(crate) fn deposit_asset() -> Weight { - (38_241_000 as Weight) + (39_039_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -95,7 +95,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn deposit_reserve_asset() -> Weight { - (57_307_000 as Weight) + (60_373_000 as Weight) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -106,7 +106,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn initiate_teleport() -> Weight { - (23_594_000 as Weight) + (25_805_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } diff --git a/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index e76c612b3..ac8bc066b 100644 --- a/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/dolphin/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -18,23 +18,23 @@ //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `georgi-desktop`, CPU: `AMD Ryzen 9 5900X 12-Core Processor` +//! HOSTNAME: `ip-172-31-0-42`, CPU: `Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dolphin-dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/manta +// ./target/production/manta // benchmark // pallet +// --chain=dolphin-dev // --steps=50 // --repeat=20 +// --pallet=pallet_xcm_benchmarks::generic // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --pallet=pallet_xcm_benchmarks::generic -// --chain=dolphin-dev +// --output=./scripts/benchmarking/xcm-weights-output/pallet_xcm_benchmarks_generic // --template=.github/resources/xcm-weight-template.hbs -// --output=pallet_xcm_benchmarks_generic.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -53,38 +53,38 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn query_holding() -> Weight { - (661_704_000 as Weight) + (1_032_874_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } pub(crate) fn buy_execution() -> Weight { - (3_316_000 as Weight) + (4_490_000 as Weight) } // Storage: PolkadotXcm Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (23_294_000 as Weight) + (12_237_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } pub(crate) fn transact() -> Weight { - (30_467_000 as Weight) + (16_340_000 as Weight) } pub(crate) fn refund_surplus() -> Weight { - (5_671_000 as Weight) + (4_401_000 as Weight) } pub(crate) fn set_error_handler() -> Weight { - (702_000 as Weight) + (1_043_000 as Weight) } pub(crate) fn set_appendix() -> Weight { - (711_000 as Weight) + (1_042_000 as Weight) } pub(crate) fn clear_error() -> Weight { - (692_000 as Weight) + (1_015_000 as Weight) } pub(crate) fn descend_origin() -> Weight { - (1_413_000 as Weight) + (1_889_000 as Weight) } pub(crate) fn clear_origin() -> Weight { - (681_000 as Weight) + (1_018_000 as Weight) } // Storage: PolkadotXcm SupportedVersion (r:1 w:0) // Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) @@ -92,18 +92,18 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn report_error() -> Weight { - (13_305_000 as Weight) + (14_116_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: PolkadotXcm AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (6_492_000 as Weight) + (7_014_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 { - (691_000 as Weight) + (1_018_000 as Weight) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Storage: PolkadotXcm SupportedVersion (r:1 w:0) @@ -112,13 +112,13 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (17_373_000 as Weight) + (18_055_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (2_916_000 as Weight) + (3_253_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -128,7 +128,7 @@ impl WeightInfo { // Storage: ParachainSystem HostConfiguration (r:1 w:0) // Storage: ParachainSystem PendingUpwardMessages (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (836_421_000 as Weight) + (1_334_027_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } From e823afc8deb97cf1c58cfeb8e1cd7ef918de55e4 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Thu, 1 Sep 2022 09:33:53 +0300 Subject: [PATCH 19/22] Add real weights benchmarked by the benchmarking machine Signed-off-by: Georgi Zlatarev --- scripts/benchmarking/run_all_benchmarks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/benchmarking/run_all_benchmarks.sh b/scripts/benchmarking/run_all_benchmarks.sh index 6c6384e04..db5aabe84 100755 --- a/scripts/benchmarking/run_all_benchmarks.sh +++ b/scripts/benchmarking/run_all_benchmarks.sh @@ -133,7 +133,7 @@ for PALLET in "${PALLETS[@]}"; do if [ "$PALLET" == "pallet_xcm_benchmarks::fungible" ] || [ "$PALLET" == "pallet_xcm_benchmarks::generic" ] then OUTPUT_NAME=$(echo $PALLET | sed -r 's/[:]+/_/g') - WEIGHT_FILE="./${XCM_WEIGHTS_OUTPUT}/$OUTPUT_NAME" + WEIGHT_FILE="./${XCM_WEIGHTS_OUTPUT}/${OUTPUT_NAME}.rs" TEMPLATE_FILE=".github/resources/xcm-weight-template.hbs" fi From fbdf1201f695afce002f87d828a3cacf28857253 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Fri, 2 Sep 2022 11:25:42 +0300 Subject: [PATCH 20/22] Revert stopper job code change Signed-off-by: Georgi Zlatarev --- .github/workflows/integration_test_calamari.yml | 6 +++--- .github/workflows/integration_test_dolphin.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration_test_calamari.yml b/.github/workflows/integration_test_calamari.yml index 9dd28f340..cd03b2080 100644 --- a/.github/workflows/integration_test_calamari.yml +++ b/.github/workflows/integration_test_calamari.yml @@ -431,7 +431,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-node-builder-current: - if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') + if: ${{ always() }} needs: [start-node-builder-current, build-node-current] runs-on: ubuntu-20.04 steps: @@ -468,7 +468,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-calamari-integration-tester: - if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') + if: ${{ always() }} needs: [start-calamari-integration-tester, calamari-integration-test] runs-on: ubuntu-20.04 steps: @@ -505,7 +505,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-docker-image-tester: - if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') + if: ${{ always() }} needs: [start-docker-image-tester, docker-image-test] runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/integration_test_dolphin.yml b/.github/workflows/integration_test_dolphin.yml index ce19e1a58..ac45a7422 100644 --- a/.github/workflows/integration_test_dolphin.yml +++ b/.github/workflows/integration_test_dolphin.yml @@ -394,7 +394,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-node-builder-current: - if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') + if: ${{ always() }} needs: [start-node-builder-current, build-node-current] runs-on: ubuntu-20.04 steps: @@ -431,7 +431,7 @@ jobs: aws-image-search-pattern: ${{ env.AWS_IMAGE_SEARCH_PATTERN }} aws-image-search-owners: ${{ env.AWS_IMAGE_SEARCH_OWNERS }} stop-dolphin-integration-tester: - if: contains(github.event.pull_request.labels.*.name, 'A-dolphin' || github.ref == 'refs/heads/manta') + if: ${{ always() }} needs: [start-dolphin-integration-tester, dolphin-integration-test] runs-on: ubuntu-20.04 steps: From 7fa60d51aeaaef7cb0de8db0e0976d5595c35146 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Fri, 2 Sep 2022 12:54:42 +0300 Subject: [PATCH 21/22] Fix clippy unnecessary borrows Signed-off-by: Georgi Zlatarev --- node/src/command.rs | 2 +- pallets/asset-manager/src/lib.rs | 32 +++++++++---------- pallets/collator-selection/src/lib.rs | 12 +++---- pallets/manta-pay/src/bin/precompute_coins.rs | 2 +- pallets/manta-pay/src/lib.rs | 12 +++---- pallets/vesting/src/lib.rs | 10 +++--- runtime/calamari/src/xcm_config.rs | 2 +- runtime/common/tests/xcm_mock/parachain.rs | 2 +- runtime/dolphin/src/xcm_config.rs | 2 +- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index 209c86a0d..c7a773594 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -424,7 +424,7 @@ pub fn run_with(cli: Cli) -> Result { runner.run_node_until_exit(|config| async move { let hwbench = if !cli.no_hardware_benchmarks { config.database.path().map(|database_path| { - let _ = std::fs::create_dir_all(&database_path); + let _ = std::fs::create_dir_all(database_path); sc_sysinfo::gather_hwbench(Some(database_path)) }) } else { diff --git a/pallets/asset-manager/src/lib.rs b/pallets/asset-manager/src/lib.rs index 74da16e16..13201471e 100644 --- a/pallets/asset-manager/src/lib.rs +++ b/pallets/asset-manager/src/lib.rs @@ -141,9 +141,9 @@ pub mod pallet { let asset_id = >::NativeAssetId::get(); let metadata = >::NativeAssetMetadata::get(); let location = >::NativeAssetLocation::get(); - AssetIdLocation::::insert(&asset_id, &location); - AssetIdMetadata::::insert(&asset_id, &metadata); - LocationAssetId::::insert(&location, &asset_id); + AssetIdLocation::::insert(asset_id, &location); + AssetIdMetadata::::insert(asset_id, &metadata); + LocationAssetId::::insert(&location, asset_id); } } @@ -278,9 +278,9 @@ pub mod pallet { metadata.is_sufficient(), ) .map_err(|_| Error::::ErrorCreatingAsset)?; - AssetIdLocation::::insert(&asset_id, &location); - AssetIdMetadata::::insert(&asset_id, &metadata); - LocationAssetId::::insert(&location, &asset_id); + AssetIdLocation::::insert(asset_id, &location); + AssetIdMetadata::::insert(asset_id, &metadata); + LocationAssetId::::insert(&location, asset_id); // If it's a new para id, which will be inserted with AssetCount as 1. // If not, AssetCount will increased by 1. @@ -314,7 +314,7 @@ pub mod pallet { // checks validity T::ModifierOrigin::ensure_origin(origin)?; ensure!( - AssetIdLocation::::contains_key(&asset_id), + AssetIdLocation::::contains_key(asset_id), Error::::UpdateNonExistAsset ); ensure!( @@ -323,10 +323,10 @@ pub mod pallet { ); // change the ledger state. let old_location = - AssetIdLocation::::get(&asset_id).ok_or(Error::::UpdateNonExistAsset)?; + AssetIdLocation::::get(asset_id).ok_or(Error::::UpdateNonExistAsset)?; LocationAssetId::::remove(&old_location); - LocationAssetId::::insert(&location, &asset_id); - AssetIdLocation::::insert(&asset_id, &location); + LocationAssetId::::insert(&location, asset_id); + AssetIdLocation::::insert(asset_id, &location); // 1. If the new location has new para id, insert the new para id, // the old para id will be deleted if AssetCount <= 1, or decreased by 1. @@ -379,14 +379,14 @@ pub mod pallet { Error::::CannotUpdateNativeAssetMetadata ); ensure!( - AssetIdLocation::::contains_key(&asset_id), + AssetIdLocation::::contains_key(asset_id), Error::::UpdateNonExistAsset ); >::AssetRegistrar::update_asset_metadata( asset_id, metadata.clone().into(), )?; - AssetIdMetadata::::insert(&asset_id, &metadata); + AssetIdMetadata::::insert(asset_id, &metadata); Self::deposit_event(Event::::AssetMetadataUpdated { asset_id, metadata }); Ok(()) } @@ -406,10 +406,10 @@ pub mod pallet { ) -> DispatchResult { T::ModifierOrigin::ensure_origin(origin)?; ensure!( - AssetIdLocation::::contains_key(&asset_id), + AssetIdLocation::::contains_key(asset_id), Error::::UpdateNonExistAsset ); - UnitsPerSecond::::insert(&asset_id, &units_per_second); + UnitsPerSecond::::insert(asset_id, units_per_second); Self::deposit_event(Event::::UnitsPerSecondUpdated { asset_id, units_per_second, @@ -434,7 +434,7 @@ pub mod pallet { ) -> DispatchResult { T::ModifierOrigin::ensure_origin(origin)?; ensure!( - AssetIdLocation::::contains_key(&asset_id), + AssetIdLocation::::contains_key(asset_id), Error::::UpdateNonExistAsset ); @@ -475,7 +475,7 @@ pub mod pallet { #[pallet::compact] min_xcm_fee: u128, ) -> DispatchResult { T::ModifierOrigin::ensure_origin(origin)?; - MinXcmFee::::insert(&reserve_chain, &min_xcm_fee); + MinXcmFee::::insert(&reserve_chain, min_xcm_fee); Self::deposit_event(Event::::MinXcmFeeUpdated { reserve_chain, min_xcm_fee, diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index ee1fc03b9..12ba655e0 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -279,10 +279,10 @@ pub mod pallet { self.eviction_tolerance <= Percent::one(), "Eviction tolerance must be given as a percentage - number between 0 and 100", ); - >::put(&self.desired_candidates); - >::put(&self.candidacy_bond); - >::put(&self.eviction_baseline); - >::put(&self.eviction_tolerance); + >::put(self.desired_candidates); + >::put(self.candidacy_bond); + >::put(self.eviction_baseline); + >::put(self.eviction_tolerance); >::put(&self.invulnerables); } } @@ -362,7 +362,7 @@ pub mod pallet { if max > T::MaxCandidates::get() { log::warn!("max > T::MaxCandidates; you might need to run benchmarks again"); } - >::put(&max); + >::put(max); Self::deposit_event(Event::NewDesiredCandidates(max)); Ok(().into()) } @@ -377,7 +377,7 @@ pub mod pallet { bond: BalanceOf, ) -> DispatchResultWithPostInfo { T::UpdateOrigin::ensure_origin(origin)?; - >::put(&bond); + >::put(bond); Self::deposit_event(Event::NewCandidacyBond(bond)); Ok(().into()) } diff --git a/pallets/manta-pay/src/bin/precompute_coins.rs b/pallets/manta-pay/src/bin/precompute_coins.rs index 08b5165ea..b30d77f75 100644 --- a/pallets/manta-pay/src/bin/precompute_coins.rs +++ b/pallets/manta-pay/src/bin/precompute_coins.rs @@ -231,7 +231,7 @@ fn main() -> Result<()> { target_file, ); fs::create_dir_all( - &target_file + target_file .parent() .expect("This file should have a parent."), )?; diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index f0741a129..74f50532c 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -686,7 +686,7 @@ where #[inline] fn is_unspent(&self, void_number: config::VoidNumber) -> Option { - if VoidNumberSet::::contains_key(encode(&void_number)) { + if VoidNumberSet::::contains_key(encode(void_number)) { None } else { Some(Wrap(void_number)) @@ -698,7 +698,7 @@ where &self, output: config::UtxoAccumulatorOutput, ) -> Option { - if UtxoAccumulatorOutputs::::contains_key(encode(&output)) { + if UtxoAccumulatorOutputs::::contains_key(encode(output)) { return Some(Wrap(output)); } None @@ -713,7 +713,7 @@ where let index = VoidNumberSetSize::::get(); let mut i = 0; for (_, void_number) in iter { - let void_number = encode(&void_number.0); + let void_number = encode(void_number.0); VoidNumberSet::::insert(void_number, ()); VoidNumberSetInsertionOrder::::insert(index + i, void_number); i += 1; @@ -733,7 +733,7 @@ where #[inline] fn is_not_registered(&self, utxo: config::Utxo) -> Option { - if UtxoSet::::contains_key(encode(&utxo)) { + if UtxoSet::::contains_key(encode(utxo)) { None } else { Some(Wrap(utxo)) @@ -784,14 +784,14 @@ where .expect("If this errors, then we have run out of Merkle Tree capacity."), ); let next_index = current_path.leaf_index().0 as u64; - let utxo = encode(&utxo); + let utxo = encode(utxo); UtxoSet::::insert(utxo, ()); Shards::::insert(shard_index, next_index, (utxo, EncryptedNote::from(note))); } tree.current_path = current_path.into(); if let Some(next_root) = next_root { ShardTrees::::insert(shard_index, tree); - UtxoAccumulatorOutputs::::insert(encode(&next_root), ()); + UtxoAccumulatorOutputs::::insert(encode(next_root), ()); } } } diff --git a/pallets/vesting/src/lib.rs b/pallets/vesting/src/lib.rs index 4f2a734b3..8928500a0 100644 --- a/pallets/vesting/src/lib.rs +++ b/pallets/vesting/src/lib.rs @@ -231,7 +231,7 @@ pub mod pallet { /// The dispatch origin for this call must be _Signed_. /// /// - `target`: The account receiving the vested funds. - /// - `locked_amount`: How much tokens will be transfered. + /// - `locked_amount`: How much tokens will be transferred. #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::vested_transfer())] pub fn vested_transfer( @@ -274,7 +274,7 @@ impl Pallet { /// (Re)set pallet's currency lock on `who`'s account in accordance with their /// current unvested amount. fn update_lock(who: &T::AccountId) -> DispatchResult { - let vesting = Self::vesting_balance(&who).ok_or(Error::::NotVesting)?; + let vesting = Self::vesting_balance(who).ok_or(Error::::NotVesting)?; let now = T::Timestamp::now().as_secs(); // compute the vested portion @@ -291,7 +291,7 @@ impl Pallet { if unvested.is_zero() { T::Currency::remove_lock(VESTING_ID, who); - VestingBalances::::remove(&who); + VestingBalances::::remove(who); Self::deposit_event(Event::::VestingCompleted(who.clone())); } else { let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE; @@ -309,11 +309,11 @@ impl Pallet { // Ensure current user doesn't have any vested token. ensure!( - !VestingBalances::::contains_key(&who), + !VestingBalances::::contains_key(who), Error::::ExistingVestingSchedule ); - VestingBalances::::insert(&who, locked); + VestingBalances::::insert(who, locked); // it can't fail, but even if somehow it did, we don't really care. Self::update_lock(who) } diff --git a/runtime/calamari/src/xcm_config.rs b/runtime/calamari/src/xcm_config.rs index e7419167c..d644bb3f6 100644 --- a/runtime/calamari/src/xcm_config.rs +++ b/runtime/calamari/src/xcm_config.rs @@ -300,7 +300,7 @@ where { fn convert(currency: CurrencyId) -> Option { match currency { - CurrencyId::MantaCurrency(asset_id) => match AssetXConverter::reverse_ref(&asset_id) { + CurrencyId::MantaCurrency(asset_id) => match AssetXConverter::reverse_ref(asset_id) { Ok(location) => Some(location), Err(_) => None, }, diff --git a/runtime/common/tests/xcm_mock/parachain.rs b/runtime/common/tests/xcm_mock/parachain.rs index 7c484af34..94d0cb9c3 100644 --- a/runtime/common/tests/xcm_mock/parachain.rs +++ b/runtime/common/tests/xcm_mock/parachain.rs @@ -588,7 +588,7 @@ where { fn convert(currency: CurrencyId) -> Option { match currency { - CurrencyId::MantaCurrency(asset_id) => match AssetXConverter::reverse_ref(&asset_id) { + CurrencyId::MantaCurrency(asset_id) => match AssetXConverter::reverse_ref(asset_id) { Ok(location) => Some(location), Err(_) => None, }, diff --git a/runtime/dolphin/src/xcm_config.rs b/runtime/dolphin/src/xcm_config.rs index 1dc8b7895..a3acdf992 100644 --- a/runtime/dolphin/src/xcm_config.rs +++ b/runtime/dolphin/src/xcm_config.rs @@ -299,7 +299,7 @@ where { fn convert(currency: CurrencyId) -> Option { match currency { - CurrencyId::MantaCurrency(asset_id) => match AssetXConverter::reverse_ref(&asset_id) { + CurrencyId::MantaCurrency(asset_id) => match AssetXConverter::reverse_ref(asset_id) { Ok(location) => Some(location), Err(_) => None, }, From 29b14f5e6a2f75c1c930e1df87a2ff8ae34f6f13 Mon Sep 17 00:00:00 2001 From: Georgi Zlatarev Date: Fri, 2 Sep 2022 12:57:28 +0300 Subject: [PATCH 22/22] Comment Signed-off-by: Georgi Zlatarev --- runtime/calamari/src/lib.rs | 1 + runtime/dolphin/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index 1f2cdb06f..ee5582553 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -1015,6 +1015,7 @@ impl_runtime_apis! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = None; pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( KsmLocation::get(), + // Random amount for the benchmark. MultiAsset { fun: Fungible(1_000_000_000_000), id: Concrete(KsmLocation::get()) }, )); pub const CheckedAccount: Option = None; diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index cb2b4ac1f..2c216cbe9 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -1012,6 +1012,7 @@ impl_runtime_apis! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = None; pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( RocLocation::get(), + // Random amount for the benchmark. MultiAsset { fun: Fungible(1_000_000_000_000_000_000), id: Concrete(RocLocation::get()) }, )); pub const CheckedAccount: Option = None;