diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/burn_at_relay.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/burn_at_relay.rs new file mode 100644 index 0000000000000..0bae1242ac8d3 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/burn_at_relay.rs @@ -0,0 +1,84 @@ +// Copyright (C) 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +use crate::imports::*; +use emulated_integration_tests_common::accounts; + +/// Create asset and then remove privileges; this results in the burning of the deposit, which must +/// burn at the Relay Chain. +#[test] +fn create_asset_remove_privileges_burn_deposit_at_relay() { + let owner = AssetHubRococo::account_id_of(accounts::CHARLIE); + let asset_id = 3939; + + // We need first to teleport some balance so that it can be withdrawn later on the Relay + // Chain. Otherwise the asset is not withdrawable due to how genesis is set up. + Rococo::execute_with(|| { + type XcmPallet = ::XcmPallet; + + assert_ok!(XcmPallet::limited_teleport_assets( + ::RuntimeOrigin::signed(Rococo::account_id_of(accounts::CHARLIE)), + bx!(Parachain(AssetHubRococo::para_id().into()).into()), + bx!((*AsRef::<[u8; 32]>::as_ref(&owner)).into()), + bx!(Assets::from((Here, 1_000_000_000_000u128)).into()), + 0, + WeightLimit::Unlimited, + )); + }); + + let original_total_issuance = + Rococo::execute_with(|| ::Balances::total_issuance()); + + let deposit = AssetHubRococo::execute_with(|| { + type Assets = ::Assets; + type Balances = ::Balances; + + let original_reserved_balance = Balances::reserved_balance(owner.clone()); + + assert_ok!(Assets::create( + ::RuntimeOrigin::signed(owner.clone()), + asset_id.into(), + owner.clone().into(), + 1, + )); + assert_ok!(Assets::set_metadata( + ::RuntimeOrigin::signed(owner.clone()), + asset_id.into(), + vec![], + vec![], + 0, + )); + + let new_reserved_balance = Balances::reserved_balance(owner.clone()); + let original_total_issuance = Balances::total_issuance(); + + let deposit = new_reserved_balance - original_reserved_balance; + assert!(deposit != 0); // This ensures we are testing something. + + assert_ok!(Assets::revoke_all_privileges( + ::RuntimeOrigin::signed(owner.clone()), + asset_id.into(), + )); + + assert_eq!(deposit, original_total_issuance - Balances::total_issuance()); + + deposit + }); + + let new_total_issuance = + Rococo::execute_with(|| ::Balances::total_issuance()); + + assert_eq!(deposit, original_total_issuance - new_total_issuance); +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/mod.rs index 88fa379c4072b..c5764f3b237ab 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/mod.rs @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +mod burn_at_relay; mod claim_assets; mod hybrid_transfers; mod reserve_transfer; diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/burn_at_relay.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/burn_at_relay.rs new file mode 100644 index 0000000000000..4ebfd838a31fe --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/burn_at_relay.rs @@ -0,0 +1,84 @@ +// Copyright (C) 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +use crate::imports::*; +use emulated_integration_tests_common::accounts; + +/// Create asset and then remove privileges; this results in the burning of the deposit, which must +/// burn at the Relay Chain. +#[test] +fn create_asset_remove_privileges_burn_deposit_at_relay() { + let owner = AssetHubWestend::account_id_of(accounts::CHARLIE); + let asset_id = 3939; + + // We need first to teleport some balance so that it can be withdrawn later on the Relay + // Chain. Otherwise the asset is not withdrawable due to how genesis is set up. + Westend::execute_with(|| { + type XcmPallet = ::XcmPallet; + + assert_ok!(XcmPallet::limited_teleport_assets( + ::RuntimeOrigin::signed(Westend::account_id_of(accounts::CHARLIE)), + bx!(Parachain(AssetHubWestend::para_id().into()).into()), + bx!((*AsRef::<[u8; 32]>::as_ref(&owner)).into()), + bx!(Assets::from((Here, 1_000_000_000_000u128)).into()), + 0, + WeightLimit::Unlimited, + )); + }); + + let original_total_issuance = + Westend::execute_with(|| ::Balances::total_issuance()); + + let deposit = AssetHubWestend::execute_with(|| { + type Assets = ::Assets; + type Balances = ::Balances; + + let original_reserved_balance = Balances::reserved_balance(owner.clone()); + + assert_ok!(Assets::create( + ::RuntimeOrigin::signed(owner.clone()), + asset_id.into(), + owner.clone().into(), + 1, + )); + assert_ok!(Assets::set_metadata( + ::RuntimeOrigin::signed(owner.clone()), + asset_id.into(), + vec![], + vec![], + 0, + )); + + let new_reserved_balance = Balances::reserved_balance(owner.clone()); + let original_total_issuance = Balances::total_issuance(); + + let deposit = new_reserved_balance - original_reserved_balance; + assert!(deposit != 0); // This ensures we are testing something. + + assert_ok!(Assets::revoke_all_privileges( + ::RuntimeOrigin::signed(owner.clone()), + asset_id.into(), + )); + + assert_eq!(deposit, original_total_issuance - Balances::total_issuance()); + + deposit + }); + + let new_total_issuance = + Westend::execute_with(|| ::Balances::total_issuance()); + + assert_eq!(deposit, original_total_issuance - new_total_issuance); +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs index 73b73b239a1bb..436d9a3aaba31 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +mod burn_at_relay; mod claim_assets; mod fellowship_treasury; mod hybrid_transfers; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 2f3fb6b68c4ab..362c0da0346fc 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -63,7 +63,8 @@ use frame_support::{ ord_parameter_types, parameter_types, traits::{ fungible, fungibles, tokens::imbalance::ResolveAssetTo, AsEnsureOriginWithArg, ConstBool, - ConstU128, ConstU32, ConstU64, ConstU8, EitherOfDiverse, InstanceFilter, TransformOrigin, + ConstU128, ConstU32, ConstU64, ConstU8, DefensiveResult, EitherOfDiverse, Imbalance, + InstanceFilter, OnUnbalanced, TransformOrigin, }, weights::{ConstantMultiplier, Weight, WeightToFee as _}, BoundedVec, PalletId, @@ -99,13 +100,17 @@ use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; #[cfg(feature = "runtime-benchmarks")] use xcm::latest::prelude::{ - Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, - NetworkId, NonFungible, Parent, ParentThen, Response, XCM_VERSION, + InteriorLocation, Junction, Junction::*, NetworkId, NonFungible, Parent, ParentThen, Response, + XCM_VERSION, }; use xcm::{ - latest::prelude::{AssetId, BodyId}, + latest::prelude::{ + Asset, AssetId, Assets as XcmAssets, BodyId, BurnAsset, Fungible, Here, Instruction, + Location, Reanchorable, ReceiveTeleportedAsset, WeightLimit, Xcm, XcmContext, XcmError, + }, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm, }; +use xcm_executor::traits::TransactAsset; use xcm_runtime_apis::{ dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, fees::Error as XcmPaymentApiError, @@ -245,6 +250,50 @@ parameter_types! { /// We allow root to execute privileged asset operations. pub type AssetsForceOrigin = EnsureRoot; +type AssetTransactor = ::AssetTransactor; + +fn try_burn_at_relay(value: Balance) -> Result<(), XcmError> { + let asset = Asset { id: AssetId(Location::parent()), fun: Fungible(value) }; + let dest = Location::parent(); + let parent_assets = Into::::into(asset.clone()) + .reanchored(&dest, &Here.into()) + .defensive_map_err(|_| XcmError::ReanchorFailed)?; + + let dummy_xcm_context = XcmContext { origin: None, message_id: [0; 32], topic: None }; + + AssetTransactor::can_check_out(&dest, &asset, &dummy_xcm_context)?; + + PolkadotXcm::send_xcm( + Here, + Location::parent(), + Xcm(vec![ + Instruction::UnpaidExecution { + weight_limit: WeightLimit::Unlimited, + check_origin: None, + }, + ReceiveTeleportedAsset(parent_assets.clone()), + BurnAsset(parent_assets), + ]), + )?; + + AssetTransactor::check_out(&dest, &asset, &dummy_xcm_context); + + Ok(()) +} + +// Burn negative imbalance at the relay chain. +pub struct BurnAtRelay; + +impl OnUnbalanced> for BurnAtRelay { + fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { + let amount = amount.peek(); + if let Err(e) = try_burn_at_relay(amount) { + log::error!(target: "runtime::assets", "failed to burn balance at relay: amount: \ + {amount}: {e:?}"); + } + } +} + // Called "Trust Backed" assets because these are generally registered by some account, and users of // the asset assume it has some claimed backing. The pallet is called `Assets` in // `construct_runtime` to avoid breaking changes on storage reads. @@ -269,6 +318,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type AssetAccountDeposit = AssetAccountDeposit; type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type DepositDestinationOnRevocation = BurnAtRelay; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } @@ -312,6 +362,7 @@ impl pallet_assets::Config for Runtime { type Extra = (); type WeightInfo = weights::pallet_assets_pool::WeightInfo; type CallbackHandle = (); + type DepositDestinationOnRevocation = BurnAtRelay; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } @@ -437,6 +488,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit; type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type DepositDestinationOnRevocation = BurnAtRelay; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = xcm_config::XcmBenchmarkHelper; } @@ -1016,9 +1068,13 @@ pub type Migrations = ( InitStorageVersions, // unreleased cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, + // unreleased cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, pallet_collator_selection::migration::v2::MigrationToV2, frame_support::migrations::RemovePallet, + pallet_assets::migration::v2::MigrateV1ToV2, + pallet_assets::migration::v2::MigrateV1ToV2, + pallet_assets::migration::v2::MigrateV1ToV2, // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, ); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_foreign.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_foreign.rs index c76c1137335a1..b3deb29cb447b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_foreign.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_foreign.rs @@ -16,33 +16,26 @@ //! Autogenerated weights for `pallet_assets` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024 +//! HOSTNAME: `runner-dcu62vjg-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot-parachain +// target/production/polkadot-parachain // benchmark // pallet // --steps=50 // --repeat=20 // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json // --pallet=pallet_assets -// --no-storage-info -// --no-median-slopes -// --no-min-squares -// --extrinsic=* -// --steps=50 -// --repeat=20 -// --json -// --header=./file_header.txt -// --output=./parachains/runtimes/assets/asset-hub-rococo/src/weights/ +// --chain=asset-hub-rococo-dev +// --header=./cumulus/file_header.txt +// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -65,8 +58,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `107` // Estimated: `4273` - // Minimum execution time: 30_485_000 picoseconds. - Weight::from_parts(31_007_000, 0) + // Minimum execution time: 26_183_000 picoseconds. + Weight::from_parts(26_879_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) @@ -77,8 +70,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `4` // Estimated: `4273` - // Minimum execution time: 12_991_000 picoseconds. - Weight::from_parts(13_304_000, 0) + // Minimum execution time: 9_162_000 picoseconds. + Weight::from_parts(9_521_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -89,50 +82,52 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `276` // Estimated: `4273` - // Minimum execution time: 15_689_000 picoseconds. - Weight::from_parts(16_063_000, 0) + // Minimum execution time: 10_726_000 picoseconds. + Weight::from_parts(11_194_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: ForeignAssets Asset (r:1 w:1) - /// Proof: ForeignAssets Asset (max_values: None, max_size: Some(808), added: 3283, mode: MaxEncodedLen) - /// Storage: ForeignAssets Account (r:1001 w:1000) - /// Proof: ForeignAssets Account (max_values: None, max_size: Some(732), added: 3207, mode: MaxEncodedLen) - /// Storage: System Account (r:1000 w:1000) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: `ForeignAssets::Asset` (r:1 w:1) + /// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`) + /// Storage: `ForeignAssets::Account` (r:1001 w:1000) + /// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1000 w:1000) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `c` is `[0, 1000]`. /// The range of component `c` is `[0, 1000]`. /// The range of component `c` is `[0, 1000]`. fn destroy_accounts(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + c * (208 ±0)` // Estimated: `4273 + c * (3207 ±0)` - // Minimum execution time: 18_533_000 picoseconds. - Weight::from_parts(18_791_000, 0) + // Minimum execution time: 15_118_000 picoseconds. + Weight::from_parts(15_433_000, 0) .saturating_add(Weight::from_parts(0, 4273)) - // Standard Error: 5_059 - .saturating_add(Weight::from_parts(12_049_659, 0).saturating_mul(c.into())) + // Standard Error: 5_039 + .saturating_add(Weight::from_parts(12_784_335, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into()))) .saturating_add(Weight::from_parts(0, 3207).saturating_mul(c.into())) } - /// Storage: ForeignAssets Asset (r:1 w:1) - /// Proof: ForeignAssets Asset (max_values: None, max_size: Some(808), added: 3283, mode: MaxEncodedLen) - /// Storage: ForeignAssets Approvals (r:1001 w:1000) - /// Proof: ForeignAssets Approvals (max_values: None, max_size: Some(746), added: 3221, mode: MaxEncodedLen) + /// Storage: `ForeignAssets::Asset` (r:1 w:1) + /// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`) + /// Storage: `ForeignAssets::Approvals` (r:1001 w:1000) + /// Proof: `ForeignAssets::Approvals` (`max_values`: None, `max_size`: Some(746), added: 3221, mode: `MaxEncodedLen`) + /// The range of component `a` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy_approvals(a: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `413 + a * (86 ±0)` // Estimated: `4273 + a * (3221 ±0)` - // Minimum execution time: 20_028_000 picoseconds. - Weight::from_parts(20_148_000, 0) + // Minimum execution time: 14_994_000 picoseconds. + Weight::from_parts(15_559_000, 0) .saturating_add(Weight::from_parts(0, 4273)) - // Standard Error: 3_401 - .saturating_add(Weight::from_parts(13_897_319, 0).saturating_mul(a.into())) + // Standard Error: 2_722 + .saturating_add(Weight::from_parts(13_228_169, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -147,8 +142,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 15_949_000 picoseconds. - Weight::from_parts(16_241_000, 0) + // Minimum execution time: 12_602_000 picoseconds. + Weight::from_parts(13_136_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -161,8 +156,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 27_156_000 picoseconds. - Weight::from_parts(28_182_000, 0) + // Minimum execution time: 21_020_000 picoseconds. + Weight::from_parts(21_703_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -175,8 +170,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `4273` - // Minimum execution time: 33_503_000 picoseconds. - Weight::from_parts(33_860_000, 0) + // Minimum execution time: 27_616_000 picoseconds. + Weight::from_parts(28_322_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -191,8 +186,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `7404` - // Minimum execution time: 45_065_000 picoseconds. - Weight::from_parts(45_856_000, 0) + // Minimum execution time: 38_276_000 picoseconds. + Weight::from_parts(39_125_000, 0) .saturating_add(Weight::from_parts(0, 7404)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -207,8 +202,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `7404` - // Minimum execution time: 39_913_000 picoseconds. - Weight::from_parts(40_791_000, 0) + // Minimum execution time: 34_415_000 picoseconds. + Weight::from_parts(35_449_000, 0) .saturating_add(Weight::from_parts(0, 7404)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -223,8 +218,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `7404` - // Minimum execution time: 45_337_000 picoseconds. - Weight::from_parts(45_980_000, 0) + // Minimum execution time: 38_390_000 picoseconds. + Weight::from_parts(39_340_000, 0) .saturating_add(Weight::from_parts(0, 7404)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -237,8 +232,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `4273` - // Minimum execution time: 19_012_000 picoseconds. - Weight::from_parts(19_326_000, 0) + // Minimum execution time: 14_384_000 picoseconds. + Weight::from_parts(14_825_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -251,8 +246,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `4273` - // Minimum execution time: 18_656_000 picoseconds. - Weight::from_parts(19_205_000, 0) + // Minimum execution time: 14_460_000 picoseconds. + Weight::from_parts(14_971_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -263,8 +258,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `276` // Estimated: `4273` - // Minimum execution time: 15_440_000 picoseconds. - Weight::from_parts(15_825_000, 0) + // Minimum execution time: 10_700_000 picoseconds. + Weight::from_parts(11_078_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -275,8 +270,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `276` // Estimated: `4273` - // Minimum execution time: 15_465_000 picoseconds. - Weight::from_parts(15_769_000, 0) + // Minimum execution time: 10_690_000 picoseconds. + Weight::from_parts(11_067_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -289,8 +284,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 16_579_000 picoseconds. - Weight::from_parts(16_931_000, 0) + // Minimum execution time: 13_106_000 picoseconds. + Weight::from_parts(13_543_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -301,27 +296,33 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 15_138_000 picoseconds. - Weight::from_parts(15_435_000, 0) + // Minimum execution time: 11_462_000 picoseconds. + Weight::from_parts(11_844_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: ForeignAssets Asset (r:1 w:0) - /// Proof: ForeignAssets Asset (max_values: None, max_size: Some(808), added: 3283, mode: MaxEncodedLen) - /// Storage: ForeignAssets Metadata (r:1 w:1) - /// Proof: ForeignAssets Metadata (max_values: None, max_size: Some(738), added: 3213, mode: MaxEncodedLen) + /// Storage: `ForeignAssets::Asset` (r:1 w:0) + /// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`) + /// Storage: `ForeignAssets::Metadata` (r:1 w:1) + /// Proof: `ForeignAssets::Metadata` (`max_values`: None, `max_size`: Some(738), added: 3213, mode: `MaxEncodedLen`) + /// The range of component `n` is `[0, 50]`. + /// The range of component `s` is `[0, 50]`. /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn set_metadata(_n: u32, _s: u32, ) -> Weight { + fn set_metadata(n: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 29_846_000 picoseconds. - Weight::from_parts(31_607_649, 0) + // Minimum execution time: 23_216_000 picoseconds. + Weight::from_parts(24_164_478, 0) .saturating_add(Weight::from_parts(0, 4273)) + // Standard Error: 300 + .saturating_add(Weight::from_parts(2_477, 0).saturating_mul(n.into())) + // Standard Error: 300 + .saturating_add(Weight::from_parts(1_661, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -333,29 +334,33 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `406` // Estimated: `4273` - // Minimum execution time: 30_582_000 picoseconds. - Weight::from_parts(31_008_000, 0) + // Minimum execution time: 24_617_000 picoseconds. + Weight::from_parts(25_335_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: ForeignAssets Asset (r:1 w:0) - /// Proof: ForeignAssets Asset (max_values: None, max_size: Some(808), added: 3283, mode: MaxEncodedLen) - /// Storage: ForeignAssets Metadata (r:1 w:1) - /// Proof: ForeignAssets Metadata (max_values: None, max_size: Some(738), added: 3213, mode: MaxEncodedLen) + /// Storage: `ForeignAssets::Asset` (r:1 w:0) + /// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`) + /// Storage: `ForeignAssets::Metadata` (r:1 w:1) + /// Proof: `ForeignAssets::Metadata` (`max_values`: None, `max_size`: Some(738), added: 3213, mode: `MaxEncodedLen`) /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn force_set_metadata(_n: u32, s: u32, ) -> Weight { + /// The range of component `n` is `[0, 50]`. + /// The range of component `s` is `[0, 50]`. + fn force_set_metadata(n: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `81` // Estimated: `4273` - // Minimum execution time: 14_186_000 picoseconds. - Weight::from_parts(14_717_332, 0) + // Minimum execution time: 11_423_000 picoseconds. + Weight::from_parts(11_989_506, 0) .saturating_add(Weight::from_parts(0, 4273)) - // Standard Error: 517 - .saturating_add(Weight::from_parts(2_595, 0).saturating_mul(s.into())) + // Standard Error: 168 + .saturating_add(Weight::from_parts(664, 0).saturating_mul(n.into())) + // Standard Error: 168 + .saturating_add(Weight::from_parts(1_210, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -367,8 +372,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `406` // Estimated: `4273` - // Minimum execution time: 29_499_000 picoseconds. - Weight::from_parts(29_918_000, 0) + // Minimum execution time: 23_719_000 picoseconds. + Weight::from_parts(24_477_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -379,8 +384,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 13_815_000 picoseconds. - Weight::from_parts(14_138_000, 0) + // Minimum execution time: 10_269_000 picoseconds. + Weight::from_parts(10_803_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -393,8 +398,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `276` // Estimated: `4273` - // Minimum execution time: 33_029_000 picoseconds. - Weight::from_parts(33_524_000, 0) + // Minimum execution time: 26_696_000 picoseconds. + Weight::from_parts(27_569_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -411,8 +416,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `520` // Estimated: `7404` - // Minimum execution time: 63_205_000 picoseconds. - Weight::from_parts(64_078_000, 0) + // Minimum execution time: 57_242_000 picoseconds. + Weight::from_parts(58_498_000, 0) .saturating_add(Weight::from_parts(0, 7404)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) @@ -425,8 +430,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `446` // Estimated: `4273` - // Minimum execution time: 34_948_000 picoseconds. - Weight::from_parts(35_484_000, 0) + // Minimum execution time: 29_233_000 picoseconds. + Weight::from_parts(30_182_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -439,8 +444,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `446` // Estimated: `4273` - // Minimum execution time: 35_722_000 picoseconds. - Weight::from_parts(36_266_000, 0) + // Minimum execution time: 29_549_000 picoseconds. + Weight::from_parts(30_722_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -451,8 +456,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 15_855_000 picoseconds. - Weight::from_parts(16_182_000, 0) + // Minimum execution time: 11_610_000 picoseconds. + Weight::from_parts(11_978_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -467,8 +472,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `345` // Estimated: `4273` - // Minimum execution time: 34_984_000 picoseconds. - Weight::from_parts(35_512_000, 0) + // Minimum execution time: 29_136_000 picoseconds. + Weight::from_parts(30_027_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -481,8 +486,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 33_041_000 picoseconds. - Weight::from_parts(34_124_000, 0) + // Minimum execution time: 26_375_000 picoseconds. + Weight::from_parts(27_020_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -497,8 +502,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `471` // Estimated: `4273` - // Minimum execution time: 31_728_000 picoseconds. - Weight::from_parts(32_012_000, 0) + // Minimum execution time: 28_040_000 picoseconds. + Weight::from_parts(28_809_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -511,8 +516,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `401` // Estimated: `4273` - // Minimum execution time: 29_432_000 picoseconds. - Weight::from_parts(29_968_000, 0) + // Minimum execution time: 25_635_000 picoseconds. + Weight::from_parts(26_360_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -525,8 +530,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `4273` - // Minimum execution time: 18_827_000 picoseconds. - Weight::from_parts(19_172_000, 0) + // Minimum execution time: 14_735_000 picoseconds. + Weight::from_parts(15_143_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -541,4 +546,19 @@ impl pallet_assets::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + + /// Storage: `ForeignAssets::Asset` (r:1 w:1) + /// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`) + /// Storage: `ForeignAssets::Metadata` (r:1 w:1) + /// Proof: `ForeignAssets::Metadata` (`max_values`: None, `max_size`: Some(738), added: 3213, mode: `MaxEncodedLen`) + fn revoke_all_privileges() -> Weight { + // Proof Size summary in bytes: + // Measured: `406` + // Estimated: `4273` + // Minimum execution time: 40_301_000 picoseconds. + Weight::from_parts(41_226_000, 0) + .saturating_add(Weight::from_parts(0, 4273)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_local.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_local.rs index cf4f60042bc68..79133f37fccc2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_local.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_local.rs @@ -16,28 +16,26 @@ //! Autogenerated weights for `pallet_assets` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024 +//! HOSTNAME: `runner-dcu62vjg-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot-parachain +// target/production/polkadot-parachain // benchmark // pallet -// --chain=asset-hub-rococo-dev -// --wasm-execution=compiled -// --pallet=pallet_assets -// --no-storage-info -// --no-median-slopes -// --no-min-squares -// --extrinsic=* // --steps=50 // --repeat=20 -// --json -// --header=./file_header.txt -// --output=./parachains/runtimes/assets/asset-hub-rococo/src/weights/ +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_assets +// --chain=asset-hub-rococo-dev +// --header=./cumulus/file_header.txt +// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -56,10 +54,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `109` + // Measured: `145` // Estimated: `3675` - // Minimum execution time: 26_510_000 picoseconds. - Weight::from_parts(27_332_000, 0) + // Minimum execution time: 22_223_000 picoseconds. + Weight::from_parts(22_933_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -68,10 +66,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn force_create() -> Weight { // Proof Size summary in bytes: - // Measured: `6` + // Measured: `42` // Estimated: `3675` - // Minimum execution time: 10_899_000 picoseconds. - Weight::from_parts(11_395_000, 0) + // Minimum execution time: 9_024_000 picoseconds. + Weight::from_parts(9_629_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -80,10 +78,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn start_destroy() -> Weight { // Proof Size summary in bytes: - // Measured: `277` + // Measured: `314` // Estimated: `3675` - // Minimum execution time: 13_593_000 picoseconds. - Weight::from_parts(14_108_000, 0) + // Minimum execution time: 9_740_000 picoseconds. + Weight::from_parts(10_134_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -96,15 +94,16 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// The range of component `c` is `[0, 1000]`. /// The range of component `c` is `[0, 1000]`. + /// The range of component `c` is `[0, 1000]`. fn destroy_accounts(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + c * (208 ±0)` // Estimated: `3675 + c * (2609 ±0)` - // Minimum execution time: 16_216_000 picoseconds. - Weight::from_parts(16_636_000, 0) + // Minimum execution time: 13_980_000 picoseconds. + Weight::from_parts(14_204_000, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 9_346 - .saturating_add(Weight::from_parts(15_306_152, 0).saturating_mul(c.into())) + // Standard Error: 5_058 + .saturating_add(Weight::from_parts(12_570_475, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -117,17 +116,20 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. + /// The range of component `a` is `[0, 1000]`. fn destroy_approvals(a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `414 + a * (86 ±0)` + // Measured: `451 + a * (86 ±0)` // Estimated: `3675 + a * (2623 ±0)` - // Minimum execution time: 16_745_000 picoseconds. - Weight::from_parts(17_247_000, 0) + // Minimum execution time: 13_875_000 picoseconds. + Weight::from_parts(14_114_000, 0) .saturating_add(Weight::from_parts(0, 3675)) - .saturating_add(Weight::from_parts(15_634_963, 0).saturating_mul(a.into())) + // Standard Error: 2_864 + .saturating_add(Weight::from_parts(13_378_504, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) .saturating_add(Weight::from_parts(0, 2623).saturating_mul(a.into())) } /// Storage: `Assets::Asset` (r:1 w:1) @@ -136,10 +138,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) fn finish_destroy() -> Weight { // Proof Size summary in bytes: - // Measured: `243` + // Measured: `280` // Estimated: `3675` - // Minimum execution time: 13_650_000 picoseconds. - Weight::from_parts(14_721_000, 0) + // Minimum execution time: 11_030_000 picoseconds. + Weight::from_parts(11_618_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -150,10 +152,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `243` + // Measured: `280` // Estimated: `3675` - // Minimum execution time: 24_121_000 picoseconds. - Weight::from_parts(25_023_000, 0) + // Minimum execution time: 19_546_000 picoseconds. + Weight::from_parts(20_462_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -164,10 +166,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `388` // Estimated: `3675` - // Minimum execution time: 31_414_000 picoseconds. - Weight::from_parts(32_235_000, 0) + // Minimum execution time: 26_180_000 picoseconds. + Weight::from_parts(26_885_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -180,10 +182,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `388` // Estimated: `6208` - // Minimum execution time: 43_114_000 picoseconds. - Weight::from_parts(44_106_000, 0) + // Minimum execution time: 35_938_000 picoseconds. + Weight::from_parts(37_068_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -196,10 +198,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `388` // Estimated: `6208` - // Minimum execution time: 37_954_000 picoseconds. - Weight::from_parts(38_772_000, 0) + // Minimum execution time: 31_641_000 picoseconds. + Weight::from_parts(32_857_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -212,10 +214,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `388` // Estimated: `6208` - // Minimum execution time: 43_051_000 picoseconds. - Weight::from_parts(44_003_000, 0) + // Minimum execution time: 36_066_000 picoseconds. + Weight::from_parts(37_202_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -226,10 +228,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn freeze() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `388` // Estimated: `3675` - // Minimum execution time: 17_048_000 picoseconds. - Weight::from_parts(17_614_000, 0) + // Minimum execution time: 13_433_000 picoseconds. + Weight::from_parts(13_880_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -240,10 +242,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn thaw() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `388` // Estimated: `3675` - // Minimum execution time: 16_705_000 picoseconds. - Weight::from_parts(17_581_000, 0) + // Minimum execution time: 13_255_000 picoseconds. + Weight::from_parts(13_789_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -252,10 +254,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn freeze_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `277` + // Measured: `314` // Estimated: `3675` - // Minimum execution time: 13_284_000 picoseconds. - Weight::from_parts(13_735_000, 0) + // Minimum execution time: 9_457_000 picoseconds. + Weight::from_parts(10_013_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -264,10 +266,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn thaw_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `277` + // Measured: `314` // Estimated: `3675` - // Minimum execution time: 13_030_000 picoseconds. - Weight::from_parts(13_417_000, 0) + // Minimum execution time: 9_503_000 picoseconds. + Weight::from_parts(9_965_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -278,10 +280,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `243` + // Measured: `280` // Estimated: `3675` - // Minimum execution time: 14_174_000 picoseconds. - Weight::from_parts(14_660_000, 0) + // Minimum execution time: 11_621_000 picoseconds. + Weight::from_parts(12_251_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -290,10 +292,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `243` + // Measured: `280` // Estimated: `3675` - // Minimum execution time: 12_737_000 picoseconds. - Weight::from_parts(13_172_000, 0) + // Minimum execution time: 10_333_000 picoseconds. + Weight::from_parts(10_847_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -306,17 +308,19 @@ impl pallet_assets::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 50]`. /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. + /// The range of component `n` is `[0, 50]`. + /// The range of component `s` is `[0, 50]`. fn set_metadata(n: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `243` + // Measured: `280` // Estimated: `3675` - // Minimum execution time: 27_707_000 picoseconds. - Weight::from_parts(29_036_880, 0) + // Minimum execution time: 22_210_000 picoseconds. + Weight::from_parts(23_359_867, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 688 - .saturating_add(Weight::from_parts(2_426, 0).saturating_mul(n.into())) - // Standard Error: 688 - .saturating_add(Weight::from_parts(776, 0).saturating_mul(s.into())) + // Standard Error: 351 + .saturating_add(Weight::from_parts(1_709, 0).saturating_mul(n.into())) + // Standard Error: 351 + .saturating_add(Weight::from_parts(857, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -326,10 +330,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `407` + // Measured: `444` // Estimated: `3675` - // Minimum execution time: 28_514_000 picoseconds. - Weight::from_parts(29_216_000, 0) + // Minimum execution time: 22_720_000 picoseconds. + Weight::from_parts(23_930_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -342,17 +346,19 @@ impl pallet_assets::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 50]`. /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. + /// The range of component `n` is `[0, 50]`. + /// The range of component `s` is `[0, 50]`. fn force_set_metadata(n: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `82` + // Measured: `119` // Estimated: `3675` - // Minimum execution time: 12_452_000 picoseconds. - Weight::from_parts(13_095_356, 0) + // Minimum execution time: 10_626_000 picoseconds. + Weight::from_parts(11_157_429, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 275 - .saturating_add(Weight::from_parts(826, 0).saturating_mul(n.into())) - // Standard Error: 275 - .saturating_add(Weight::from_parts(808, 0).saturating_mul(s.into())) + // Standard Error: 181 + .saturating_add(Weight::from_parts(1_684, 0).saturating_mul(n.into())) + // Standard Error: 181 + .saturating_add(Weight::from_parts(1_794, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -362,10 +368,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) fn force_clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `407` + // Measured: `444` // Estimated: `3675` - // Minimum execution time: 28_181_000 picoseconds. - Weight::from_parts(29_050_000, 0) + // Minimum execution time: 22_515_000 picoseconds. + Weight::from_parts(23_383_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -374,10 +380,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn force_asset_status() -> Weight { // Proof Size summary in bytes: - // Measured: `243` + // Measured: `280` // Estimated: `3675` - // Minimum execution time: 12_253_000 picoseconds. - Weight::from_parts(12_545_000, 0) + // Minimum execution time: 9_838_000 picoseconds. + Weight::from_parts(10_112_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -388,10 +394,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`) fn approve_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `277` + // Measured: `314` // Estimated: `3675` - // Minimum execution time: 31_084_000 picoseconds. - Weight::from_parts(32_052_000, 0) + // Minimum execution time: 25_623_000 picoseconds. + Weight::from_parts(26_450_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -406,10 +412,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn transfer_approved() -> Weight { // Proof Size summary in bytes: - // Measured: `521` + // Measured: `558` // Estimated: `6208` - // Minimum execution time: 61_756_000 picoseconds. - Weight::from_parts(62_740_000, 0) + // Minimum execution time: 54_182_000 picoseconds. + Weight::from_parts(55_669_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) @@ -420,10 +426,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`) fn cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `447` + // Measured: `484` // Estimated: `3675` - // Minimum execution time: 33_370_000 picoseconds. - Weight::from_parts(34_127_000, 0) + // Minimum execution time: 28_103_000 picoseconds. + Weight::from_parts(28_947_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -434,10 +440,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`) fn force_cancel_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `447` + // Measured: `484` // Estimated: `3675` - // Minimum execution time: 33_753_000 picoseconds. - Weight::from_parts(34_613_000, 0) + // Minimum execution time: 28_295_000 picoseconds. + Weight::from_parts(29_149_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -446,10 +452,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn set_min_balance() -> Weight { // Proof Size summary in bytes: - // Measured: `243` + // Measured: `280` // Estimated: `3675` - // Minimum execution time: 13_508_000 picoseconds. - Weight::from_parts(13_997_000, 0) + // Minimum execution time: 10_829_000 picoseconds. + Weight::from_parts(11_276_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -462,10 +468,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn touch() -> Weight { // Proof Size summary in bytes: - // Measured: `346` + // Measured: `383` // Estimated: `3675` - // Minimum execution time: 32_578_000 picoseconds. - Weight::from_parts(33_675_000, 0) + // Minimum execution time: 27_897_000 picoseconds. + Weight::from_parts(28_628_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -476,10 +482,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn touch_other() -> Weight { // Proof Size summary in bytes: - // Measured: `243` + // Measured: `280` // Estimated: `3675` - // Minimum execution time: 30_768_000 picoseconds. - Weight::from_parts(31_710_000, 0) + // Minimum execution time: 25_467_000 picoseconds. + Weight::from_parts(26_124_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -492,10 +498,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn refund() -> Weight { // Proof Size summary in bytes: - // Measured: `472` + // Measured: `509` // Estimated: `3675` - // Minimum execution time: 30_028_000 picoseconds. - Weight::from_parts(30_793_000, 0) + // Minimum execution time: 27_106_000 picoseconds. + Weight::from_parts(28_064_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -506,10 +512,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn refund_other() -> Weight { // Proof Size summary in bytes: - // Measured: `402` + // Measured: `439` // Estimated: `3675` - // Minimum execution time: 28_354_000 picoseconds. - Weight::from_parts(29_097_000, 0) + // Minimum execution time: 24_570_000 picoseconds. + Weight::from_parts(25_511_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -520,10 +526,10 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn block() -> Weight { // Proof Size summary in bytes: - // Measured: `351` + // Measured: `388` // Estimated: `3675` - // Minimum execution time: 16_607_000 picoseconds. - Weight::from_parts(17_433_000, 0) + // Minimum execution time: 13_363_000 picoseconds. + Weight::from_parts(13_796_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -538,4 +544,19 @@ impl pallet_assets::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + + /// Storage: `Assets::Asset` (r:1 w:1) + /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `Assets::Metadata` (r:1 w:1) + /// Proof: `Assets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + fn revoke_all_privileges() -> Weight { + // Proof Size summary in bytes: + // Measured: `444` + // Estimated: `3675` + // Minimum execution time: 38_426_000 picoseconds. + Weight::from_parts(39_400_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_pool.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_pool.rs index 2cd85de009895..e4638fb852a18 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_pool.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_pool.rs @@ -16,11 +16,11 @@ //! Autogenerated weights for `pallet_assets` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024 +//! HOSTNAME: `runner-dcu62vjg-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024 // Executed Command: // target/production/polkadot-parachain @@ -31,11 +31,11 @@ // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/builds/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json // --pallet=pallet_assets // --chain=asset-hub-rococo-dev -// --header=./file_header.txt -// --output=./parachains/runtimes/assets/asset-hub-rococo/src/weights/ +// --header=./cumulus/file_header.txt +// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -54,8 +54,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3675` - // Minimum execution time: 11_591_000 picoseconds. - Weight::from_parts(11_901_000, 0) + // Minimum execution time: 9_472_000 picoseconds. + Weight::from_parts(10_002_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -66,8 +66,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3675` - // Minimum execution time: 11_184_000 picoseconds. - Weight::from_parts(11_640_000, 0) + // Minimum execution time: 8_688_000 picoseconds. + Weight::from_parts(9_276_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -78,8 +78,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 13_809_000 picoseconds. - Weight::from_parts(14_226_000, 0) + // Minimum execution time: 9_593_000 picoseconds. + Weight::from_parts(9_988_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -97,11 +97,11 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0 + c * (208 ±0)` // Estimated: `3675 + c * (2609 ±0)` - // Minimum execution time: 16_439_000 picoseconds. - Weight::from_parts(16_743_000, 0) + // Minimum execution time: 13_609_000 picoseconds. + Weight::from_parts(14_135_000, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 4_792 - .saturating_add(Weight::from_parts(14_463_991, 0).saturating_mul(c.into())) + // Standard Error: 5_315 + .saturating_add(Weight::from_parts(12_666_231, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -119,11 +119,11 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `451 + a * (86 ±0)` // Estimated: `3675 + a * (2623 ±0)` - // Minimum execution time: 17_218_000 picoseconds. - Weight::from_parts(17_585_000, 0) + // Minimum execution time: 13_792_000 picoseconds. + Weight::from_parts(14_039_000, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 2_056 - .saturating_add(Weight::from_parts(5_323_866, 0).saturating_mul(a.into())) + // Standard Error: 3_028 + .saturating_add(Weight::from_parts(13_266_704, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -138,8 +138,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 13_848_000 picoseconds. - Weight::from_parts(14_325_000, 0) + // Minimum execution time: 11_225_000 picoseconds. + Weight::from_parts(11_494_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -152,8 +152,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 24_904_000 picoseconds. - Weight::from_parts(25_607_000, 0) + // Minimum execution time: 19_778_000 picoseconds. + Weight::from_parts(20_412_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -166,8 +166,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3675` - // Minimum execution time: 31_477_000 picoseconds. - Weight::from_parts(32_338_000, 0) + // Minimum execution time: 25_763_000 picoseconds. + Weight::from_parts(26_507_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -182,8 +182,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `6208` - // Minimum execution time: 42_994_000 picoseconds. - Weight::from_parts(44_041_000, 0) + // Minimum execution time: 35_492_000 picoseconds. + Weight::from_parts(36_602_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -198,8 +198,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `6208` - // Minimum execution time: 37_551_000 picoseconds. - Weight::from_parts(38_648_000, 0) + // Minimum execution time: 32_111_000 picoseconds. + Weight::from_parts(32_664_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -214,8 +214,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `6208` - // Minimum execution time: 42_829_000 picoseconds. - Weight::from_parts(44_029_000, 0) + // Minimum execution time: 35_929_000 picoseconds. + Weight::from_parts(36_940_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -228,8 +228,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3675` - // Minimum execution time: 17_304_000 picoseconds. - Weight::from_parts(17_782_000, 0) + // Minimum execution time: 13_227_000 picoseconds. + Weight::from_parts(13_670_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -242,8 +242,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3675` - // Minimum execution time: 17_040_000 picoseconds. - Weight::from_parts(17_698_000, 0) + // Minimum execution time: 13_219_000 picoseconds. + Weight::from_parts(13_754_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -254,8 +254,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 13_238_000 picoseconds. - Weight::from_parts(13_810_000, 0) + // Minimum execution time: 9_410_000 picoseconds. + Weight::from_parts(9_858_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -266,8 +266,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 13_034_000 picoseconds. - Weight::from_parts(13_603_000, 0) + // Minimum execution time: 9_347_000 picoseconds. + Weight::from_parts(9_810_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -280,8 +280,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 14_357_000 picoseconds. - Weight::from_parts(14_774_000, 0) + // Minimum execution time: 11_581_000 picoseconds. + Weight::from_parts(12_226_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -292,8 +292,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 13_040_000 picoseconds. - Weight::from_parts(13_616_000, 0) + // Minimum execution time: 10_308_000 picoseconds. + Weight::from_parts(10_685_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -312,13 +312,13 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 15_274_000 picoseconds. - Weight::from_parts(16_096_881, 0) + // Minimum execution time: 11_454_000 picoseconds. + Weight::from_parts(12_207_264, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 239 - .saturating_add(Weight::from_parts(1_631, 0).saturating_mul(n.into())) - // Standard Error: 239 - .saturating_add(Weight::from_parts(2_334, 0).saturating_mul(s.into())) + // Standard Error: 225 + .saturating_add(Weight::from_parts(1_386, 0).saturating_mul(n.into())) + // Standard Error: 225 + .saturating_add(Weight::from_parts(656, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -330,8 +330,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `444` // Estimated: `3675` - // Minimum execution time: 15_900_000 picoseconds. - Weight::from_parts(16_526_000, 0) + // Minimum execution time: 12_336_000 picoseconds. + Weight::from_parts(12_774_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -350,13 +350,13 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `119` // Estimated: `3675` - // Minimum execution time: 13_391_000 picoseconds. - Weight::from_parts(14_047_176, 0) + // Minimum execution time: 10_535_000 picoseconds. + Weight::from_parts(11_172_274, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 172 - .saturating_add(Weight::from_parts(2_617, 0).saturating_mul(n.into())) - // Standard Error: 172 - .saturating_add(Weight::from_parts(2_081, 0).saturating_mul(s.into())) + // Standard Error: 159 + .saturating_add(Weight::from_parts(938, 0).saturating_mul(n.into())) + // Standard Error: 159 + .saturating_add(Weight::from_parts(1_034, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -368,8 +368,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `444` // Estimated: `3675` - // Minimum execution time: 15_794_000 picoseconds. - Weight::from_parts(16_279_000, 0) + // Minimum execution time: 11_920_000 picoseconds. + Weight::from_parts(12_352_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -380,8 +380,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 12_538_000 picoseconds. - Weight::from_parts(13_080_000, 0) + // Minimum execution time: 9_824_000 picoseconds. + Weight::from_parts(10_147_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -394,8 +394,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 18_991_000 picoseconds. - Weight::from_parts(19_812_000, 0) + // Minimum execution time: 25_414_000 picoseconds. + Weight::from_parts(26_298_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -412,8 +412,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `558` // Estimated: `6208` - // Minimum execution time: 50_336_000 picoseconds. - Weight::from_parts(51_441_000, 0) + // Minimum execution time: 54_065_000 picoseconds. + Weight::from_parts(55_366_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) @@ -426,8 +426,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `484` // Estimated: `3675` - // Minimum execution time: 21_195_000 picoseconds. - Weight::from_parts(21_946_000, 0) + // Minimum execution time: 27_739_000 picoseconds. + Weight::from_parts(28_609_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -440,8 +440,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `484` // Estimated: `3675` - // Minimum execution time: 21_568_000 picoseconds. - Weight::from_parts(22_366_000, 0) + // Minimum execution time: 28_021_000 picoseconds. + Weight::from_parts(28_996_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -452,8 +452,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 13_690_000 picoseconds. - Weight::from_parts(14_086_000, 0) + // Minimum execution time: 10_872_000 picoseconds. + Weight::from_parts(11_196_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -466,8 +466,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 18_240_000 picoseconds. - Weight::from_parts(19_000_000, 0) + // Minimum execution time: 15_308_000 picoseconds. + Weight::from_parts(15_843_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -480,8 +480,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 18_469_000 picoseconds. - Weight::from_parts(19_040_000, 0) + // Minimum execution time: 14_524_000 picoseconds. + Weight::from_parts(15_140_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -494,8 +494,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `406` // Estimated: `3675` - // Minimum execution time: 14_633_000 picoseconds. - Weight::from_parts(15_296_000, 0) + // Minimum execution time: 13_743_000 picoseconds. + Weight::from_parts(14_358_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -508,8 +508,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `439` // Estimated: `3675` - // Minimum execution time: 14_751_000 picoseconds. - Weight::from_parts(15_312_000, 0) + // Minimum execution time: 13_283_000 picoseconds. + Weight::from_parts(13_663_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -522,8 +522,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3675` - // Minimum execution time: 16_930_000 picoseconds. - Weight::from_parts(17_653_000, 0) + // Minimum execution time: 13_176_000 picoseconds. + Weight::from_parts(13_746_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -538,4 +538,19 @@ impl pallet_assets::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + + /// Storage: `PoolAssets::Asset` (r:1 w:1) + /// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `PoolAssets::Metadata` (r:1 w:1) + /// Proof: `PoolAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + fn revoke_all_privileges() -> Weight { + // Proof Size summary in bytes: + // Measured: `444` + // Estimated: `3675` + // Minimum execution time: 19_478_000 picoseconds. + Weight::from_parts(19_995_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 97dbe7c361c11..16f15fcb062fb 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -45,8 +45,8 @@ use frame_support::{ traits::{ fungible, fungibles, tokens::{imbalance::ResolveAssetTo, nonfungibles_v2::Inspect}, - AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, InstanceFilter, - TransformOrigin, + AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, DefensiveResult, + Imbalance, InstanceFilter, OnUnbalanced, TransformOrigin, }, weights::{ConstantMultiplier, Weight, WeightToFee as _}, BoundedVec, PalletId, @@ -91,16 +91,20 @@ use assets_common::{ }; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use xcm::{ - latest::prelude::AssetId, + latest::prelude::{ + Asset, AssetId, Assets as XcmAssets, BurnAsset, Fungible, Here, Instruction, Location, + Reanchorable, ReceiveTeleportedAsset, WeightLimit, Xcm, XcmContext, XcmError, + }, prelude::{VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm}, }; #[cfg(feature = "runtime-benchmarks")] use xcm::latest::prelude::{ - Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, - NetworkId, NonFungible, Parent, ParentThen, Response, XCM_VERSION, + InteriorLocation, Junction, Junction::*, NetworkId, NonFungible, Parent, ParentThen, Response, + XCM_VERSION, }; +use xcm_executor::traits::TransactAsset; use xcm_runtime_apis::{ dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, fees::Error as XcmPaymentApiError, @@ -242,6 +246,50 @@ parameter_types! { pub type AssetsForceOrigin = EnsureRoot; +type AssetTransactor = ::AssetTransactor; + +fn try_burn_at_relay(value: Balance) -> Result<(), XcmError> { + let asset = Asset { id: AssetId(Location::parent()), fun: Fungible(value) }; + let dest = Location::parent(); + let parent_assets = Into::::into(asset.clone()) + .reanchored(&dest, &Here.into()) + .defensive_map_err(|_| XcmError::ReanchorFailed)?; + + let dummy_xcm_context = XcmContext { origin: None, message_id: [0; 32], topic: None }; + + AssetTransactor::can_check_out(&dest, &asset, &dummy_xcm_context)?; + + PolkadotXcm::send_xcm( + Here, + Location::parent(), + Xcm(vec![ + Instruction::UnpaidExecution { + weight_limit: WeightLimit::Unlimited, + check_origin: None, + }, + ReceiveTeleportedAsset(parent_assets.clone()), + BurnAsset(parent_assets), + ]), + )?; + + AssetTransactor::check_out(&dest, &asset, &dummy_xcm_context); + + Ok(()) +} + +// Burn negative imbalance at the relay chain. +pub struct BurnAtRelay; + +impl OnUnbalanced> for BurnAtRelay { + fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { + let amount = amount.peek(); + if let Err(e) = try_burn_at_relay(amount) { + log::error!(target: "runtime::assets", "failed to burn balance at relay: amount: \ + {amount}: {e:?}"); + } + } +} + // Called "Trust Backed" assets because these are generally registered by some account, and users of // the asset assume it has some claimed backing. The pallet is called `Assets` in // `construct_runtime` to avoid breaking changes on storage reads. @@ -266,6 +314,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type AssetAccountDeposit = AssetAccountDeposit; type RemoveItemsLimit = ConstU32<1000>; + type DepositDestinationOnRevocation = BurnAtRelay; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } @@ -308,6 +357,7 @@ impl pallet_assets::Config for Runtime { type Extra = (); type WeightInfo = weights::pallet_assets_pool::WeightInfo; type CallbackHandle = (); + type DepositDestinationOnRevocation = BurnAtRelay; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } @@ -433,6 +483,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit; type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type DepositDestinationOnRevocation = BurnAtRelay; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = xcm_config::XcmBenchmarkHelper; } @@ -1021,6 +1072,10 @@ pub type Migrations = ( // unreleased cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, + // unreleased + pallet_assets::migration::v2::MigrateV1ToV2, + pallet_assets::migration::v2::MigrateV1ToV2, + pallet_assets::migration::v2::MigrateV1ToV2, // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, ); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_foreign.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_foreign.rs index 2692de9aeb50d..3ca5dc62d1e0e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_foreign.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_foreign.rs @@ -1,42 +1,41 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// This file is part of Cumulus. -// 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// 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. +// 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_assets` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024 +//! HOSTNAME: `runner-dcu62vjg-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot-parachain +// target/production/polkadot-parachain // benchmark // pallet -// --chain=asset-hub-westend-dev -// --wasm-execution=compiled -// --pallet=pallet_assets -// --no-storage-info -// --no-median-slopes -// --no-min-squares -// --extrinsic=* // --steps=50 // --repeat=20 -// --json -// --header=./file_header.txt -// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/ +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_assets +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -59,8 +58,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `107` // Estimated: `4273` - // Minimum execution time: 29_123_000 picoseconds. - Weight::from_parts(30_025_000, 0) + // Minimum execution time: 26_339_000 picoseconds. + Weight::from_parts(27_145_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) @@ -71,8 +70,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `4` // Estimated: `4273` - // Minimum execution time: 11_857_000 picoseconds. - Weight::from_parts(12_256_000, 0) + // Minimum execution time: 9_538_000 picoseconds. + Weight::from_parts(9_970_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -83,8 +82,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `276` // Estimated: `4273` - // Minimum execution time: 14_513_000 picoseconds. - Weight::from_parts(15_110_000, 0) + // Minimum execution time: 11_983_000 picoseconds. + Weight::from_parts(12_456_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -102,11 +101,11 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0 + c * (208 ±0)` // Estimated: `4273 + c * (3207 ±0)` - // Minimum execution time: 17_168_000 picoseconds. - Weight::from_parts(17_732_000, 0) + // Minimum execution time: 15_062_000 picoseconds. + Weight::from_parts(15_478_000, 0) .saturating_add(Weight::from_parts(0, 4273)) - // Standard Error: 8_406 - .saturating_add(Weight::from_parts(15_274_700, 0).saturating_mul(c.into())) + // Standard Error: 4_867 + .saturating_add(Weight::from_parts(12_838_428, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -124,11 +123,11 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `413 + a * (86 ±0)` // Estimated: `4273 + a * (3221 ±0)` - // Minimum execution time: 18_111_000 picoseconds. - Weight::from_parts(18_573_000, 0) + // Minimum execution time: 15_955_000 picoseconds. + Weight::from_parts(16_543_000, 0) .saturating_add(Weight::from_parts(0, 4273)) - // Standard Error: 3_988 - .saturating_add(Weight::from_parts(15_270_030, 0).saturating_mul(a.into())) + // Standard Error: 2_841 + .saturating_add(Weight::from_parts(13_361_922, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -143,8 +142,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 14_768_000 picoseconds. - Weight::from_parts(15_323_000, 0) + // Minimum execution time: 13_040_000 picoseconds. + Weight::from_parts(13_411_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -157,8 +156,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 25_855_000 picoseconds. - Weight::from_parts(26_592_000, 0) + // Minimum execution time: 21_377_000 picoseconds. + Weight::from_parts(22_177_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -171,8 +170,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `4273` - // Minimum execution time: 33_065_000 picoseconds. - Weight::from_parts(34_113_000, 0) + // Minimum execution time: 29_298_000 picoseconds. + Weight::from_parts(30_107_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -187,8 +186,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `7404` - // Minimum execution time: 45_409_000 picoseconds. - Weight::from_parts(46_176_000, 0) + // Minimum execution time: 40_328_000 picoseconds. + Weight::from_parts(41_493_000, 0) .saturating_add(Weight::from_parts(0, 7404)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -203,8 +202,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `7404` - // Minimum execution time: 40_017_000 picoseconds. - Weight::from_parts(41_081_000, 0) + // Minimum execution time: 36_153_000 picoseconds. + Weight::from_parts(37_131_000, 0) .saturating_add(Weight::from_parts(0, 7404)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -219,8 +218,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `7404` - // Minimum execution time: 45_189_000 picoseconds. - Weight::from_parts(46_133_000, 0) + // Minimum execution time: 40_397_000 picoseconds. + Weight::from_parts(41_489_000, 0) .saturating_add(Weight::from_parts(0, 7404)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -233,8 +232,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `4273` - // Minimum execution time: 18_147_000 picoseconds. - Weight::from_parts(18_923_000, 0) + // Minimum execution time: 15_608_000 picoseconds. + Weight::from_parts(16_114_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -247,8 +246,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `4273` - // Minimum execution time: 17_801_000 picoseconds. - Weight::from_parts(18_472_000, 0) + // Minimum execution time: 15_703_000 picoseconds. + Weight::from_parts(16_345_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -259,8 +258,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `276` // Estimated: `4273` - // Minimum execution time: 14_204_000 picoseconds. - Weight::from_parts(14_671_000, 0) + // Minimum execution time: 11_784_000 picoseconds. + Weight::from_parts(12_150_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -271,8 +270,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `276` // Estimated: `4273` - // Minimum execution time: 13_752_000 picoseconds. - Weight::from_parts(14_380_000, 0) + // Minimum execution time: 12_067_000 picoseconds. + Weight::from_parts(12_365_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -285,8 +284,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 15_310_000 picoseconds. - Weight::from_parts(15_761_000, 0) + // Minimum execution time: 13_354_000 picoseconds. + Weight::from_parts(13_693_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -297,8 +296,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 13_656_000 picoseconds. - Weight::from_parts(14_121_000, 0) + // Minimum execution time: 11_514_000 picoseconds. + Weight::from_parts(11_964_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -317,13 +316,13 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 28_413_000 picoseconds. - Weight::from_parts(29_399_881, 0) + // Minimum execution time: 24_636_000 picoseconds. + Weight::from_parts(25_465_171, 0) .saturating_add(Weight::from_parts(0, 4273)) - // Standard Error: 369 - .saturating_add(Weight::from_parts(5_400, 0).saturating_mul(n.into())) - // Standard Error: 369 - .saturating_add(Weight::from_parts(3_525, 0).saturating_mul(s.into())) + // Standard Error: 275 + .saturating_add(Weight::from_parts(2_800, 0).saturating_mul(n.into())) + // Standard Error: 275 + .saturating_add(Weight::from_parts(3_214, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -335,8 +334,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `406` // Estimated: `4273` - // Minimum execution time: 29_660_000 picoseconds. - Weight::from_parts(30_281_000, 0) + // Minimum execution time: 26_109_000 picoseconds. + Weight::from_parts(26_772_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -355,13 +354,13 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `81` // Estimated: `4273` - // Minimum execution time: 12_949_000 picoseconds. - Weight::from_parts(13_813_061, 0) + // Minimum execution time: 10_696_000 picoseconds. + Weight::from_parts(11_372_892, 0) .saturating_add(Weight::from_parts(0, 4273)) - // Standard Error: 229 - .saturating_add(Weight::from_parts(480, 0).saturating_mul(n.into())) - // Standard Error: 229 - .saturating_add(Weight::from_parts(94, 0).saturating_mul(s.into())) + // Standard Error: 160 + .saturating_add(Weight::from_parts(1_455, 0).saturating_mul(n.into())) + // Standard Error: 160 + .saturating_add(Weight::from_parts(1_294, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -373,8 +372,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `406` // Estimated: `4273` - // Minimum execution time: 29_002_000 picoseconds. - Weight::from_parts(29_772_000, 0) + // Minimum execution time: 24_841_000 picoseconds. + Weight::from_parts(25_768_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -385,8 +384,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 13_023_000 picoseconds. - Weight::from_parts(13_528_000, 0) + // Minimum execution time: 10_552_000 picoseconds. + Weight::from_parts(10_940_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -399,8 +398,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `276` // Estimated: `4273` - // Minimum execution time: 32_393_000 picoseconds. - Weight::from_parts(33_164_000, 0) + // Minimum execution time: 27_926_000 picoseconds. + Weight::from_parts(28_417_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -417,8 +416,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `520` // Estimated: `7404` - // Minimum execution time: 64_647_000 picoseconds. - Weight::from_parts(65_669_000, 0) + // Minimum execution time: 59_616_000 picoseconds. + Weight::from_parts(60_863_000, 0) .saturating_add(Weight::from_parts(0, 7404)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) @@ -431,8 +430,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `446` // Estimated: `4273` - // Minimum execution time: 34_292_000 picoseconds. - Weight::from_parts(35_505_000, 0) + // Minimum execution time: 30_814_000 picoseconds. + Weight::from_parts(31_576_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -445,8 +444,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `446` // Estimated: `4273` - // Minimum execution time: 35_358_000 picoseconds. - Weight::from_parts(36_553_000, 0) + // Minimum execution time: 31_107_000 picoseconds. + Weight::from_parts(31_926_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -457,8 +456,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 14_656_000 picoseconds. - Weight::from_parts(15_097_000, 0) + // Minimum execution time: 11_758_000 picoseconds. + Weight::from_parts(12_244_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -473,8 +472,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `345` // Estimated: `4273` - // Minimum execution time: 33_758_000 picoseconds. - Weight::from_parts(34_618_000, 0) + // Minimum execution time: 29_527_000 picoseconds. + Weight::from_parts(30_404_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -487,8 +486,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `4273` - // Minimum execution time: 32_205_000 picoseconds. - Weight::from_parts(33_208_000, 0) + // Minimum execution time: 27_571_000 picoseconds. + Weight::from_parts(28_559_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -503,8 +502,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `471` // Estimated: `4273` - // Minimum execution time: 30_848_000 picoseconds. - Weight::from_parts(31_592_000, 0) + // Minimum execution time: 28_427_000 picoseconds. + Weight::from_parts(29_345_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -517,8 +516,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `401` // Estimated: `4273` - // Minimum execution time: 28_920_000 picoseconds. - Weight::from_parts(29_519_000, 0) + // Minimum execution time: 27_005_000 picoseconds. + Weight::from_parts(27_810_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -531,8 +530,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `350` // Estimated: `4273` - // Minimum execution time: 17_938_000 picoseconds. - Weight::from_parts(18_525_000, 0) + // Minimum execution time: 15_874_000 picoseconds. + Weight::from_parts(16_337_000, 0) .saturating_add(Weight::from_parts(0, 4273)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -547,4 +546,19 @@ impl pallet_assets::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + + /// Storage: `ForeignAssets::Asset` (r:1 w:1) + /// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`) + /// Storage: `ForeignAssets::Metadata` (r:1 w:1) + /// Proof: `ForeignAssets::Metadata` (`max_values`: None, `max_size`: Some(738), added: 3213, mode: `MaxEncodedLen`) + fn revoke_all_privileges() -> Weight { + // Proof Size summary in bytes: + // Measured: `406` + // Estimated: `4273` + // Minimum execution time: 42_157_000 picoseconds. + Weight::from_parts(43_155_000, 0) + .saturating_add(Weight::from_parts(0, 4273)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_local.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_local.rs index d2e12549a45c7..7f45959882c03 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_local.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_local.rs @@ -1,42 +1,41 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// This file is part of Cumulus. -// 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// 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. +// 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_assets` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024 +//! HOSTNAME: `runner-dcu62vjg-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot-parachain +// target/production/polkadot-parachain // benchmark // pallet -// --chain=asset-hub-westend-dev -// --wasm-execution=compiled -// --pallet=pallet_assets -// --no-storage-info -// --no-median-slopes -// --no-min-squares -// --extrinsic=* // --steps=50 // --repeat=20 -// --json -// --header=./file_header.txt -// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/ +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_assets +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -57,8 +56,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `109` // Estimated: `3675` - // Minimum execution time: 25_894_000 picoseconds. - Weight::from_parts(26_675_000, 0) + // Minimum execution time: 21_602_000 picoseconds. + Weight::from_parts(22_318_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -69,8 +68,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `6` // Estimated: `3675` - // Minimum execution time: 10_155_000 picoseconds. - Weight::from_parts(10_864_000, 0) + // Minimum execution time: 7_823_000 picoseconds. + Weight::from_parts(8_251_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -81,8 +80,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3675` - // Minimum execution time: 12_904_000 picoseconds. - Weight::from_parts(13_723_000, 0) + // Minimum execution time: 10_333_000 picoseconds. + Weight::from_parts(10_827_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -100,11 +99,11 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0 + c * (208 ±0)` // Estimated: `3675 + c * (2609 ±0)` - // Minimum execution time: 15_522_000 picoseconds. - Weight::from_parts(16_015_000, 0) + // Minimum execution time: 13_187_000 picoseconds. + Weight::from_parts(13_498_000, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 7_984 - .saturating_add(Weight::from_parts(15_024_602, 0).saturating_mul(c.into())) + // Standard Error: 4_685 + .saturating_add(Weight::from_parts(12_672_357, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -122,11 +121,11 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `414 + a * (86 ±0)` // Estimated: `3675 + a * (2623 ±0)` - // Minimum execution time: 16_570_000 picoseconds. - Weight::from_parts(16_940_000, 0) + // Minimum execution time: 14_050_000 picoseconds. + Weight::from_parts(14_296_000, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 4_030 - .saturating_add(Weight::from_parts(15_317_878, 0).saturating_mul(a.into())) + // Standard Error: 2_878 + .saturating_add(Weight::from_parts(13_374_553, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -141,8 +140,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 13_327_000 picoseconds. - Weight::from_parts(13_909_000, 0) + // Minimum execution time: 10_980_000 picoseconds. + Weight::from_parts(11_327_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -155,8 +154,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 23_662_000 picoseconds. - Weight::from_parts(24_510_000, 0) + // Minimum execution time: 19_496_000 picoseconds. + Weight::from_parts(20_346_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -169,8 +168,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `3675` - // Minimum execution time: 30_903_000 picoseconds. - Weight::from_parts(31_725_000, 0) + // Minimum execution time: 26_529_000 picoseconds. + Weight::from_parts(27_512_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -185,8 +184,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6208` - // Minimum execution time: 42_163_000 picoseconds. - Weight::from_parts(43_176_000, 0) + // Minimum execution time: 37_041_000 picoseconds. + Weight::from_parts(38_430_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -201,8 +200,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6208` - // Minimum execution time: 36_812_000 picoseconds. - Weight::from_parts(37_836_000, 0) + // Minimum execution time: 32_969_000 picoseconds. + Weight::from_parts(33_792_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -217,8 +216,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `6208` - // Minimum execution time: 41_923_000 picoseconds. - Weight::from_parts(43_200_000, 0) + // Minimum execution time: 37_087_000 picoseconds. + Weight::from_parts(38_202_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -231,8 +230,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `3675` - // Minimum execution time: 16_567_000 picoseconds. - Weight::from_parts(17_125_000, 0) + // Minimum execution time: 13_942_000 picoseconds. + Weight::from_parts(14_470_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -245,8 +244,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `3675` - // Minimum execution time: 16_271_000 picoseconds. - Weight::from_parts(17_116_000, 0) + // Minimum execution time: 13_963_000 picoseconds. + Weight::from_parts(14_536_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -257,8 +256,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3675` - // Minimum execution time: 12_772_000 picoseconds. - Weight::from_parts(13_267_000, 0) + // Minimum execution time: 10_060_000 picoseconds. + Weight::from_parts(10_502_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -269,8 +268,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3675` - // Minimum execution time: 12_477_000 picoseconds. - Weight::from_parts(13_110_000, 0) + // Minimum execution time: 9_996_000 picoseconds. + Weight::from_parts(10_384_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -283,8 +282,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 13_857_000 picoseconds. - Weight::from_parts(14_270_000, 0) + // Minimum execution time: 11_159_000 picoseconds. + Weight::from_parts(11_769_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -295,8 +294,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 12_844_000 picoseconds. - Weight::from_parts(13_215_000, 0) + // Minimum execution time: 9_758_000 picoseconds. + Weight::from_parts(10_295_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -315,13 +314,13 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 27_149_000 picoseconds. - Weight::from_parts(28_147_817, 0) + // Minimum execution time: 23_106_000 picoseconds. + Weight::from_parts(24_002_121, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 410 - .saturating_add(Weight::from_parts(3_935, 0).saturating_mul(n.into())) - // Standard Error: 410 - .saturating_add(Weight::from_parts(2_686, 0).saturating_mul(s.into())) + // Standard Error: 362 + .saturating_add(Weight::from_parts(4_045, 0).saturating_mul(n.into())) + // Standard Error: 362 + .saturating_add(Weight::from_parts(4_126, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -333,8 +332,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `407` // Estimated: `3675` - // Minimum execution time: 27_866_000 picoseconds. - Weight::from_parts(28_735_000, 0) + // Minimum execution time: 23_795_000 picoseconds. + Weight::from_parts(24_633_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -353,13 +352,13 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `82` // Estimated: `3675` - // Minimum execution time: 11_877_000 picoseconds. - Weight::from_parts(12_700_940, 0) + // Minimum execution time: 9_381_000 picoseconds. + Weight::from_parts(10_076_735, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 219 - .saturating_add(Weight::from_parts(253, 0).saturating_mul(n.into())) - // Standard Error: 219 - .saturating_add(Weight::from_parts(1_004, 0).saturating_mul(s.into())) + // Standard Error: 171 + .saturating_add(Weight::from_parts(101, 0).saturating_mul(n.into())) + // Standard Error: 171 + .saturating_add(Weight::from_parts(89, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -371,8 +370,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `407` // Estimated: `3675` - // Minimum execution time: 27_536_000 picoseconds. - Weight::from_parts(28_635_000, 0) + // Minimum execution time: 23_281_000 picoseconds. + Weight::from_parts(24_110_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -383,8 +382,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 12_010_000 picoseconds. - Weight::from_parts(12_526_000, 0) + // Minimum execution time: 9_401_000 picoseconds. + Weight::from_parts(9_807_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -397,8 +396,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3675` - // Minimum execution time: 30_436_000 picoseconds. - Weight::from_parts(31_420_000, 0) + // Minimum execution time: 26_281_000 picoseconds. + Weight::from_parts(27_128_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -415,8 +414,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `521` // Estimated: `6208` - // Minimum execution time: 60_189_000 picoseconds. - Weight::from_parts(61_948_000, 0) + // Minimum execution time: 55_118_000 picoseconds. + Weight::from_parts(56_712_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) @@ -429,8 +428,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `447` // Estimated: `3675` - // Minimum execution time: 33_033_000 picoseconds. - Weight::from_parts(33_710_000, 0) + // Minimum execution time: 28_565_000 picoseconds. + Weight::from_parts(29_445_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -443,8 +442,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `447` // Estimated: `3675` - // Minimum execution time: 33_121_000 picoseconds. - Weight::from_parts(34_112_000, 0) + // Minimum execution time: 28_930_000 picoseconds. + Weight::from_parts(29_773_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -455,8 +454,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 12_994_000 picoseconds. - Weight::from_parts(13_442_000, 0) + // Minimum execution time: 10_290_000 picoseconds. + Weight::from_parts(10_811_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -471,8 +470,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `346` // Estimated: `3675` - // Minimum execution time: 31_950_000 picoseconds. - Weight::from_parts(32_750_000, 0) + // Minimum execution time: 27_428_000 picoseconds. + Weight::from_parts(28_450_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -485,8 +484,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 29_976_000 picoseconds. - Weight::from_parts(31_186_000, 0) + // Minimum execution time: 25_590_000 picoseconds. + Weight::from_parts(26_788_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -501,8 +500,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `472` // Estimated: `3675` - // Minimum execution time: 29_549_000 picoseconds. - Weight::from_parts(30_533_000, 0) + // Minimum execution time: 26_662_000 picoseconds. + Weight::from_parts(27_502_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -515,8 +514,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `402` // Estimated: `3675` - // Minimum execution time: 27_746_000 picoseconds. - Weight::from_parts(28_561_000, 0) + // Minimum execution time: 25_450_000 picoseconds. + Weight::from_parts(26_202_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -529,8 +528,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `351` // Estimated: `3675` - // Minimum execution time: 16_408_000 picoseconds. - Weight::from_parts(17_038_000, 0) + // Minimum execution time: 13_789_000 picoseconds. + Weight::from_parts(14_462_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -545,4 +544,19 @@ impl pallet_assets::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + + /// Storage: `Assets::Asset` (r:1 w:1) + /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `Assets::Metadata` (r:1 w:1) + /// Proof: `Assets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + fn revoke_all_privileges() -> Weight { + // Proof Size summary in bytes: + // Measured: `407` + // Estimated: `3675` + // Minimum execution time: 39_172_000 picoseconds. + Weight::from_parts(40_107_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_pool.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_pool.rs index 8368f6e583ccf..99779385f0bd5 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_pool.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_pool.rs @@ -1,42 +1,41 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// This file is part of Cumulus. -// 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// 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. +// 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_assets` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024 +//! HOSTNAME: `runner-dcu62vjg-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot-parachain +// target/production/polkadot-parachain // benchmark // pallet -// --chain=asset-hub-westend-dev -// --wasm-execution=compiled -// --pallet=pallet_assets -// --no-storage-info -// --no-median-slopes -// --no-min-squares -// --extrinsic=* // --steps=50 // --repeat=20 -// --json -// --header=./file_header.txt -// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/ +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_assets +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -55,8 +54,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3675` - // Minimum execution time: 11_148_000 picoseconds. - Weight::from_parts(11_683_000, 0) + // Minimum execution time: 8_815_000 picoseconds. + Weight::from_parts(9_144_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -67,8 +66,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3675` - // Minimum execution time: 10_811_000 picoseconds. - Weight::from_parts(11_324_000, 0) + // Minimum execution time: 8_327_000 picoseconds. + Weight::from_parts(8_713_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -79,8 +78,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 13_360_000 picoseconds. - Weight::from_parts(13_961_000, 0) + // Minimum execution time: 10_733_000 picoseconds. + Weight::from_parts(11_148_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -98,11 +97,11 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0 + c * (208 ±0)` // Estimated: `3675 + c * (2609 ±0)` - // Minimum execution time: 16_162_000 picoseconds. - Weight::from_parts(16_588_000, 0) + // Minimum execution time: 13_830_000 picoseconds. + Weight::from_parts(14_100_000, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 8_120 - .saturating_add(Weight::from_parts(14_997_923, 0).saturating_mul(c.into())) + // Standard Error: 4_806 + .saturating_add(Weight::from_parts(12_687_674, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -120,11 +119,11 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `451 + a * (86 ±0)` // Estimated: `3675 + a * (2623 ±0)` - // Minimum execution time: 17_013_000 picoseconds. - Weight::from_parts(17_433_000, 0) + // Minimum execution time: 14_540_000 picoseconds. + Weight::from_parts(14_886_000, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 3_595 - .saturating_add(Weight::from_parts(5_514_723, 0).saturating_mul(a.into())) + // Standard Error: 2_283 + .saturating_add(Weight::from_parts(5_271_917, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -139,8 +138,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 13_565_000 picoseconds. - Weight::from_parts(14_080_000, 0) + // Minimum execution time: 11_277_000 picoseconds. + Weight::from_parts(11_842_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -153,8 +152,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 24_156_000 picoseconds. - Weight::from_parts(24_879_000, 0) + // Minimum execution time: 20_159_000 picoseconds. + Weight::from_parts(20_981_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -167,8 +166,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3675` - // Minimum execution time: 31_099_000 picoseconds. - Weight::from_parts(31_804_000, 0) + // Minimum execution time: 27_071_000 picoseconds. + Weight::from_parts(27_923_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -183,8 +182,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `6208` - // Minimum execution time: 42_337_000 picoseconds. - Weight::from_parts(43_359_000, 0) + // Minimum execution time: 37_167_000 picoseconds. + Weight::from_parts(38_574_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -199,8 +198,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `6208` - // Minimum execution time: 37_216_000 picoseconds. - Weight::from_parts(37_927_000, 0) + // Minimum execution time: 33_155_000 picoseconds. + Weight::from_parts(34_193_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -215,8 +214,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `6208` - // Minimum execution time: 42_250_000 picoseconds. - Weight::from_parts(43_145_000, 0) + // Minimum execution time: 37_360_000 picoseconds. + Weight::from_parts(38_410_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) @@ -229,8 +228,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3675` - // Minimum execution time: 16_897_000 picoseconds. - Weight::from_parts(17_424_000, 0) + // Minimum execution time: 14_663_000 picoseconds. + Weight::from_parts(15_019_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -243,8 +242,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3675` - // Minimum execution time: 16_804_000 picoseconds. - Weight::from_parts(17_335_000, 0) + // Minimum execution time: 14_476_000 picoseconds. + Weight::from_parts(14_949_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -255,8 +254,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 13_195_000 picoseconds. - Weight::from_parts(13_531_000, 0) + // Minimum execution time: 10_509_000 picoseconds. + Weight::from_parts(10_906_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -267,8 +266,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 12_982_000 picoseconds. - Weight::from_parts(13_469_000, 0) + // Minimum execution time: 10_489_000 picoseconds. + Weight::from_parts(10_919_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -281,8 +280,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 14_275_000 picoseconds. - Weight::from_parts(14_696_000, 0) + // Minimum execution time: 11_916_000 picoseconds. + Weight::from_parts(12_344_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -293,8 +292,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 12_972_000 picoseconds. - Weight::from_parts(13_459_000, 0) + // Minimum execution time: 10_501_000 picoseconds. + Weight::from_parts(10_841_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -313,13 +312,13 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 15_092_000 picoseconds. - Weight::from_parts(15_929_556, 0) + // Minimum execution time: 12_763_000 picoseconds. + Weight::from_parts(13_379_680, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 289 - .saturating_add(Weight::from_parts(3_185, 0).saturating_mul(n.into())) - // Standard Error: 289 - .saturating_add(Weight::from_parts(1_709, 0).saturating_mul(s.into())) + // Standard Error: 234 + .saturating_add(Weight::from_parts(1_763, 0).saturating_mul(n.into())) + // Standard Error: 234 + .saturating_add(Weight::from_parts(2_564, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -331,8 +330,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `444` // Estimated: `3675` - // Minimum execution time: 15_711_000 picoseconds. - Weight::from_parts(16_183_000, 0) + // Minimum execution time: 13_334_000 picoseconds. + Weight::from_parts(13_768_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -347,17 +346,15 @@ impl pallet_assets::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 50]`. /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn force_set_metadata(n: u32, s: u32, ) -> Weight { + fn force_set_metadata(n: u32, _s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `119` // Estimated: `3675` - // Minimum execution time: 13_288_000 picoseconds. - Weight::from_parts(14_061_633, 0) + // Minimum execution time: 10_801_000 picoseconds. + Weight::from_parts(11_431_573, 0) .saturating_add(Weight::from_parts(0, 3675)) - // Standard Error: 215 - .saturating_add(Weight::from_parts(1_169, 0).saturating_mul(n.into())) - // Standard Error: 215 - .saturating_add(Weight::from_parts(900, 0).saturating_mul(s.into())) + // Standard Error: 178 + .saturating_add(Weight::from_parts(104, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -369,8 +366,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `444` // Estimated: `3675` - // Minimum execution time: 15_235_000 picoseconds. - Weight::from_parts(15_998_000, 0) + // Minimum execution time: 12_948_000 picoseconds. + Weight::from_parts(13_409_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -381,8 +378,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 12_556_000 picoseconds. - Weight::from_parts(13_054_000, 0) + // Minimum execution time: 9_860_000 picoseconds. + Weight::from_parts(10_213_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -395,8 +392,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 18_635_000 picoseconds. - Weight::from_parts(19_431_000, 0) + // Minimum execution time: 15_985_000 picoseconds. + Weight::from_parts(16_564_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -413,8 +410,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `558` // Estimated: `6208` - // Minimum execution time: 49_082_000 picoseconds. - Weight::from_parts(50_414_000, 0) + // Minimum execution time: 45_941_000 picoseconds. + Weight::from_parts(46_685_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) @@ -427,8 +424,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `484` // Estimated: `3675` - // Minimum execution time: 20_978_000 picoseconds. - Weight::from_parts(21_628_000, 0) + // Minimum execution time: 18_390_000 picoseconds. + Weight::from_parts(18_915_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -441,8 +438,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `484` // Estimated: `3675` - // Minimum execution time: 21_453_000 picoseconds. - Weight::from_parts(22_134_000, 0) + // Minimum execution time: 18_461_000 picoseconds. + Weight::from_parts(19_092_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -453,8 +450,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 13_390_000 picoseconds. - Weight::from_parts(13_920_000, 0) + // Minimum execution time: 10_820_000 picoseconds. + Weight::from_parts(11_198_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -467,8 +464,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 18_063_000 picoseconds. - Weight::from_parts(18_669_000, 0) + // Minimum execution time: 15_508_000 picoseconds. + Weight::from_parts(16_103_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -481,8 +478,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `280` // Estimated: `3675` - // Minimum execution time: 17_949_000 picoseconds. - Weight::from_parts(18_891_000, 0) + // Minimum execution time: 15_635_000 picoseconds. + Weight::from_parts(16_147_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -495,8 +492,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `406` // Estimated: `3675` - // Minimum execution time: 14_696_000 picoseconds. - Weight::from_parts(15_295_000, 0) + // Minimum execution time: 13_680_000 picoseconds. + Weight::from_parts(14_301_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -509,8 +506,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `439` // Estimated: `3675` - // Minimum execution time: 14_643_000 picoseconds. - Weight::from_parts(15_289_000, 0) + // Minimum execution time: 14_150_000 picoseconds. + Weight::from_parts(14_536_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -523,8 +520,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `388` // Estimated: `3675` - // Minimum execution time: 16_619_000 picoseconds. - Weight::from_parts(17_279_000, 0) + // Minimum execution time: 14_322_000 picoseconds. + Weight::from_parts(14_923_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -539,4 +536,18 @@ impl pallet_assets::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: `PoolAssets::Asset` (r:1 w:1) + /// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `PoolAssets::Metadata` (r:1 w:1) + /// Proof: `PoolAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + fn revoke_all_privileges() -> Weight { + // Proof Size summary in bytes: + // Measured: `444` + // Estimated: `3675` + // Minimum execution time: 20_593_000 picoseconds. + Weight::from_parts(21_136_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } } diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index 7d19c0ed8d85d..b1d97db3c0b41 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -148,6 +148,8 @@ pub type UncheckedExtrinsic = pub type Migrations = ( pallet_balances::migration::MigrateToTrackInactive, pallet_collator_selection::migration::v1::MigrateToV1, + pallet_assets::migration::v2::MigrateV1ToV2, + pallet_assets::migration::v2::MigrateV1ToV2, ); /// Executive: handles dispatch to the various modules. @@ -470,6 +472,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type AssetAccountDeposit = AssetAccountDeposit; type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } @@ -505,6 +508,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit; type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = xcm_config::XcmBenchmarkHelper; } @@ -542,6 +546,7 @@ impl pallet_assets::Config for Runtime { type Extra = (); type WeightInfo = pallet_assets::weights::SubstrateWeight; type CallbackHandle = (); + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } diff --git a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs index dff7046f19726..62bface92403b 100644 --- a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs @@ -595,6 +595,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type AssetAccountDeposit = AssetAccountDeposit; type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } @@ -675,9 +676,12 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - RemoveCollectiveFlip, + Migrations, >; +/// Migrations to apply on runtime upgrade. +pub type Migrations = (RemoveCollectiveFlip, pallet_assets::migration::v2::MigrateV1ToV2); + pub struct RemoveCollectiveFlip; impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip { fn on_runtime_upgrade() -> Weight { diff --git a/polkadot/xcm/pallet-xcm/src/mock.rs b/polkadot/xcm/pallet-xcm/src/mock.rs index 8d0476b0e70d7..646636a449894 100644 --- a/polkadot/xcm/pallet-xcm/src/mock.rs +++ b/polkadot/xcm/pallet-xcm/src/mock.rs @@ -304,6 +304,7 @@ impl pallet_assets::Config for Test { type CallbackHandle = (); type Extra = (); type RemoveItemsLimit = ConstU32<5>; + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = XcmBenchmarkHelper; } diff --git a/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs b/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs index 18bde3aab485a..7c10d97a0cb8c 100644 --- a/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs +++ b/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs @@ -108,6 +108,7 @@ impl pallet_assets::Config for Test { type RemoveItemsLimit = RemoveItemsLimit; type AssetIdParameter = AssetIdForAssets; type CallbackHandle = (); + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } diff --git a/prdoc/pr_4150.prdoc b/prdoc/pr_4150.prdoc new file mode 100644 index 0000000000000..4624675bc2cd7 --- /dev/null +++ b/prdoc/pr_4150.prdoc @@ -0,0 +1,83 @@ +title: "pallet assets: Add the new status `LiveAndNoPrivilege` and new call to revoke privileges" +topic: pallet assets + + +doc: + - audience: Runtime Dev + description: | + The new status "live and no privileges" (`LiveAndNoPrivileges`) is created. Under this + status, owner, issuer, admin and freezer has no privileges and metadata are frozen. + The new call `revoke_all_privileges` is created. This call allows `ForceOrigin` or the + `Owner` to revoke all the privileges on the asset. This operation is irrevesible for the + `Owner`, `ForceOrigin` can always reverse by using `force_asset_status`. + + Storage is backward compatible so the migration consists of updating storage version + from V1 to V2. + + `Config` trait has a new associated type `DepositDestinationOnRevocation`. + This type is used for the destination of the deposit when privileges are revoked. + Set it to `()` to burn them. + + - audience: Runtime User + description: | + The new status "live and no privileges" (`LiveAndNoPrivileges`) is created. Under this + status, owner, issuer, admin and freezer has no privileges and metadata are frozen. + The new call `revoke_all_privileges` is created. This call allows `ForceOrigin` or the + `Owner` to revoke all the privileges on the asset. This operation is irrevesible for the + `Owner`, `ForceOrigin` can always reverse by using `force_asset_status`. + +crates: + - name: pallet-assets + bump: major + - name: staging-xcm-builder + bump: none + - name: pallet-xcm + bump: none + - name: pallet-asset-conversion + bump: none + - name: pallet-asset-tx-payment + bump: none + - name: rococo-parachain-runtime + bump: major + note: | + In `Assets`, assets status can now be "live and no privileges", and there is a new call + `revoke_all_privileges`. + There is also a minor migration for assets. + - name: pallet-asset-conversion-tx-payment + bump: none + - name: pallet-assets-freezer + bump: none + - name: pallet-contracts-mock-network + bump: none + - name: pallet-nft-fractionalization + bump: none + - name: asset-hub-rococo-runtime + bump: major + note: | + In `TrustBackedAssets`, `PoolAssets` and `ForeignAssets`, assets status can now be + "live and no privileges", and there is a new call `revoke_all_privileges`. + There is also some minor migration for assets. + - name: asset-hub-westend-runtime + bump: major + note: | + In `TrustBackedAssets`, `PoolAssets` and `ForeignAssets`, assets status can now be + "live and no privileges", and there is a new call `revoke_all_privileges`. + There is also a minor migration for assets. + - name: penpal-runtime + bump: major + note: | + In `ForeignAssets` and `Assets`, assets status can now be "live and no privileges", and there + is a new call `revoke_all_privileges`. + There is also some minor migration for assets. + - name: pallet-revive-mock-network + bump: major + - name: frame-support + bump: minor + note: | + The trait `ResetTeam` meaning has been precised: even if the asset has no privileges, + the new team will have the privileges. + +migrations: + runtime: + - reference: "pallet-assets: storage version 2" + description: "V2: update is backward compatible with V1, so only storage version 2 needs to be stored" diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 6ae04902aa820..57bf8e256eccd 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -1706,6 +1706,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type WeightInfo = pallet_assets::weights::SubstrateWeight; type RemoveItemsLimit = ConstU32<1000>; + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } @@ -1733,6 +1734,7 @@ impl pallet_assets::Config for Runtime { type WeightInfo = pallet_assets::weights::SubstrateWeight; type RemoveItemsLimit = ConstU32<1000>; type CallbackHandle = (); + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } diff --git a/substrate/frame/asset-conversion/src/mock.rs b/substrate/frame/asset-conversion/src/mock.rs index d8832d70488af..d79947fabf6e0 100644 --- a/substrate/frame/asset-conversion/src/mock.rs +++ b/substrate/frame/asset-conversion/src/mock.rs @@ -87,6 +87,7 @@ impl pallet_assets::Config for Test { type Extra = (); type WeightInfo = (); type CallbackHandle = (); + type DepositDestinationOnRevocation = (); pallet_assets::runtime_benchmarks_enabled! { type BenchmarkHelper = (); } @@ -112,6 +113,7 @@ impl pallet_assets::Config for Test { type Extra = (); type WeightInfo = (); type CallbackHandle = (); + type DepositDestinationOnRevocation = (); pallet_assets::runtime_benchmarks_enabled! { type BenchmarkHelper = (); } diff --git a/substrate/frame/assets-freezer/src/mock.rs b/substrate/frame/assets-freezer/src/mock.rs index 5e04dfe8e2b9c..c76e57bf190c8 100644 --- a/substrate/frame/assets-freezer/src/mock.rs +++ b/substrate/frame/assets-freezer/src/mock.rs @@ -108,6 +108,7 @@ impl pallet_assets::Config for Test { type Freezer = AssetsFreezer; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } diff --git a/substrate/frame/assets/src/benchmarking.rs b/substrate/frame/assets/src/benchmarking.rs index 8988323c19851..a7c4ae1b59478 100644 --- a/substrate/frame/assets/src/benchmarking.rs +++ b/substrate/frame/assets/src/benchmarking.rs @@ -564,5 +564,24 @@ benchmarks_instance_pallet! { assert_last_event::(Event::Transferred { asset_id: asset_id.into(), from: caller, to: target, amount }.into()); } + revoke_all_privileges { + let (asset_id, caller, _) = create_default_asset::(true); + T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); + let name = vec![0u8; T::StringLimit::get() as usize]; + let symbol = vec![0u8; T::StringLimit::get() as usize]; + + // We set some metadata so that it goes to `DepositDestinationOnRevocation` + Assets::::set_metadata( + SystemOrigin::Signed(caller.clone()).into(), + asset_id.clone(), + name.clone(), + symbol.clone(), + 12 + )?; + }: _(SystemOrigin::Signed(caller.clone()), asset_id.clone()) + verify { + assert_eq!(Asset::::get(asset_id.into()).unwrap().status, AssetStatus::LiveAndNoPrivileges); + } + impl_benchmark_test_suite!(Assets, crate::mock::new_test_ext(), crate::mock::Test) } diff --git a/substrate/frame/assets/src/functions.rs b/substrate/frame/assets/src/functions.rs index c218c4ddc952c..fa349bdc1ab58 100644 --- a/substrate/frame/assets/src/functions.rs +++ b/substrate/frame/assets/src/functions.rs @@ -223,7 +223,7 @@ impl, I: 'static> Pallet { keep_alive: bool, ) -> Result { let details = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(details.is_live(), Error::::AssetNotLive); let account = Account::::get(&id, who).ok_or(Error::::NoAccount)?; ensure!(!account.status.is_frozen(), Error::::Frozen); @@ -324,11 +324,13 @@ impl, I: 'static> Pallet { ensure!(!Account::::contains_key(&id, &who), Error::::AlreadyExists); let deposit = T::AssetAccountDeposit::get(); let mut details = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); - ensure!( - !check_depositor || &depositor == &details.admin || &depositor == &details.freezer, - Error::::NoPermission - ); + ensure!(details.is_live(), Error::::AssetNotLive); + if check_depositor { + ensure!( + details.admin() == Some(&depositor) || details.freezer() == Some(&depositor), + Error::::NoPermission + ); + } let reason = Self::new_account(&who, &mut details, Some((&depositor, deposit)))?; T::Currency::reserve(&depositor, deposit)?; Asset::::insert(&id, details); @@ -354,7 +356,7 @@ impl, I: 'static> Pallet { let mut account = Account::::get(&id, &who).ok_or(Error::::NoDeposit)?; ensure!(matches!(account.reason, Consumer | DepositHeld(..)), Error::::NoDeposit); let mut details = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(matches!(details.status, Live | Frozen), Error::::IncorrectStatus); + ensure!(details.status != Destroying, Error::::DestroyingAsset); ensure!(account.balance.is_zero() || allow_burn, Error::::WouldBurn); if let Some(deposit) = account.reason.take_deposit() { @@ -388,10 +390,13 @@ impl, I: 'static> Pallet { let (depositor, deposit) = account.reason.take_deposit_from().ok_or(Error::::NoDeposit)?; let mut details = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(details.is_live(), Error::::AssetNotLive); ensure!(!account.status.is_frozen(), Error::::Frozen); if let Some(caller) = maybe_check_caller { - ensure!(caller == depositor || caller == details.admin, Error::::NoPermission); + ensure!( + caller == depositor || Some(&caller) == details.admin(), + Error::::NoPermission + ); } ensure!(account.balance.is_zero(), Error::::WouldBurn); @@ -424,7 +429,7 @@ impl, I: 'static> Pallet { ) -> DispatchResult { Self::increase_balance(id.clone(), beneficiary, amount, |details| -> DispatchResult { if let Some(check_issuer) = maybe_check_issuer { - ensure!(check_issuer == details.issuer, Error::::NoPermission); + ensure!(details.issuer() == Some(&check_issuer), Error::::NoPermission); } debug_assert!(details.supply.checked_add(&amount).is_some(), "checked in prep; qed"); @@ -459,7 +464,7 @@ impl, I: 'static> Pallet { Self::can_increase(id.clone(), beneficiary, amount, true).into_result()?; Asset::::try_mutate(&id, |maybe_details| -> DispatchResult { let details = maybe_details.as_mut().ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(details.is_live(), Error::::AssetNotLive); check(details)?; Account::::try_mutate(&id, beneficiary, |maybe_account| -> DispatchResult { @@ -501,15 +506,12 @@ impl, I: 'static> Pallet { f: DebitFlags, ) -> Result { let d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!( - d.status == AssetStatus::Live || d.status == AssetStatus::Frozen, - Error::::IncorrectStatus - ); + ensure!(d.status != AssetStatus::Destroying, Error::::DestroyingAsset); let actual = Self::decrease_balance(id.clone(), target, amount, f, |actual, details| { // Check admin rights. if let Some(check_admin) = maybe_check_admin { - ensure!(check_admin == details.admin, Error::::NoPermission); + ensure!(details.admin() == Some(&check_admin), Error::::NoPermission); } debug_assert!(details.supply >= actual, "checked in prep; qed"); @@ -544,7 +546,7 @@ impl, I: 'static> Pallet { } let details = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(details.is_live(), Error::::AssetNotLive); let actual = Self::prep_debit(id.clone(), target, amount, f)?; let mut target_died: Option = None; @@ -619,7 +621,7 @@ impl, I: 'static> Pallet { return Ok((amount, None)) } let details = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(details.is_live(), Error::::AssetNotLive); // Figure out the debit and credit, together with side-effects. let debit = Self::prep_debit(id.clone(), source, amount, f.into())?; @@ -634,7 +636,7 @@ impl, I: 'static> Pallet { // Check admin rights. if let Some(need_admin) = maybe_need_admin { - ensure!(need_admin == details.admin, Error::::NoPermission); + ensure!(details.admin() == Some(&need_admin), Error::::NoPermission); } // Skip if source == dest @@ -722,20 +724,20 @@ impl, I: 'static> Pallet { Asset::::insert( &id, - AssetDetails { - owner: owner.clone(), - issuer: owner.clone(), - admin: owner.clone(), - freezer: owner.clone(), - supply: Zero::zero(), - deposit: Zero::zero(), + AssetDetails::new( + owner.clone(), + owner.clone(), + owner.clone(), + owner.clone(), + Zero::zero(), + Zero::zero(), min_balance, is_sufficient, - accounts: 0, - sufficients: 0, - approvals: 0, - status: AssetStatus::Live, - }, + 0, + 0, + 0, + AssetStatus::Live, + ), ); ensure!(T::CallbackHandle::created(&id, &owner).is_ok(), Error::::CallbackFailed); Self::deposit_event(Event::ForceCreated { asset_id: id, owner: owner.clone() }); @@ -751,7 +753,7 @@ impl, I: 'static> Pallet { Asset::::try_mutate_exists(id.clone(), |maybe_details| -> Result<(), DispatchError> { let details = maybe_details.as_mut().ok_or(Error::::Unknown)?; if let Some(check_owner) = maybe_check_owner { - ensure!(details.owner == check_owner, Error::::NoPermission); + ensure!(details.owner() == Some(&check_owner), Error::::NoPermission); } details.status = AssetStatus::Destroying; @@ -858,10 +860,9 @@ impl, I: 'static> Pallet { ensure!(T::CallbackHandle::destroyed(&id).is_ok(), Error::::CallbackFailed); let metadata = Metadata::::take(&id); - T::Currency::unreserve( - &details.owner, - details.deposit.saturating_add(metadata.deposit), - ); + if let Some(owner) = details.owner() { + T::Currency::unreserve(owner, details.deposit.saturating_add(metadata.deposit)); + } Self::deposit_event(Event::Destroyed { asset_id: id }); Ok(()) @@ -879,7 +880,7 @@ impl, I: 'static> Pallet { amount: T::Balance, ) -> DispatchResult { let mut d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(d.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(d.is_live(), Error::::AssetNotLive); Approvals::::try_mutate( (id.clone(), &owner, &delegate), |maybe_approved| -> DispatchResult { @@ -930,7 +931,7 @@ impl, I: 'static> Pallet { let mut owner_died: Option = None; let d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(d.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(d.is_live(), Error::::AssetNotLive); Approvals::::try_mutate_exists( (id.clone(), &owner, delegate), @@ -979,8 +980,8 @@ impl, I: 'static> Pallet { symbol.clone().try_into().map_err(|_| Error::::BadMetadata)?; let d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(d.status == AssetStatus::Live, Error::::AssetNotLive); - ensure!(from == &d.owner, Error::::NoPermission); + ensure!(d.is_live(), Error::::AssetNotLive); + ensure!(d.owner() == Some(&from), Error::::NoPermission); Metadata::::try_mutate_exists(id.clone(), |metadata| { ensure!(metadata.as_ref().map_or(true, |m| !m.is_frozen), Error::::NoPermission); @@ -1031,6 +1032,10 @@ impl, I: 'static> Pallet { /// Reset the team for the asset with the given `id`. /// + /// This forces the reset of the team. If the team had revoked its pivileges, the new team will + /// still get the privileges. + /// If the asset status is `LiveAndNoPrivileges` then it is changed to `Live`. + /// /// ### Parameters /// - `id`: The identifier of the asset for which the team is being reset. /// - `owner`: The new `owner` account for the asset. @@ -1045,11 +1050,24 @@ impl, I: 'static> Pallet { freezer: T::AccountId, ) -> DispatchResult { let mut d = Asset::::get(&id).ok_or(Error::::Unknown)?; - d.owner = owner; - d.admin = admin; - d.issuer = issuer; - d.freezer = freezer; + if d.status == AssetStatus::LiveAndNoPrivileges { + d.status = AssetStatus::Live + } + d.try_set_team(&owner, &issuer, &admin, &freezer).map_err(|e| match e { + SetTeamError::AssetStatusLiveAndNoPrivileges => { + log::error!( + target: LOG_TARGET, + "Operation failed because status is `LiveAndNoPrivileges`, but it was set \ + to `Live` before; qed" + ); + Error::::InternalError + }, + })?; Asset::::insert(&id, d); + + Self::deposit_event(Event::TeamChanged { asset_id: id.clone(), issuer, admin, freezer }); + Self::deposit_event(Event::OwnerChanged { asset_id: id, owner }); + Ok(()) } } diff --git a/substrate/frame/assets/src/impl_fungibles.rs b/substrate/frame/assets/src/impl_fungibles.rs index 578fa08c4e63e..f368c212d0110 100644 --- a/substrate/frame/assets/src/impl_fungibles.rs +++ b/substrate/frame/assets/src/impl_fungibles.rs @@ -299,19 +299,19 @@ impl, I: 'static> fungibles::roles::Inspect<::Ac for Pallet { fn owner(asset: T::AssetId) -> Option<::AccountId> { - Asset::::get(asset).map(|x| x.owner) + Asset::::get(asset).and_then(|x| x.owner().cloned()) } fn issuer(asset: T::AssetId) -> Option<::AccountId> { - Asset::::get(asset).map(|x| x.issuer) + Asset::::get(asset).and_then(|x| x.issuer().cloned()) } fn admin(asset: T::AssetId) -> Option<::AccountId> { - Asset::::get(asset).map(|x| x.admin) + Asset::::get(asset).and_then(|x| x.admin().cloned()) } fn freezer(asset: T::AssetId) -> Option<::AccountId> { - Asset::::get(asset).map(|x| x.freezer) + Asset::::get(asset).and_then(|x| x.freezer().cloned()) } } diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index e909932bfc820..486e2fa5b5189 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -79,6 +79,7 @@ //! * Update an asset class's total supply. //! * Allow administrative activities by specially privileged accounts including freezing account //! balances and minting/burning assets. +//! * Allow revocation of all administrative privileges. //! //! ## Interface //! @@ -120,6 +121,8 @@ //! called by the asset class's Freezer or Admin. //! * `block`: Disallows further `transfer`s to and from an account; called by the asset class's //! Freezer. +//! * `revoke_all_privileges`: Revoke owner, issuer, admin, and freezer privileges for the asset +//! class. //! //! Please refer to the [`Call`] enum and its associated variants for documentation on each //! function. @@ -181,7 +184,7 @@ use frame_support::{ dispatch::DispatchResult, ensure, pallet_prelude::DispatchResultWithPostInfo, - storage::KeyPrefixIterator, + storage::{with_storage_layer, KeyPrefixIterator}, traits::{ tokens::{ fungibles, DepositConsequence, Fortitude, @@ -189,15 +192,20 @@ use frame_support::{ WithdrawConsequence, }, BalanceStatus::Reserved, - Currency, EnsureOriginWithArg, Incrementable, ReservableCurrency, StoredMap, + Currency, EnsureOriginWithArg, ExistenceRequirement, Imbalance, Incrementable, + OnUnbalanced, ReservableCurrency, StoredMap, WithdrawReasons, }, }; use frame_system::Config as SystemConfig; +use sp_runtime::traits::TrailingZeroInput; pub use pallet::*; pub use weights::WeightInfo; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; +type NegativeImbalanceOf = <>::Currency as Currency< + ::AccountId, +>>::NegativeImbalance; const LOG_TARGET: &str = "runtime::assets"; /// Trait with callbacks that are executed after successful asset creation or destruction. @@ -255,7 +263,7 @@ pub mod pallet { use frame_system::pallet_prelude::*; /// The in-code storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] @@ -297,6 +305,7 @@ pub mod pallet { type StringLimit = ConstU32<50>; type Extra = (); type CallbackHandle = (); + type DepositDestinationOnRevocation = (); type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); @@ -404,6 +413,11 @@ pub mod pallet { /// used to set up auto-incrementing asset IDs for this collection. type CallbackHandle: AssetsCallback; + /// Destination of deposit of revoked asset owner. + /// This is used when the owner is revoked, its deposit is transferred to this destination. + #[pallet::no_default_bounds] + type DepositDestinationOnRevocation: OnUnbalanced>; + /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -494,20 +508,20 @@ pub mod pallet { assert!(!min_balance.is_zero(), "Min balance should not be zero"); Asset::::insert( id, - AssetDetails { - owner: owner.clone(), - issuer: owner.clone(), - admin: owner.clone(), - freezer: owner.clone(), - supply: Zero::zero(), - deposit: Zero::zero(), - min_balance: *min_balance, - is_sufficient: *is_sufficient, - accounts: 0, - sufficients: 0, - approvals: 0, - status: AssetStatus::Live, - }, + AssetDetails::new( + owner.clone(), + owner.clone(), + owner.clone(), + owner.clone(), + Zero::zero(), + Zero::zero(), + *min_balance, + *is_sufficient, + 0, + 0, + 0, + AssetStatus::Live, + ), ); } @@ -639,6 +653,8 @@ pub mod pallet { Deposited { asset_id: T::AssetId, who: T::AccountId, amount: T::Balance }, /// Some assets were withdrawn from the account (e.g. for transaction fees). Withdrawn { asset_id: T::AssetId, who: T::AccountId, amount: T::Balance }, + /// The owner is revoked. + OwnerAndTeamRevoked { asset_id: T::AssetId }, } #[pallet::error] @@ -688,6 +704,12 @@ pub mod pallet { CallbackFailed, /// The asset ID must be equal to the [`NextAssetId`]. BadAssetId, + /// Operation fails because the asset status is `Destroying`. + DestroyingAsset, + /// Operation fails because the asset status is `LiveAndNoPrivileges`. + LiveAndNoPrivileges, + /// Internal error, an operation unexpectedly failed. + InternalError, } #[pallet::call(weight(>::WeightInfo))] @@ -734,20 +756,20 @@ pub mod pallet { Asset::::insert( id.clone(), - AssetDetails { - owner: owner.clone(), - issuer: admin.clone(), - admin: admin.clone(), - freezer: admin.clone(), - supply: Zero::zero(), + AssetDetails::new( + owner.clone(), + admin.clone(), + admin.clone(), + admin.clone(), + Zero::zero(), deposit, min_balance, - is_sufficient: false, - accounts: 0, - sufficients: 0, - approvals: 0, - status: AssetStatus::Live, - }, + false, + 0, + 0, + 0, + AssetStatus::Live, + ), ); ensure!(T::CallbackHandle::created(&id, &owner).is_ok(), Error::::CallbackFailed); Self::deposit_event(Event::Created { @@ -798,6 +820,8 @@ pub mod pallet { /// destruction of an asset class. /// /// The origin must conform to `ForceOrigin` or must be `Signed` by the asset's `owner`. + /// If the origin is `Signed` by `owner` then the asset status must not be + /// `LiveAndNoPrivileges`. /// /// - `id`: The identifier of the asset to be destroyed. This must identify an existing /// asset. @@ -878,7 +902,8 @@ pub mod pallet { /// Mint assets of a particular class. /// - /// The origin must be Signed and the sender must be the Issuer of the asset `id`. + /// The origin must be Signed and the sender must be the Issuer of the asset `id` and the + /// asset status must not be `LiveAndNoPrivileges`. /// /// - `id`: The identifier of the asset to have some amount minted. /// - `beneficiary`: The account to be credited with the minted assets. @@ -904,7 +929,8 @@ pub mod pallet { /// Reduce the balance of `who` by as much as possible up to `amount` assets of `id`. /// - /// Origin must be Signed and the sender should be the Manager of the asset `id`. + /// Origin must be Signed and the sender should be the Admin of the asset `id` and the + /// asset status must not be `LiveAndNoPrivileges`. /// /// Bails with `NoAccount` if the `who` is already dead. /// @@ -1001,7 +1027,8 @@ pub mod pallet { /// Move some assets from one account to another. /// - /// Origin must be Signed and the sender should be the Admin of the asset `id`. + /// Origin must be Signed and the sender should be the Admin of the asset `id` and the + /// asset status must not be `LiveAndNoPrivileges`. /// /// - `id`: The identifier of the asset to have some amount transferred. /// - `source`: The account to be debited. @@ -1057,11 +1084,8 @@ pub mod pallet { let id: T::AssetId = id.into(); let d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!( - d.status == AssetStatus::Live || d.status == AssetStatus::Frozen, - Error::::IncorrectStatus - ); - ensure!(origin == d.freezer, Error::::NoPermission); + ensure!(d.status != AssetStatus::Destroying, Error::::DestroyingAsset); + ensure!(d.freezer() == Some(&origin), Error::::NoPermission); let who = T::Lookup::lookup(who)?; Account::::try_mutate(&id, &who, |maybe_account| -> DispatchResult { @@ -1094,11 +1118,8 @@ pub mod pallet { let id: T::AssetId = id.into(); let details = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!( - details.status == AssetStatus::Live || details.status == AssetStatus::Frozen, - Error::::IncorrectStatus - ); - ensure!(origin == details.admin, Error::::NoPermission); + ensure!(details.status != AssetStatus::Destroying, Error::::DestroyingAsset); + ensure!(details.admin() == Some(&origin), Error::::NoPermission); let who = T::Lookup::lookup(who)?; Account::::try_mutate(&id, &who, |maybe_account| -> DispatchResult { @@ -1127,8 +1148,8 @@ pub mod pallet { Asset::::try_mutate(id.clone(), |maybe_details| { let d = maybe_details.as_mut().ok_or(Error::::Unknown)?; - ensure!(d.status == AssetStatus::Live, Error::::AssetNotLive); - ensure!(origin == d.freezer, Error::::NoPermission); + ensure!(d.is_live(), Error::::AssetNotLive); + ensure!(d.freezer() == Some(&origin), Error::::NoPermission); d.status = AssetStatus::Frozen; @@ -1153,7 +1174,7 @@ pub mod pallet { Asset::::try_mutate(id.clone(), |maybe_details| { let d = maybe_details.as_mut().ok_or(Error::::Unknown)?; - ensure!(origin == d.admin, Error::::NoPermission); + ensure!(d.admin() == Some(&origin), Error::::NoPermission); ensure!(d.status == AssetStatus::Frozen, Error::::NotFrozen); d.status = AssetStatus::Live; @@ -1185,9 +1206,10 @@ pub mod pallet { Asset::::try_mutate(id.clone(), |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); - ensure!(origin == details.owner, Error::::NoPermission); - if details.owner == owner { + ensure!(details.is_live(), Error::::AssetNotLive); + let old_owner = details.owner().ok_or(Error::::NoPermission)?; + ensure!(old_owner == &origin, Error::::NoPermission); + if old_owner == &owner { return Ok(()) } @@ -1195,9 +1217,18 @@ pub mod pallet { let deposit = details.deposit + metadata_deposit; // Move the deposit to the new owner. - T::Currency::repatriate_reserved(&details.owner, &owner, deposit, Reserved)?; - - details.owner = owner.clone(); + T::Currency::repatriate_reserved(&old_owner, &owner, deposit, Reserved)?; + + details.try_set_owner(&owner).map_err(|e| match e { + SetTeamError::AssetStatusLiveAndNoPrivileges => { + log::error!( + target: LOG_TARGET, + "Operation failed because status is `LiveAndNoPrivileges`, but \ + there is an owner so status cannot be `LiveAndNoPrivileges`; qed" + ); + Error::::InternalError + }, + })?; Self::deposit_event(Event::OwnerChanged { asset_id: id, owner }); Ok(()) @@ -1232,12 +1263,18 @@ pub mod pallet { Asset::::try_mutate(id.clone(), |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::Unknown)?; - ensure!(details.status == AssetStatus::Live, Error::::AssetNotLive); - ensure!(origin == details.owner, Error::::NoPermission); - - details.issuer = issuer.clone(); - details.admin = admin.clone(); - details.freezer = freezer.clone(); + ensure!(details.is_live(), Error::::AssetNotLive); + let owner = details.owner().ok_or(Error::::NoPermission)?; + ensure!(owner == &origin, Error::::NoPermission); + + match details.try_set_team(&owner.clone(), &issuer, &admin, &freezer) { + Ok(()) => (), + Err(SetTeamError::AssetStatusLiveAndNoPrivileges) => log::error!( + target: LOG_TARGET, + "Operation failed because status is `LiveAndNoPrivileges`, but there is + an owner so asset cannot be without privileges; qed" + ), + } Self::deposit_event(Event::TeamChanged { asset_id: id, issuer, admin, freezer }); Ok(()) @@ -1291,12 +1328,13 @@ pub mod pallet { let id: T::AssetId = id.into(); let d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(d.status == AssetStatus::Live, Error::::AssetNotLive); - ensure!(origin == d.owner, Error::::NoPermission); + ensure!(d.is_live(), Error::::AssetNotLive); + let owner = d.owner().ok_or_else(|| Error::::NoPermission)?; + ensure!(owner == &origin, Error::::NoPermission); Metadata::::try_mutate_exists(id.clone(), |metadata| { let deposit = metadata.take().ok_or(Error::::Unknown)?.deposit; - T::Currency::unreserve(&d.owner, deposit); + T::Currency::unreserve(&owner, deposit); Self::deposit_event(Event::MetadataCleared { asset_id: id }); Ok(()) }) @@ -1379,7 +1417,9 @@ pub mod pallet { let d = Asset::::get(&id).ok_or(Error::::Unknown)?; Metadata::::try_mutate_exists(id.clone(), |metadata| { let deposit = metadata.take().ok_or(Error::::Unknown)?.deposit; - T::Currency::unreserve(&d.owner, deposit); + if let Some(owner) = d.owner() { + T::Currency::unreserve(&owner, deposit); + } Self::deposit_event(Event::MetadataCleared { asset_id: id }); Ok(()) }) @@ -1425,10 +1465,6 @@ pub mod pallet { Asset::::try_mutate(id.clone(), |maybe_asset| { let mut asset = maybe_asset.take().ok_or(Error::::Unknown)?; ensure!(asset.status != AssetStatus::Destroying, Error::::AssetNotLive); - asset.owner = T::Lookup::lookup(owner)?; - asset.issuer = T::Lookup::lookup(issuer)?; - asset.admin = T::Lookup::lookup(admin)?; - asset.freezer = T::Lookup::lookup(freezer)?; asset.min_balance = min_balance; asset.is_sufficient = is_sufficient; if is_frozen { @@ -1436,6 +1472,24 @@ pub mod pallet { } else { asset.status = AssetStatus::Live; } + asset + .try_set_team( + &T::Lookup::lookup(owner)?, + &T::Lookup::lookup(issuer)?, + &T::Lookup::lookup(admin)?, + &T::Lookup::lookup(freezer)?, + ) + .map_err(|e| match e { + SetTeamError::AssetStatusLiveAndNoPrivileges => { + log::error!( + target: LOG_TARGET, + "Operation failed because status is `LiveAndNoPrivileges`, but it \ + was set to `Live` or `Frozen` before; qed" + ); + Error::::InternalError + }, + })?; + *maybe_asset = Some(asset); Self::deposit_event(Event::AssetStatusChanged { asset_id: id }); @@ -1499,7 +1553,7 @@ pub mod pallet { let delegate = T::Lookup::lookup(delegate)?; let id: T::AssetId = id.into(); let mut d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(d.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(d.is_live(), Error::::AssetNotLive); let approval = Approvals::::take((id.clone(), &owner, &delegate)) .ok_or(Error::::Unknown)?; @@ -1534,12 +1588,12 @@ pub mod pallet { ) -> DispatchResult { let id: T::AssetId = id.into(); let mut d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(d.status == AssetStatus::Live, Error::::AssetNotLive); + ensure!(d.is_live(), Error::::AssetNotLive); T::ForceOrigin::try_origin(origin) .map(|_| ()) .or_else(|origin| -> DispatchResult { let origin = ensure_signed(origin)?; - ensure!(origin == d.admin, Error::::NoPermission); + ensure!(d.admin() == Some(&origin), Error::::NoPermission); Ok(()) })?; @@ -1649,7 +1703,7 @@ pub mod pallet { let id: T::AssetId = id.into(); let mut details = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!(origin == details.owner, Error::::NoPermission); + ensure!(details.owner() == Some(&origin), Error::::NoPermission); let old_min_balance = details.min_balance; // If the asset is marked as sufficient it won't be allowed to @@ -1739,11 +1793,8 @@ pub mod pallet { let id: T::AssetId = id.into(); let d = Asset::::get(&id).ok_or(Error::::Unknown)?; - ensure!( - d.status == AssetStatus::Live || d.status == AssetStatus::Frozen, - Error::::IncorrectStatus - ); - ensure!(origin == d.freezer, Error::::NoPermission); + ensure!(d.status != AssetStatus::Destroying, Error::::DestroyingAsset); + ensure!(d.freezer() == Some(&origin), Error::::NoPermission); let who = T::Lookup::lookup(who)?; Account::::try_mutate(&id, &who, |maybe_account| -> DispatchResult { @@ -1798,6 +1849,138 @@ pub mod pallet { )?; Ok(()) } + + /// Revoke irreversibly Owner, Issuer, Admin, and Freezer privileges of the asset. Freeze + /// the metadata. + /// + /// Warning: This action is irreversible. Reinstating privileged roles would require an + /// action from `ForceOrigin`. + /// + /// Origin must be either Signed and the sender should be the Owner of the asset `id` or + /// `ForceOrigin`. + /// + /// If origin is the owner: The deposit of the asset details and metadata will be + /// unreserved then withdrawn and sent to `DepositDestinationOnRevocation`. If no metadata + /// was set then the new deposit for the new metadata will be withdrawn from the owner. + /// + /// If origin is `ForceOrigin`: The deposit of owner is unreserved. + /// + /// Asset must be in `Live` status. + /// + /// - `id`: The identifier of the asset. + /// + /// Emits `OwnerAndTeamRevoked` and `MetadataSet`. + /// + /// Weight: `O(1)` + #[pallet::call_index(33)] + pub fn revoke_all_privileges( + origin: OriginFor, + id: T::AssetIdParameter, + ) -> DispatchResult { + let maybe_owner_origin = match T::ForceOrigin::try_origin(origin) { + Ok(_) => None, + Err(origin) => Some(ensure_signed(origin)?), + }; + let id: T::AssetId = id.into(); + let mut asset = Asset::::get(&id).ok_or(Error::::Unknown)?; + + if let Some(owner) = maybe_owner_origin.as_ref() { + ensure!(asset.owner() == Some(&owner), Error::::NoPermission); + } + ensure!(asset.status == AssetStatus::Live, Error::::IncorrectStatus); + + let Some(owner) = asset.owner() else { + log::error!( + target: LOG_TARGET, + "asset is ensured to be `Live` thus asset has an owner; qed" + ); + return Err(Error::::IncorrectStatus.into()); + }; + + // Some randomly generated account to be used for the team. Not necessary but safer. + let pure_account = { + let (height, ext_index) = ( + frame_system::Pallet::::block_number(), + frame_system::Pallet::::extrinsic_index().unwrap_or_default(), + ); + + let entropy = (b"modlasts/assets_", owner, height, ext_index) + .using_encoded(sp_core::blake2_256); + + T::AccountId::decode(&mut TrailingZeroInput::new(entropy.as_ref())).map_err( + |_| { + log::error!( + target: LOG_TARGET, + "infinite length input; no invalid inputs for type; qed" + ); + Error::::InternalError + }, + )? + }; + + let old_metadata = Metadata::::get(&id); + + let deposit_amount = asset.deposit.saturating_add(old_metadata.deposit); + + let fee_imbalance = if maybe_owner_origin.is_some() { + // Call is from owner: pay for deposits. + + let new_metadata_deposit = + Self::calc_metadata_deposit(&old_metadata.name, &old_metadata.symbol); + + // NOTE: if new deposit is less than old deposit then the excess is not refunded. + let metadata_deposit_diff = + new_metadata_deposit.saturating_sub(old_metadata.deposit); + + with_storage_layer::<_, DispatchError, _>(|| { + T::Currency::unreserve(&owner, deposit_amount); + let imbalance = T::Currency::withdraw( + &owner, + deposit_amount.saturating_add(metadata_deposit_diff), + WithdrawReasons::FEE, + ExistenceRequirement::KeepAlive, + )?; + Ok(imbalance) + })? + } else { + // Call is not from owner: unreserve owner's deposit. + + T::Currency::unreserve(owner, deposit_amount); + Imbalance::zero() + }; + + let new_metadata = AssetMetadata { + deposit: Zero::zero(), + name: old_metadata.name, + symbol: old_metadata.symbol, + decimals: old_metadata.decimals, + is_frozen: true, + }; + Metadata::::insert(&id, &new_metadata); + + asset.set_team_or_historical_team( + &pure_account, + &pure_account, + &pure_account, + &pure_account, + ); + asset.deposit = Zero::zero(); + asset.status = AssetStatus::LiveAndNoPrivileges; + Asset::::insert(&id, &asset); + + Self::deposit_event(Event::OwnerAndTeamRevoked { asset_id: id.clone() }); + Self::deposit_event(Event::MetadataSet { + asset_id: id, + name: new_metadata.name.into(), + symbol: new_metadata.symbol.into(), + decimals: new_metadata.decimals, + is_frozen: new_metadata.is_frozen, + }); + + T::DepositDestinationOnRevocation::on_unbalanced(fee_imbalance); + + Ok(()) + } } /// Implements [`AccountTouch`] trait. diff --git a/substrate/frame/assets/src/migration.rs b/substrate/frame/assets/src/migration.rs index 9096f25fb791f..d945a083fdbfe 100644 --- a/substrate/frame/assets/src/migration.rs +++ b/substrate/frame/assets/src/migration.rs @@ -67,24 +67,26 @@ pub mod v1 { pub is_frozen: bool, } - impl OldAssetDetails { + impl + OldAssetDetails + { fn migrate_to_v1(self) -> AssetDetails { let status = if self.is_frozen { AssetStatus::Frozen } else { AssetStatus::Live }; - AssetDetails { - owner: self.owner, - issuer: self.issuer, - admin: self.admin, - freezer: self.freezer, - supply: self.supply, - deposit: self.deposit, - min_balance: self.min_balance, - is_sufficient: self.is_sufficient, - accounts: self.accounts, - sufficients: self.sufficients, - approvals: self.approvals, + AssetDetails::new( + self.owner, + self.issuer, + self.admin, + self.freezer, + self.supply, + self.deposit, + self.min_balance, + self.is_sufficient, + self.accounts, + self.sufficients, + self.approvals, status, - } + ) } } @@ -160,3 +162,52 @@ pub mod v1 { } } } + +pub mod v2 { + use frame_support::{ + migrations::VersionedMigration, traits::UncheckedOnRuntimeUpgrade, weights::Weight, + }; + + use super::*; + + /// Run migration from v1 to v2: basically writes version 2 into storage. + pub type MigrateV1ToV2 = VersionedMigration< + 1u16, + 2u16, + UncheckedMigrationV1toV2, + crate::Pallet, + ::DbWeight, + >; + + /// Inner implementation of the migration without version check. + /// + /// Warning: This doesn't write the version 2 into storage. Use `MigrateV1ToV2` for that. + pub struct UncheckedMigrationV1toV2(core::marker::PhantomData<(T, I)>); + + impl, I: 'static> UncheckedOnRuntimeUpgrade for UncheckedMigrationV1toV2 { + fn on_runtime_upgrade() -> Weight { + Weight::zero() + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, TryRuntimeError> { + Ok(alloc::vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_: Vec) -> Result<(), TryRuntimeError> { + use frame_support::traits::GetStorageVersion; + + let in_code_version = Pallet::::in_code_storage_version(); + let on_chain_version = Pallet::::on_chain_storage_version(); + + frame_support::ensure!(on_chain_version >= 2, "must_upgrade"); + ensure!( + in_code_version == on_chain_version, + "after migration, the in_code_version and on_chain_version should be the same" + ); + + Ok(()) + } + } +} diff --git a/substrate/frame/assets/src/mock.rs b/substrate/frame/assets/src/mock.rs index 2c160840e1478..2044513b8ed3f 100644 --- a/substrate/frame/assets/src/mock.rs +++ b/substrate/frame/assets/src/mock.rs @@ -97,6 +97,12 @@ impl AssetsCallbackHandle { } } +pub struct To123; +impl OnUnbalanced> for To123 { + fn on_nonzero_unbalanced(amount: NegativeImbalanceOf) { + Balances::resolve_creating(&123, amount); + } +} #[derive_impl(crate::config_preludes::TestDefaultConfig)] impl Config for Test { type Currency = Balances; @@ -104,6 +110,7 @@ impl Config for Test { type ForceOrigin = frame_system::EnsureRoot; type Freezer = TestFreezer; type CallbackHandle = (AssetsCallbackHandle, AutoIncAssetId); + type DepositDestinationOnRevocation = To123; } use std::collections::HashMap; diff --git a/substrate/frame/assets/src/tests.rs b/substrate/frame/assets/src/tests.rs index af605c5a3c640..0235454cf1700 100644 --- a/substrate/frame/assets/src/tests.rs +++ b/substrate/frame/assets/src/tests.rs @@ -19,6 +19,7 @@ use super::*; use crate::{mock::*, Error}; +use codec::{Decode, Encode}; use frame_support::{ assert_noop, assert_ok, dispatch::GetDispatchInfo, @@ -27,6 +28,7 @@ use frame_support::{ tokens::{Preservation::Protect, Provenance}, Currency, }, + BoundedVec, }; use pallet_balances::Error as BalancesError; use sp_io::storage; @@ -1921,3 +1923,363 @@ fn asset_id_cannot_be_reused() { assert!(Asset::::contains_key(7)); }); } + +#[test] +fn revoke_with_not_owner_or_already_revoked() { + new_test_ext().execute_with(|| { + let owner = 1; + let owner_origin = RuntimeOrigin::signed(owner); + Balances::make_free_balance_be(&1, 100); + + assert_ok!(Assets::create(owner_origin.clone(), 0, owner, 1)); + + assert_noop!( + Assets::revoke_all_privileges(RuntimeOrigin::signed(owner + 1), 0), + Error::::NoPermission + ); + assert_ok!(Assets::revoke_all_privileges(owner_origin.clone(), 0)); + + assert_noop!( + Assets::revoke_all_privileges(RuntimeOrigin::signed(owner + 1), 0), + Error::::NoPermission + ); + }); +} + +#[test] +fn revoke_with_owner_no_metadata() { + new_test_ext().execute_with(|| { + let owner = 1; + let owner_origin = RuntimeOrigin::signed(owner); + Balances::make_free_balance_be(&1, 100); + + assert_ok!(Assets::create(owner_origin.clone(), 0, owner, 1)); + + assert_eq!(Balances::free_balance(&owner), 99); + assert_eq!(Balances::reserved_balance(&owner), 1); + + assert_ok!(Assets::revoke_all_privileges(owner_origin.clone(), 0)); + + assert_eq!(Balances::free_balance(&123), 2); // by DepositDestinationOnRevocation hook + assert_eq!(Balances::free_balance(&owner), 98); + assert_eq!(Balances::reserved_balance(&owner), 0); + assert_eq!( + Metadata::::get(0), + AssetMetadata { + deposit: 0, + name: BoundedVec::new(), + symbol: BoundedVec::new(), + decimals: 0, + is_frozen: true, + } + ); + assert_eq!(Asset::::get(0).unwrap().deposit, 0); + assert_eq!(Asset::::get(0).unwrap().status, AssetStatus::LiveAndNoPrivileges); + }); +} + +#[test] +fn revoke_with_owner_some_metadata() { + new_test_ext().execute_with(|| { + let owner = 1; + let owner_origin = RuntimeOrigin::signed(owner); + Balances::make_free_balance_be(&1, 100); + + assert_ok!(Assets::create(owner_origin.clone(), 0, owner, 1)); + + assert_eq!(Balances::free_balance(&owner), 99); + assert_eq!(Balances::reserved_balance(&owner), 1); + + assert_ok!(Assets::set_metadata(owner_origin.clone(), 0, vec![1u8; 10], vec![2u8; 10], 12)); + + assert_ok!(Assets::revoke_all_privileges(owner_origin.clone(), 0)); + + assert_eq!(Balances::free_balance(&123), 22); // by DepositDestinationOnRevocation hook + assert_eq!(Balances::free_balance(&owner), 78); + assert_eq!(Balances::reserved_balance(&owner), 0); + assert_eq!( + Metadata::::get(0), + AssetMetadata { + deposit: 0, + name: vec![1u8; 10].try_into().unwrap(), + symbol: vec![2u8; 10].try_into().unwrap(), + decimals: 12, + is_frozen: true, + } + ); + assert_eq!(Asset::::get(0).unwrap().deposit, 0); + assert_eq!(Asset::::get(0).unwrap().status, AssetStatus::LiveAndNoPrivileges); + }); +} + +#[test] +fn revoke_with_owner_fail_withdraw_metadata() { + new_test_ext().execute_with(|| { + let owner = 1; + let owner_origin = RuntimeOrigin::signed(owner); + Balances::make_free_balance_be(&1, 2); + + assert_ok!(Assets::create(owner_origin.clone(), 0, owner, 1)); + + assert_eq!(Balances::free_balance(&owner), 1); + assert_eq!(Balances::reserved_balance(&owner), 1); + + assert_noop!( + Assets::revoke_all_privileges(owner_origin.clone(), 0), + BalancesError::::Expendability + ); + }); +} + +#[test] +fn revoke_force_origin() { + new_test_ext().execute_with(|| { + let owner = 1; + let owner_origin = RuntimeOrigin::signed(owner); + Balances::make_free_balance_be(&1, 100); + + assert_ok!(Assets::create(owner_origin.clone(), 0, owner, 1)); + + assert_eq!(Balances::free_balance(&owner), 99); + assert_eq!(Balances::reserved_balance(&owner), 1); + + assert_ok!(Assets::set_metadata(owner_origin.clone(), 0, vec![1u8; 10], vec![2u8; 10], 12)); + + assert_ok!(Assets::revoke_all_privileges(RuntimeOrigin::root(), 0)); + + assert_eq!(Balances::free_balance(&123), 0); + assert_eq!(Balances::free_balance(&owner), 100); + assert_eq!(Balances::reserved_balance(&owner), 0); + assert_eq!( + Metadata::::get(0), + AssetMetadata { + deposit: 0, + name: vec![1u8; 10].try_into().unwrap(), + symbol: vec![2u8; 10].try_into().unwrap(), + decimals: 12, + is_frozen: true, + } + ); + assert_eq!(Asset::::get(0).unwrap().deposit, 0); + assert_eq!(Asset::::get(0).unwrap().status, AssetStatus::LiveAndNoPrivileges); + }); +} + +#[test] +fn live_and_lock_should_have_no_privilege() { + new_test_ext().execute_with(|| { + let owner = 1; + let owner_origin = RuntimeOrigin::signed(owner); + Balances::make_free_balance_be(&1, 100); + Balances::make_free_balance_be(&2, 100); + + assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, owner, false, 1)); + assert_ok!(Assets::touch_other(owner_origin.clone(), 0, 2)); + assert_ok!(Assets::mint(owner_origin.clone(), 0, 2, 100)); + + assert_ok!(Assets::set_team(owner_origin.clone(), 0, 2, 2, 2)); + assert_ok!(Assets::touch_other(RuntimeOrigin::signed(2), 0, 3)); + assert_ok!(Assets::set_team(owner_origin.clone(), 0, owner, owner, owner)); + assert_ok!(Assets::mint(owner_origin.clone(), 0, 3, 100)); + + assert_ok!(Assets::revoke_all_privileges(RuntimeOrigin::root(), 0)); + + assert_eq!(Asset::::get(0).unwrap().status, AssetStatus::LiveAndNoPrivileges); + + assert_noop!(Assets::start_destroy(owner_origin.clone(), 0), Error::::NoPermission); + assert_noop!( + Assets::destroy_accounts(owner_origin.clone(), 0), + Error::::IncorrectStatus + ); + assert_noop!( + Assets::destroy_approvals(owner_origin.clone(), 0), + Error::::IncorrectStatus + ); + assert_noop!( + Assets::finish_destroy(owner_origin.clone(), 0), + Error::::IncorrectStatus + ); + assert_noop!(Assets::mint(owner_origin.clone(), 0, 2, 1), Error::::NoPermission); + assert_noop!(Assets::burn(owner_origin.clone(), 0, 2, 1), Error::::NoPermission); + assert_noop!( + Assets::force_transfer(owner_origin.clone(), 0, 2, 1, 1), + Error::::NoPermission + ); + assert_noop!(Assets::freeze(owner_origin.clone(), 0, 2), Error::::NoPermission); + assert_noop!(Assets::thaw(owner_origin.clone(), 0, 2), Error::::NoPermission); + assert_noop!(Assets::freeze_asset(owner_origin.clone(), 0), Error::::NoPermission); + assert_noop!(Assets::thaw_asset(owner_origin.clone(), 0), Error::::NoPermission); + assert_noop!( + Assets::transfer_ownership(owner_origin.clone(), 0, 2), + Error::::NoPermission + ); + assert_noop!( + Assets::set_team(owner_origin.clone(), 0, 2, 2, 2), + Error::::NoPermission + ); + assert_noop!( + Assets::set_metadata(owner_origin.clone(), 0, vec![], vec![], 2), + Error::::NoPermission + ); + assert_noop!(Assets::clear_metadata(owner_origin.clone(), 0), Error::::NoPermission); + assert_noop!( + Assets::force_cancel_approval(owner_origin.clone(), 0, 2, 3), + Error::::NoPermission + ); + assert_noop!( + Assets::set_min_balance(owner_origin.clone(), 0, 2), + Error::::NoPermission + ); + assert_noop!(Assets::touch_other(owner_origin.clone(), 0, 4), Error::::NoPermission); + assert_noop!(Assets::refund_other(owner_origin.clone(), 0, 3), Error::::NoPermission); + assert_noop!(Assets::block(owner_origin.clone(), 0, 2), Error::::NoPermission); + assert_noop!( + Assets::revoke_all_privileges(owner_origin.clone(), 0), + Error::::NoPermission + ); + }); +} + +#[test] +fn live_and_lock_should_work_like_live() { + use frame_support::traits::{ + fungibles::{roles::ResetTeam, Mutate}, + tokens::{Fortitude, Precision, Preservation}, + }; + + new_test_ext().execute_with(|| { + let owner = 1; + let owner_origin = RuntimeOrigin::signed(owner); + Balances::make_free_balance_be(&1, 100); + Balances::make_free_balance_be(&2, 100); + Balances::make_free_balance_be(&3, 100); + Balances::make_free_balance_be(&4, 100); + Balances::make_free_balance_be(&5, 100); + Balances::make_free_balance_be(&6, 100); + + assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, owner, false, 1)); + assert_ok!(Assets::touch_other(owner_origin.clone(), 0, 444)); + assert_ok!(Assets::mint(owner_origin.clone(), 0, 2, 50)); + assert_ok!(Assets::mint(owner_origin.clone(), 0, 3, 50)); + + assert_ok!(Assets::revoke_all_privileges(RuntimeOrigin::root(), 0)); + + assert_eq!(Asset::::get(0).unwrap().status, AssetStatus::LiveAndNoPrivileges); + + assert_ok!(Assets::transfer(RuntimeOrigin::signed(2), 0, 3, 1)); + assert_ok!(Assets::transfer_keep_alive(RuntimeOrigin::signed(2), 0, 3, 1)); + assert_ok!(Assets::force_clear_metadata(RuntimeOrigin::root(), 0)); + assert_eq!(Metadata::::get(0).is_frozen, false); + assert_ok!(Assets::force_set_metadata(RuntimeOrigin::root(), 0, vec![], vec![], 0, true)); + assert_eq!(Metadata::::get(0).is_frozen, true); + assert_ok!(Assets::force_asset_status( + RuntimeOrigin::root(), + 0, + 5, + 5, + 5, + 5, + 1, + false, + false + )); + assert_ok!(Assets::revoke_all_privileges(RuntimeOrigin::root(), 0)); + assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(2), 0, 3, 1)); + assert_ok!(Assets::cancel_approval(RuntimeOrigin::signed(2), 0, 3)); + assert_noop!( + Assets::transfer_approved(RuntimeOrigin::signed(3), 0, 2, 3, 1), + Error::::Unapproved + ); + assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(2), 0, 3, 1)); + assert_ok!(Assets::force_cancel_approval(RuntimeOrigin::root(), 0, 2, 3)); + assert_noop!( + Assets::transfer_approved(RuntimeOrigin::signed(3), 0, 2, 3, 1), + Error::::Unapproved + ); + assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(2), 0, 3, 1)); + assert_ok!(Assets::transfer_approved(RuntimeOrigin::signed(3), 0, 2, 3, 1)); + assert_ok!(Assets::touch(RuntimeOrigin::signed(4), 0)); + assert_ok!(Assets::refund(RuntimeOrigin::signed(4), 0, false)); + assert_ok!(Assets::refund_other(owner_origin.clone(), 0, 444)); + + assert_eq!(Account::::get(&0, 3).unwrap().balance, 53); + + assert_ok!(Assets::mint_into(0, &5, 10)); + assert_ok!(Assets::burn_from( + 0, + &5, + 5, + Preservation::Expendable, + Precision::Exact, + Fortitude::Polite + )); + assert_ok!(Assets::shelve(0, &5, 2)); + assert_ok!(Assets::restore(0, &5, 7)); + assert_ok!(>::transfer(0, &5, &6, 10, Preservation::Expendable)); + assert_eq!(Assets::set_balance(0, &5, 10), 10); + + assert_ok!(Assets::reset_team(0, 6, 8, 7, 9)); + + { + let asset = Asset::::get(0).unwrap(); + assert_eq!(asset.owner(), Some(&6)); + assert_eq!(asset.issuer(), Some(&7)); + assert_eq!(asset.admin(), Some(&8)); + assert_eq!(asset.freezer(), Some(&9)); + } + }); +} + +#[test] +fn reset_team_from_no_privileges() { + use frame_support::traits::fungibles::roles::ResetTeam; + + new_test_ext().execute_with(|| { + let owner = 1; + + assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, owner, false, 1)); + assert_ok!(Assets::revoke_all_privileges(RuntimeOrigin::root(), 0)); + + assert_eq!(Asset::::get(0).unwrap().status, AssetStatus::LiveAndNoPrivileges); + + assert_ok!(Assets::reset_team(0, 6, 8, 7, 9)); + + { + let asset = Asset::::get(0).unwrap(); + assert_eq!(asset.owner(), Some(&6)); + assert_eq!(asset.issuer(), Some(&7)); + assert_eq!(asset.admin(), Some(&8)); + assert_eq!(asset.freezer(), Some(&9)); + assert_eq!(asset.status, AssetStatus::Live); + } + }); +} + +#[test] +fn revoke_change_account_to_pure_account() { + new_test_ext().execute_with(|| { + let owner = 1; + + let height = 10; + let ext_index = 20; + + frame_system::Pallet::::set_block_number(height); + frame_system::Pallet::::set_extrinsic_index(ext_index); + + let pure_account = { + let entropy = + (b"modlasts/assets_", owner, height, ext_index).using_encoded(sp_core::blake2_256); + Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref())).unwrap() + }; + + assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, owner, false, 1)); + assert_ok!(Assets::revoke_all_privileges(RuntimeOrigin::root(), 0)); + + let asset = Asset::::get(0).unwrap(); + assert_eq!(asset.status, AssetStatus::LiveAndNoPrivileges); + assert_eq!( + asset.testing_team_or_historical_team(), + (pure_account, pure_account, pure_account, pure_account), + ); + }); +} diff --git a/substrate/frame/assets/src/types.rs b/substrate/frame/assets/src/types.rs index 11edc7d3fcb58..08d1cbcb19cf5 100644 --- a/substrate/frame/assets/src/types.rs +++ b/substrate/frame/assets/src/types.rs @@ -46,18 +46,26 @@ pub(super) enum AssetStatus { /// The asset is currently being destroyed, and all actions are no longer permitted on the /// asset. Once set to `Destroying`, the asset can never transition back to a `Live` state. Destroying, + /// The asset is active and able to be used, but Owner, Issuer, Admin and Freezer privileges + /// are revoked. + LiveAndNoPrivileges, } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] pub struct AssetDetails { - /// Can change `owner`, `issuer`, `freezer` and `admin` accounts. - pub(super) owner: AccountId, + /// Can change and revoke `owner`, `issuer`, `freezer` and `admin` accounts. + /// If asset status is `LiveAndNoPrivileges`, then this account has no privilege + /// and should not be holding any deposit. + owner: AccountId, /// Can mint tokens. - pub(super) issuer: AccountId, + /// If asset status is `LiveAndNoPrivileges`, then this account has no privilege. + issuer: AccountId, /// Can thaw tokens, force transfers and burn tokens from any account. - pub(super) admin: AccountId, + /// If asset status is `LiveAndNoPrivileges`, then this account has no privilege. + admin: AccountId, /// Can freeze tokens. - pub(super) freezer: AccountId, + /// If asset status is `LiveAndNoPrivileges`, then this account has no privilege. + freezer: AccountId, /// The total supply across all accounts. pub(super) supply: Balance, /// The balance deposited for this asset. This pays for the data stored here. @@ -77,6 +85,135 @@ pub struct AssetDetails { pub(super) status: AssetStatus, } +/// Error that can occur when setting the owner, issuer, admin or freezer of an asset. +pub enum SetTeamError { + /// The asset has no privileges, so team cannot be set. + AssetStatusLiveAndNoPrivileges, +} + +impl AssetDetails { + /// Create a new asset details. + pub(super) fn new( + owner: AccountId, + issuer: AccountId, + admin: AccountId, + freezer: AccountId, + supply: Balance, + deposit: DepositBalance, + min_balance: Balance, + is_sufficient: bool, + accounts: u32, + sufficients: u32, + approvals: u32, + status: AssetStatus, + ) -> Self { + Self { + owner, + issuer, + admin, + freezer, + supply, + deposit, + min_balance, + is_sufficient, + accounts, + sufficients, + approvals, + status, + } + } + + /// If asset status is `LiveAndNoPrivileges` return `None` otherwise return the owner. + pub(super) fn owner(&self) -> Option<&AccountId> { + match self.status { + AssetStatus::LiveAndNoPrivileges => None, + _ => Some(&self.owner), + } + } + + /// If asset status is `LiveAndNoPrivileges` return `None` otherwise return the admin. + pub(super) fn admin(&self) -> Option<&AccountId> { + match self.status { + AssetStatus::LiveAndNoPrivileges => None, + _ => Some(&self.admin), + } + } + + /// If asset status is `LiveAndNoPrivileges` return `None` otherwise return the issuer. + pub(super) fn issuer(&self) -> Option<&AccountId> { + match self.status { + AssetStatus::LiveAndNoPrivileges => None, + _ => Some(&self.issuer), + } + } + + /// If asset status is `LiveAndNoPrivileges` return `None` otherwise return the freezer. + pub(super) fn freezer(&self) -> Option<&AccountId> { + match self.status { + AssetStatus::LiveAndNoPrivileges => None, + _ => Some(&self.freezer), + } + } + + /// Set the owner of the asset, fails if asset status is `LiveAndNoPrivileges`. + pub(super) fn try_set_owner(&mut self, owner: &AccountId) -> Result<(), SetTeamError> { + if self.status == AssetStatus::LiveAndNoPrivileges { + Err(SetTeamError::AssetStatusLiveAndNoPrivileges) + } else { + self.owner = owner.clone(); + Ok(()) + } + } + + /// Set the team of the asset, fails if asset status is `LiveAndNoPrivileges`. + pub(super) fn try_set_team( + &mut self, + owner: &AccountId, + issuer: &AccountId, + admin: &AccountId, + freezer: &AccountId, + ) -> Result<(), SetTeamError> { + if self.status == AssetStatus::LiveAndNoPrivileges { + Err(SetTeamError::AssetStatusLiveAndNoPrivileges) + } else { + self.owner = owner.clone(); + self.issuer = issuer.clone(); + self.admin = admin.clone(); + self.freezer = freezer.clone(); + Ok(()) + } + } + + /// Set the team or the historical team of the asset, new team may not have privileges, never + /// fails. + pub(super) fn set_team_or_historical_team( + &mut self, + owner: &AccountId, + issuer: &AccountId, + admin: &AccountId, + freezer: &AccountId, + ) { + self.owner = owner.clone(); + self.issuer = issuer.clone(); + self.admin = admin.clone(); + self.freezer = freezer.clone(); + } + + /// Is the asset live or live with no privileges. + pub(super) fn is_live(&self) -> bool { + match self.status { + AssetStatus::Live | AssetStatus::LiveAndNoPrivileges => true, + AssetStatus::Frozen | AssetStatus::Destroying => false, + } + } + + /// Get team, regardless of privileges. + #[cfg(test)] + pub fn testing_team_or_historical_team(&self) -> (AccountId, AccountId, AccountId, AccountId) { + (self.owner.clone(), self.issuer.clone(), self.admin.clone(), self.freezer.clone()) + } +} + /// Data concerning an approval. #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, Default, MaxEncodedLen, TypeInfo)] pub struct Approval { diff --git a/substrate/frame/assets/src/weights.rs b/substrate/frame/assets/src/weights.rs index 57f7e951b73c4..3edd023bf5e9c 100644 --- a/substrate/frame/assets/src/weights.rs +++ b/substrate/frame/assets/src/weights.rs @@ -84,6 +84,7 @@ pub trait WeightInfo { fn refund_other() -> Weight; fn block() -> Weight; fn transfer_all() -> Weight; + fn revoke_all_privileges() -> Weight; } /// Weights for `pallet_assets` using the Substrate node and recommended hardware. @@ -541,6 +542,20 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + + /// Storage: `Assets::Asset` (r:1 w:1) + /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `Assets::Metadata` (r:1 w:1) + /// Proof: `Assets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + fn revoke_all_privileges() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 43_242_000 picoseconds. + Weight::from_parts(45_982_000, 3675) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } } // For backwards compatibility and tests. @@ -997,4 +1012,18 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + + /// Storage: `Assets::Asset` (r:1 w:1) + /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `Assets::Metadata` (r:1 w:1) + /// Proof: `Assets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + fn revoke_all_privileges() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 43_242_000 picoseconds. + Weight::from_parts(45_982_000, 3675) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } } diff --git a/substrate/frame/contracts/mock-network/src/parachain.rs b/substrate/frame/contracts/mock-network/src/parachain.rs index 3579b46ea6e9c..0e71be41b4be1 100644 --- a/substrate/frame/contracts/mock-network/src/parachain.rs +++ b/substrate/frame/contracts/mock-network/src/parachain.rs @@ -125,6 +125,7 @@ impl pallet_assets::Config for Runtime { type RemoveItemsLimit = RemoveItemsLimit; type AssetIdParameter = AssetIdForAssets; type CallbackHandle = (); + type DepositDestinationOnRevocation = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); } diff --git a/substrate/frame/nft-fractionalization/src/mock.rs b/substrate/frame/nft-fractionalization/src/mock.rs index 50b41b5fc64e1..8bc829847bee2 100644 --- a/substrate/frame/nft-fractionalization/src/mock.rs +++ b/substrate/frame/nft-fractionalization/src/mock.rs @@ -81,6 +81,7 @@ impl pallet_assets::Config for Test { type Extra = (); type CallbackHandle = (); type WeightInfo = (); + type DepositDestinationOnRevocation = (); pallet_assets::runtime_benchmarks_enabled! { type BenchmarkHelper = (); } diff --git a/substrate/frame/revive/mock-network/src/parachain.rs b/substrate/frame/revive/mock-network/src/parachain.rs index 3def48cca96b8..3af9b54f4507d 100644 --- a/substrate/frame/revive/mock-network/src/parachain.rs +++ b/substrate/frame/revive/mock-network/src/parachain.rs @@ -127,6 +127,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); + type DepositDestinationOnRevocation = (); } parameter_types! { diff --git a/substrate/frame/support/src/traits/tokens/fungibles/roles.rs b/substrate/frame/support/src/traits/tokens/fungibles/roles.rs index 3e68d6b94518d..a44a082c6773a 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/roles.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/roles.rs @@ -36,6 +36,9 @@ pub trait Inspect: super::Inspect { pub trait ResetTeam: super::Inspect { /// Reset the team for the asset with the given `id`. /// + /// This operation doesn't make any consideration about the current privileges of the team. + /// If the current team had revoked its privileges, the new team will still get the privileges. + /// /// ### Parameters /// - `id`: The identifier of the asset for which the team is being reset. /// - `owner`: The new `owner` account for the asset. diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs index acfd43d0a7cb9..cdcdb051131ca 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs @@ -192,6 +192,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type WeightInfo = (); type RemoveItemsLimit = ConstU32<1000>; + type DepositDestinationOnRevocation = (); pallet_assets::runtime_benchmarks_enabled! { type BenchmarkHelper = (); } @@ -216,6 +217,7 @@ impl pallet_assets::Config for Runtime { type Extra = (); type WeightInfo = (); type CallbackHandle = (); + type DepositDestinationOnRevocation = (); pallet_assets::runtime_benchmarks_enabled! { type BenchmarkHelper = (); } diff --git a/substrate/frame/transaction-payment/asset-tx-payment/src/mock.rs b/substrate/frame/transaction-payment/asset-tx-payment/src/mock.rs index e84df1e4eb91b..91fc98fb52a0f 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/substrate/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -136,6 +136,7 @@ impl pallet_assets::Config for Runtime { type CallbackHandle = (); type WeightInfo = (); type RemoveItemsLimit = ConstU32<1000>; + type DepositDestinationOnRevocation = (); pallet_assets::runtime_benchmarks_enabled! { type BenchmarkHelper = (); }