From 4a2c3af10156b7981d23bb6a250fd61dbe4caa5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Pa=C4=8Dandi?= <3002868+Dinonard@users.noreply.github.com> Date: Fri, 11 Aug 2023 15:14:12 +0200 Subject: [PATCH] Automatic EVM revert code registration for XC20 (#1001) * Automatic EVM revert code registration for XC20 * Add negative test * Fmt fix * Add EVM module * Asset benchmarks * Cleanup xc asset config * Update asset benchmarks * Fix tests features --- Cargo.lock | 5 + pallets/xc-asset-config/src/lib.rs | 21 - pallets/xc-asset-config/src/mock.rs | 1 - precompiles/assets-erc20/Cargo.toml | 1 + precompiles/assets-erc20/src/mock.rs | 2 + precompiles/xcm/src/mock.rs | 2 + primitives/Cargo.toml | 12 +- primitives/src/benchmarks.rs | 30 ++ primitives/src/evm.rs | 56 +++ primitives/src/lib.rs | 10 +- primitives/src/xcm/mod.rs | 51 +- primitives/src/xcm/tests.rs | 155 +----- runtime/astar/Cargo.toml | 1 + runtime/astar/src/lib.rs | 26 +- runtime/astar/src/weights/mod.rs | 19 + runtime/astar/src/weights/pallet_assets.rs | 496 +++++++++++++++++++ runtime/local/Cargo.toml | 1 + runtime/local/src/lib.rs | 12 +- runtime/local/src/weights/mod.rs | 19 + runtime/local/src/weights/pallet_assets.rs | 496 +++++++++++++++++++ runtime/shibuya/Cargo.toml | 1 + runtime/shibuya/src/lib.rs | 30 +- runtime/shibuya/src/weights/mod.rs | 19 + runtime/shibuya/src/weights/pallet_assets.rs | 496 +++++++++++++++++++ runtime/shiden/Cargo.toml | 1 + runtime/shiden/src/lib.rs | 26 +- runtime/shiden/src/weights/mod.rs | 19 + runtime/shiden/src/weights/pallet_assets.rs | 496 +++++++++++++++++++ scripts/templates/weight-template.hbs | 18 + tests/integration/Cargo.toml | 2 + tests/integration/src/assets.rs | 81 +++ tests/integration/src/lib.rs | 3 + tests/integration/src/setup.rs | 2 +- tests/xcm-simulator/src/mocks/parachain.rs | 3 +- 34 files changed, 2323 insertions(+), 290 deletions(-) create mode 100644 primitives/src/benchmarks.rs create mode 100644 primitives/src/evm.rs create mode 100644 runtime/astar/src/weights/mod.rs create mode 100644 runtime/astar/src/weights/pallet_assets.rs create mode 100644 runtime/local/src/weights/mod.rs create mode 100644 runtime/local/src/weights/pallet_assets.rs create mode 100644 runtime/shibuya/src/weights/mod.rs create mode 100644 runtime/shibuya/src/weights/pallet_assets.rs create mode 100644 runtime/shiden/src/weights/mod.rs create mode 100644 runtime/shiden/src/weights/pallet_assets.rs create mode 100644 tests/integration/src/assets.rs diff --git a/Cargo.lock b/Cargo.lock index 9aa74cd3fe..b1dd542a8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -515,6 +515,9 @@ dependencies = [ "frame-support", "impl-trait-for-tuples", "log", + "pallet-assets", + "pallet-evm", + "pallet-evm-precompile-assets-erc20", "pallet-xc-asset-config", "parity-scale-codec", "scale-info", @@ -4461,12 +4464,14 @@ dependencies = [ "frame-support", "frame-system", "hex", + "pallet-assets", "pallet-balances", "pallet-contracts", "pallet-contracts-primitives", "pallet-dapps-staking", "pallet-ethereum-checked", "pallet-evm", + "pallet-evm-precompile-assets-erc20", "pallet-proxy", "pallet-utility", "parity-scale-codec", diff --git a/pallets/xc-asset-config/src/lib.rs b/pallets/xc-asset-config/src/lib.rs index 4310198def..193cdf961f 100644 --- a/pallets/xc-asset-config/src/lib.rs +++ b/pallets/xc-asset-config/src/lib.rs @@ -85,21 +85,6 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(PhantomData); - /// Callback definition trait for cross-chain asset registration/deregistration notifications. - pub trait XcAssetChanged { - /// Will be called by pallet when new asset Id has been registered - fn xc_asset_registered(asset_id: T::AssetId); - - /// Will be called by pallet when asset Id has been unregistered - fn xc_asset_unregistered(asset_id: T::AssetId); - } - - /// Implementation that does nothing - impl XcAssetChanged for () { - fn xc_asset_registered(_: T::AssetId) {} - fn xc_asset_unregistered(_: T::AssetId) {} - } - /// Defines conversion between asset Id and cross-chain asset location pub trait XcAssetLocation { /// Get asset type from assetId @@ -139,9 +124,6 @@ pub mod pallet { /// a AssetLocation type AssetId: Member + Parameter + Default + Copy + HasCompact + MaxEncodedLen; - /// Callback handling for cross-chain asset registration or unregistration. - type XcAssetChanged: XcAssetChanged; - /// The required origin for managing cross-chain asset configuration /// /// Should most likely be root. @@ -242,8 +224,6 @@ pub mod pallet { AssetIdToLocation::::insert(&asset_id, asset_location.clone()); AssetLocationToId::::insert(&asset_location, asset_id); - T::XcAssetChanged::xc_asset_registered(asset_id); - Self::deposit_event(Event::AssetRegistered { asset_location, asset_id, @@ -354,7 +334,6 @@ pub mod pallet { AssetIdToLocation::::remove(&asset_id); AssetLocationToId::::remove(&asset_location); AssetLocationUnitsPerSecond::::remove(&asset_location); - T::XcAssetChanged::xc_asset_unregistered(asset_id); Self::deposit_event(Event::AssetRemoved { asset_id, diff --git a/pallets/xc-asset-config/src/mock.rs b/pallets/xc-asset-config/src/mock.rs index aa00246b1f..f15736b8b8 100644 --- a/pallets/xc-asset-config/src/mock.rs +++ b/pallets/xc-asset-config/src/mock.rs @@ -108,7 +108,6 @@ type AssetId = u128; impl pallet_xc_asset_config::Config for Test { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; - type XcAssetChanged = (); type ManagerOrigin = frame_system::EnsureRoot; type WeightInfo = (); } diff --git a/precompiles/assets-erc20/Cargo.toml b/precompiles/assets-erc20/Cargo.toml index cafa20e6b9..f70e155468 100644 --- a/precompiles/assets-erc20/Cargo.toml +++ b/precompiles/assets-erc20/Cargo.toml @@ -55,3 +55,4 @@ std = [ "sp-runtime/std", "sp-std/std", ] +runtime-benchmarks = [] diff --git a/precompiles/assets-erc20/src/mock.rs b/precompiles/assets-erc20/src/mock.rs index 3d7ec86fca..47c4ba498b 100644 --- a/precompiles/assets-erc20/src/mock.rs +++ b/precompiles/assets-erc20/src/mock.rs @@ -283,6 +283,8 @@ impl pallet_assets::Config for Runtime { type RemoveItemsLimit = ConstU32<0>; type AssetIdParameter = AssetId; type CallbackHandle = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } // Configure a mock runtime to test the pallet. diff --git a/precompiles/xcm/src/mock.rs b/precompiles/xcm/src/mock.rs index 85f1ddf094..b2d2ace443 100644 --- a/precompiles/xcm/src/mock.rs +++ b/precompiles/xcm/src/mock.rs @@ -270,6 +270,8 @@ impl pallet_assets::Config for Runtime { type RemoveItemsLimit = ConstU32<0>; type AssetIdParameter = AssetId; type CallbackHandle = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } pub struct AssetIdConverter(PhantomData); diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 4c8eef897c..6a4306fe00 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -20,6 +20,7 @@ fp-evm = { workspace = true } # Substrate dependencies frame-support = { workspace = true } +pallet-assets = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } @@ -30,7 +31,11 @@ xcm = { workspace = true } xcm-builder = { workspace = true } xcm-executor = { workspace = true } -# Astar pallets +# Frontier dependencies +pallet-evm = { workspace = true } + +# Astar pallets & dependencies +pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-xc-asset-config = { workspace = true } [features] @@ -52,5 +57,8 @@ std = [ "xcm-executor/std", "pallet-xc-asset-config/std", "fp-evm/std", + "pallet-assets/std", + "pallet-evm/std", + "pallet-evm-precompile-assets-erc20/std", ] -runtime-benchmarks = ["xcm-builder/runtime-benchmarks"] +runtime-benchmarks = ["xcm-builder/runtime-benchmarks", "pallet-assets/runtime-benchmarks"] diff --git a/primitives/src/benchmarks.rs b/primitives/src/benchmarks.rs new file mode 100644 index 0000000000..f0cfa392df --- /dev/null +++ b/primitives/src/benchmarks.rs @@ -0,0 +1,30 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +use crate::AssetId; + +#[cfg(feature = "runtime-benchmarks")] +/// Benchmark helper for `pallet-assets`. +pub struct AssetsBenchmarkHelper; +impl> pallet_assets::BenchmarkHelper + for AssetsBenchmarkHelper +{ + fn create_asset_id_parameter(id: u32) -> AssetIdParameter { + AssetId::from(id).into() + } +} diff --git a/primitives/src/evm.rs b/primitives/src/evm.rs new file mode 100644 index 0000000000..25d1599219 --- /dev/null +++ b/primitives/src/evm.rs @@ -0,0 +1,56 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +use crate::{AccountId, AssetId}; + +use frame_support::ensure; +use sp_std::marker::PhantomData; + +use pallet_assets::AssetsCallback; +use pallet_evm_precompile_assets_erc20::AddressToAssetId; + +/// Revert opt code. It's inserted at the precompile addresses, to make them functional in EVM. +pub const EVM_REVERT_CODE: &[u8] = &[0x60, 0x00, 0x60, 0x00, 0xfd]; + +/// Handler for automatic revert code registration. +/// +/// When an asset is created, it automatically becomes available to the EVM via an `ERC20-like` interface. +/// In order for the precompile to work, dedicated asset address needs to have the revert code registered, otherwise the call will fail. +/// +/// It is important to note that if the dedicated asset EVM address is already taken, asset creation should fail. +/// After asset has been destroyed, it is also safe to remove the revert code and free the address for future usage. +pub struct EvmRevertCodeHandler(PhantomData<(A, R)>); +impl AssetsCallback for EvmRevertCodeHandler +where + A: AddressToAssetId, + R: pallet_evm::Config, +{ + fn created(id: &AssetId, _: &AccountId) -> Result<(), ()> { + let address = A::asset_id_to_address(*id); + // In case of collision, we need to cancel the asset creation. + ensure!(!pallet_evm::AccountCodes::::contains_key(&address), ()); + pallet_evm::AccountCodes::::insert(address, EVM_REVERT_CODE.to_vec()); + Ok(()) + } + + fn destroyed(id: &AssetId) -> Result<(), ()> { + let address = A::asset_id_to_address(*id); + pallet_evm::AccountCodes::::remove(address); + Ok(()) + } +} diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 777ba49fd9..9cf71cb373 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -29,10 +29,16 @@ pub mod ethereum_checked; /// XVM primitives. pub mod xvm; -use sp_runtime::traits::BlakeTwo256; +/// EVM primitives. +pub mod evm; + +/// Benchmark primitives +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarks; + use sp_runtime::{ generic, - traits::{IdentifyAccount, Verify}, + traits::{BlakeTwo256, IdentifyAccount, Verify}, }; /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. diff --git a/primitives/src/xcm/mod.rs b/primitives/src/xcm/mod.rs index f8ce3e4eb0..66210bf95f 100644 --- a/primitives/src/xcm/mod.rs +++ b/primitives/src/xcm/mod.rs @@ -33,8 +33,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ - ensure, - traits::{tokens::fungibles, Contains, ContainsPair, Get, ProcessMessageError}, + traits::{tokens::fungibles, ContainsPair, Get}, weights::constants::WEIGHT_REF_TIME_PER_SECOND, }; use sp_runtime::traits::{Bounded, Zero}; @@ -43,7 +42,7 @@ use sp_std::{borrow::Borrow, marker::PhantomData, vec::Vec}; // Polkadot imports use xcm::latest::{prelude::*, Weight}; use xcm_builder::TakeRevenue; -use xcm_executor::traits::{MatchesFungibles, ShouldExecute, WeightTrader}; +use xcm_executor::traits::{MatchesFungibles, WeightTrader}; use pallet_xc_asset_config::{ExecutionPaymentRate, XcAssetLocation}; @@ -271,52 +270,6 @@ impl< } } -/// Allows execution from `origin` if it is contained in `T` (i.e. `T::Contains(origin)`) taking -/// payments into account. -/// -/// Only allows for sequence `DescendOrigin` -> `WithdrawAsset` -> `BuyExecution` -pub struct AllowPaidExecWithDescendOriginFrom(PhantomData); -impl> ShouldExecute for AllowPaidExecWithDescendOriginFrom { - fn should_execute( - origin: &MultiLocation, - message: &mut [Instruction], - max_weight: Weight, - _weight_credit: &mut Weight, - ) -> Result<(), ProcessMessageError> { - log::trace!( - target: "xcm::barriers", - "AllowPaidExecWithDescendOriginFrom origin: {:?}, message: {:?}, max_weight: {:?}, weight_credit: {:?}", - origin, message, max_weight, _weight_credit, - ); - ensure!(T::contains(origin), ProcessMessageError::Unsupported); - - match message - .iter_mut() - .take(3) - .collect::>() - .as_mut_slice() - { - [DescendOrigin(..), WithdrawAsset(..), BuyExecution { - weight_limit: Limited(ref mut limit), - .. - }] if limit.all_gte(max_weight) => { - *limit = max_weight; - Ok(()) - } - - [DescendOrigin(..), WithdrawAsset(..), BuyExecution { - weight_limit: ref mut limit @ Unlimited, - .. - }] => { - *limit = Limited(max_weight); - Ok(()) - } - - _ => return Err(ProcessMessageError::Unsupported), - } - } -} - // TODO: remove this after uplift to `polkadot-v0.9.44` or beyond, and replace it with code in XCM builder. use parity_scale_codec::{Compact, Encode}; diff --git a/primitives/src/xcm/tests.rs b/primitives/src/xcm/tests.rs index faef681aaf..21dcfbeaef 100644 --- a/primitives/src/xcm/tests.rs +++ b/primitives/src/xcm/tests.rs @@ -17,10 +17,7 @@ // along with Astar. If not, see . use super::*; -use frame_support::{ - assert_ok, - traits::{Everything, Nothing}, -}; +use frame_support::assert_ok; use sp_runtime::traits::Zero; use xcm_executor::traits::Convert; @@ -411,156 +408,6 @@ fn reserve_asset_filter_for_unsupported_asset_multi_location() { assert!(!ReserveAssetFilter::contains(&multi_asset, &origin)); } -/// Returns valid XCM sequence for bypassing `AllowPaidExecWithDescendOriginFrom` -fn desc_origin_barrier_valid_sequence() -> Vec> { - vec![ - DescendOrigin(X1(Junction::Parachain(1234))), - WithdrawAsset((Here, 100).into()), - BuyExecution { - fees: (Here, 100).into(), - weight_limit: WeightLimit::Unlimited, - }, - ] -} - -#[test] -fn allow_paid_exec_with_descend_origin_works() { - let mut valid_message = desc_origin_barrier_valid_sequence(); - - let res = AllowPaidExecWithDescendOriginFrom::::should_execute( - &Here.into(), - &mut valid_message, - Weight::from_parts(150, 0), - &mut Weight::zero(), - ); - assert_eq!(res, Ok(())); - - // Still works even if there are follow-up instructions - valid_message = desc_origin_barrier_valid_sequence(); - valid_message.push(SetErrorHandler(Default::default())); - let res = AllowPaidExecWithDescendOriginFrom::::should_execute( - &Here.into(), - &mut valid_message, - Weight::from_parts(100, 0), - &mut Weight::zero(), - ); - assert_eq!(res, Ok(())); -} - -#[test] -fn allow_paid_exec_with_descend_origin_with_weight_correction_works() { - let mut valid_message = desc_origin_barrier_valid_sequence(); - - // Ensure that `Limited` gets adjusted to the provided enforced_weight_limit - let enforced_weight_limit = Weight::from_parts(3, 0); - let res = AllowPaidExecWithDescendOriginFrom::::should_execute( - &Here.into(), - &mut valid_message, - enforced_weight_limit, - &mut Weight::zero(), - ); - assert_eq!(res, Ok(())); - - if let BuyExecution { - weight_limit, - fees: _, - } = valid_message[2].clone() - { - assert_eq!(weight_limit, WeightLimit::Limited(enforced_weight_limit)) - } else { - panic!("3rd instruction should be BuyExecution!"); - } - - // Ensure that we use `BuyExecution` with `Unlimited` weight limit - let _ = std::mem::replace( - &mut valid_message[2], - BuyExecution { - fees: (Here, 100).into(), - weight_limit: WeightLimit::Limited(enforced_weight_limit.add_ref_time(7)), - }, - ); - - // Ensure that `Unlimited` gets adjusted to the provided max weight limit - let res = AllowPaidExecWithDescendOriginFrom::::should_execute( - &Here.into(), - &mut valid_message, - enforced_weight_limit, - &mut Weight::zero(), - ); - assert_eq!(res, Ok(())); - - if let BuyExecution { - weight_limit, - fees: _, - } = valid_message[2].clone() - { - assert_eq!(weight_limit, WeightLimit::Limited(enforced_weight_limit)) - } else { - panic!("3rd instruction should be BuyExecution!"); - } -} - -#[test] -fn allow_paid_exec_with_descend_origin_with_unsupported_origin_fails() { - let mut valid_message = desc_origin_barrier_valid_sequence(); - - let res = AllowPaidExecWithDescendOriginFrom::::should_execute( - &Here.into(), - &mut valid_message, - Weight::from_parts(100, 0), - &mut Weight::zero(), - ); - assert_eq!(res, Err(ProcessMessageError::Unsupported)); -} - -#[test] -fn allow_paid_exec_with_descend_origin_with_invalid_message_fails() { - let mut invalid_message = vec![WithdrawAsset((Here, 100).into())]; - - let res = AllowPaidExecWithDescendOriginFrom::::should_execute( - &Here.into(), - &mut invalid_message, - Weight::from_parts(100, 0), - &mut Weight::zero(), - ); - assert_eq!(res, Err(ProcessMessageError::Unsupported)); - - // Should still fail, even if correct sequence follows next - invalid_message.append(&mut desc_origin_barrier_valid_sequence()); - let res = AllowPaidExecWithDescendOriginFrom::::should_execute( - &Here.into(), - &mut invalid_message, - Weight::from_parts(100, 0), - &mut Weight::zero(), - ); - assert_eq!(res, Err(ProcessMessageError::Unsupported)); -} - -#[test] -fn allow_paid_exec_with_descend_origin_too_small_weight_fails() { - let mut valid_message = desc_origin_barrier_valid_sequence(); - let enforced_weight_limit = Weight::from_parts(29, 0); - - // Ensure that we use `BuyExecution` with `Limited` weight but with insufficient weight. - // This means that not enough execution time (weight) is being bought compared to the - // weight of whole sequence. - let _ = std::mem::replace( - &mut valid_message[2], - BuyExecution { - fees: (Here, 100).into(), - weight_limit: WeightLimit::Limited(enforced_weight_limit.sub_ref_time(7)), - }, - ); - - let res = AllowPaidExecWithDescendOriginFrom::::should_execute( - &Here.into(), - &mut valid_message, - enforced_weight_limit, - &mut Weight::zero(), - ); - assert_eq!(res, Err(ProcessMessageError::Unsupported)); -} - // TODO: can be deleted after uplift to `polkadot-v0.9.44` or beyond. #[test] fn hashed_description_sanity_check() { diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index 07f8fec6f7..2dcb04a7b5 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -219,6 +219,7 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "polkadot-runtime/runtime-benchmarks", "astar-primitives/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 242a4dfd9a..1b8e7e4424 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -23,7 +23,8 @@ #![recursion_limit = "256"] pub use astar_primitives::{ - AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, + evm::EvmRevertCodeHandler, xcm::AssetLocationIdConverter, AccountId, Address, AssetId, Balance, + BlockNumber, Hash, Header, Index, Signature, }; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use frame_support::{ @@ -71,7 +72,6 @@ use sp_runtime::{ }; use sp_std::prelude::*; -use astar_primitives::xcm::AssetLocationIdConverter; use pallet_evm_precompile_assets_erc20::AddressToAssetId; #[cfg(any(feature = "std", test))] @@ -85,6 +85,7 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::BuildStorage; mod precompiles; +mod weights; mod xcm_config; pub type AstarAssetLocationIdConverter = AssetLocationIdConverter; @@ -580,10 +581,12 @@ impl pallet_assets::Config for Runtime { type StringLimit = AssetsStringLimit; type Freezer = (); type Extra = (); - type WeightInfo = pallet_assets::weights::SubstrateWeight; + type WeightInfo = weights::pallet_assets::SubstrateWeight; type RemoveItemsLimit = ConstU32<1000>; type AssetIdParameter = Compact; - type CallbackHandle = (); + type CallbackHandle = EvmRevertCodeHandler; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = astar_primitives::benchmarks::AssetsBenchmarkHelper; } parameter_types! { @@ -834,23 +837,9 @@ impl pallet_sudo::Config for Runtime { type WeightInfo = pallet_sudo::weights::SubstrateWeight; } -pub struct EvmRevertCodeHandler; -impl pallet_xc_asset_config::XcAssetChanged for EvmRevertCodeHandler { - fn xc_asset_registered(asset_id: AssetId) { - let address = Runtime::asset_id_to_address(asset_id); - pallet_evm::AccountCodes::::insert(address, vec![0x60, 0x00, 0x60, 0x00, 0xfd]); - } - - fn xc_asset_unregistered(asset_id: AssetId) { - let address = Runtime::asset_id_to_address(asset_id); - pallet_evm::AccountCodes::::remove(address); - } -} - impl pallet_xc_asset_config::Config for Runtime { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; - type XcAssetChanged = EvmRevertCodeHandler; type ManagerOrigin = EnsureRoot; type WeightInfo = pallet_xc_asset_config::weights::SubstrateWeight; } @@ -1163,6 +1152,7 @@ mod benches { define_benchmarks!( [frame_benchmarking, BaselineBench::] [frame_system, SystemBench::] + [pallet_assets, Assets] [pallet_balances, Balances] [pallet_timestamp, Timestamp] [pallet_dapps_staking, DappsStaking] diff --git a/runtime/astar/src/weights/mod.rs b/runtime/astar/src/weights/mod.rs new file mode 100644 index 0000000000..2db3ac12ab --- /dev/null +++ b/runtime/astar/src/weights/mod.rs @@ -0,0 +1,19 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +pub mod pallet_assets; diff --git a/runtime/astar/src/weights/pallet_assets.rs b/runtime/astar/src/weights/pallet_assets.rs new file mode 100644 index 0000000000..676729637e --- /dev/null +++ b/runtime/astar/src/weights/pallet_assets.rs @@ -0,0 +1,496 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. 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-08-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("astar-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=astar-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_assets +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/assets_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weights for pallet_assets using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl pallet_assets::WeightInfo for SubstrateWeight { + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:1 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `659` + // Estimated: `4124` + // Minimum execution time: 35_155_000 picoseconds. + Weight::from_parts(35_760_000, 4124) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:1 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn force_create() -> Weight { + // Proof Size summary in bytes: + // Measured: `519` + // Estimated: `3984` + // Minimum execution time: 20_004_000 picoseconds. + Weight::from_parts(20_348_000, 3984) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn start_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_682_000 picoseconds. + Weight::from_parts(14_059_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1001 w:1000) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, 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]`. + fn destroy_accounts(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `255 + c * (208 ±0)` + // Estimated: `3687 + c * (2621 ±0)` + // Minimum execution time: 17_910_000 picoseconds. + Weight::from_parts(18_110_000, 3687) + // Standard Error: 6_525 + .saturating_add(Weight::from_parts(11_623_553, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2621).saturating_mul(c.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1001 w:1000) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + /// The range of component `a` is `[0, 1000]`. + fn destroy_approvals(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `438 + a * (86 ±0)` + // Estimated: `3687 + a * (2635 ±0)` + // Minimum execution time: 18_065_000 picoseconds. + Weight::from_parts(18_372_000, 3687) + // Standard Error: 4_985 + .saturating_add(Weight::from_parts(13_662_720, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 2635).saturating_mul(a.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:0 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn finish_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 16_700_000 picoseconds. + Weight::from_parts(17_418_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 26_305_000 picoseconds. + Weight::from_parts(27_014_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn burn() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 30_525_000 picoseconds. + Weight::from_parts(31_113_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `6232` + // Minimum execution time: 42_955_000 picoseconds. + Weight::from_parts(43_309_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// 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: `447` + // Estimated: `6232` + // Minimum execution time: 37_951_000 picoseconds. + Weight::from_parts(38_330_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn force_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `6232` + // Minimum execution time: 43_061_000 picoseconds. + Weight::from_parts(43_561_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn freeze() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_259_000 picoseconds. + Weight::from_parts(17_516_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn thaw() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_165_000 picoseconds. + Weight::from_parts(17_547_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn freeze_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_634_000 picoseconds. + Weight::from_parts(14_069_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + fn thaw_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_456_000 picoseconds. + Weight::from_parts(13_770_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn transfer_ownership() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 16_083_000 picoseconds. + Weight::from_parts(16_343_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn set_team() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 14_443_000 picoseconds. + Weight::from_parts(14_818_000, 3687) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// 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: `255` + // Estimated: `3687` + // Minimum execution time: 28_260_000 picoseconds. + Weight::from_parts(29_181_263, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `431` + // Estimated: `3687` + // Minimum execution time: 28_580_000 picoseconds. + Weight::from_parts(28_826_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// 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: `94` + // Estimated: `3687` + // Minimum execution time: 14_605_000 picoseconds. + Weight::from_parts(15_107_642, 3687) + // Standard Error: 450 + .saturating_add(Weight::from_parts(6_608, 0).saturating_mul(n.into())) + // Standard Error: 450 + .saturating_add(Weight::from_parts(2_783, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn force_clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `431` + // Estimated: `3687` + // Minimum execution time: 27_925_000 picoseconds. + Weight::from_parts(28_323_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn force_asset_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 13_904_000 picoseconds. + Weight::from_parts(14_431_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn approve_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 31_152_000 picoseconds. + Weight::from_parts(31_715_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer_approved() -> Weight { + // Proof Size summary in bytes: + // Measured: `680` + // Estimated: `6232` + // Minimum execution time: 63_252_000 picoseconds. + Weight::from_parts(63_718_000, 6232) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `471` + // Estimated: `3687` + // Minimum execution time: 34_375_000 picoseconds. + Weight::from_parts(34_640_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn force_cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `471` + // Estimated: `3687` + // Minimum execution time: 34_159_000 picoseconds. + Weight::from_parts(34_693_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn set_min_balance() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 15_114_000 picoseconds. + Weight::from_parts(15_271_000, 3687) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn touch() -> Weight { + // Proof Size summary in bytes: + // Measured: `429` + // Estimated: `3687` + // Minimum execution time: 34_356_000 picoseconds. + Weight::from_parts(34_856_000, 3687) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn touch_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 31_063_000 picoseconds. + Weight::from_parts(31_331_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn refund() -> Weight { + // Proof Size summary in bytes: + // Measured: `567` + // Estimated: `3687` + // Minimum execution time: 31_678_000 picoseconds. + Weight::from_parts(31_941_000, 3687) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn refund_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `426` + // Estimated: `3687` + // Minimum execution time: 28_601_000 picoseconds. + Weight::from_parts(28_966_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn block() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_545_000 picoseconds. + Weight::from_parts(17_959_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index 77a300febf..6226f6fe8a 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -184,6 +184,7 @@ runtime-benchmarks = [ "pallet-preimage/runtime-benchmarks", "pallet-ethereum-checked/runtime-benchmarks", "astar-primitives/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 524b5085d0..40c1e7e9a3 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -61,7 +61,8 @@ use sp_runtime::{ use sp_std::prelude::*; pub use astar_primitives::{ - AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, + evm::EvmRevertCodeHandler, AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, + Index, Signature, }; #[cfg(feature = "std")] @@ -114,6 +115,8 @@ pub type Precompiles = LocalNetworkPrecompiles; mod chain_extensions; pub use chain_extensions::*; +mod weights; + /// Constant values used within the runtime. pub const MICROAST: Balance = 1_000_000_000_000; pub const MILLIAST: Balance = 1_000 * MICROAST; @@ -321,10 +324,12 @@ impl pallet_assets::Config for Runtime { type StringLimit = AssetsStringLimit; type Freezer = (); type Extra = (); - type WeightInfo = pallet_assets::weights::SubstrateWeight; + type WeightInfo = weights::pallet_assets::SubstrateWeight; type RemoveItemsLimit = ConstU32<1000>; type AssetIdParameter = Compact; - type CallbackHandle = (); + type CallbackHandle = EvmRevertCodeHandler; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = astar_primitives::benchmarks::AssetsBenchmarkHelper; } parameter_types! { @@ -1125,6 +1130,7 @@ extern crate frame_benchmarking; mod benches { define_benchmarks!( [frame_benchmarking, BaselineBench::] + [pallet_assets, Assets] [frame_system, SystemBench::] [pallet_balances, Balances] [pallet_timestamp, Timestamp] diff --git a/runtime/local/src/weights/mod.rs b/runtime/local/src/weights/mod.rs new file mode 100644 index 0000000000..2db3ac12ab --- /dev/null +++ b/runtime/local/src/weights/mod.rs @@ -0,0 +1,19 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +pub mod pallet_assets; diff --git a/runtime/local/src/weights/pallet_assets.rs b/runtime/local/src/weights/pallet_assets.rs new file mode 100644 index 0000000000..676729637e --- /dev/null +++ b/runtime/local/src/weights/pallet_assets.rs @@ -0,0 +1,496 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. 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-08-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("astar-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=astar-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_assets +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/assets_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weights for pallet_assets using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl pallet_assets::WeightInfo for SubstrateWeight { + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:1 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `659` + // Estimated: `4124` + // Minimum execution time: 35_155_000 picoseconds. + Weight::from_parts(35_760_000, 4124) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:1 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn force_create() -> Weight { + // Proof Size summary in bytes: + // Measured: `519` + // Estimated: `3984` + // Minimum execution time: 20_004_000 picoseconds. + Weight::from_parts(20_348_000, 3984) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn start_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_682_000 picoseconds. + Weight::from_parts(14_059_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1001 w:1000) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, 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]`. + fn destroy_accounts(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `255 + c * (208 ±0)` + // Estimated: `3687 + c * (2621 ±0)` + // Minimum execution time: 17_910_000 picoseconds. + Weight::from_parts(18_110_000, 3687) + // Standard Error: 6_525 + .saturating_add(Weight::from_parts(11_623_553, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2621).saturating_mul(c.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1001 w:1000) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + /// The range of component `a` is `[0, 1000]`. + fn destroy_approvals(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `438 + a * (86 ±0)` + // Estimated: `3687 + a * (2635 ±0)` + // Minimum execution time: 18_065_000 picoseconds. + Weight::from_parts(18_372_000, 3687) + // Standard Error: 4_985 + .saturating_add(Weight::from_parts(13_662_720, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 2635).saturating_mul(a.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:0 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn finish_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 16_700_000 picoseconds. + Weight::from_parts(17_418_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 26_305_000 picoseconds. + Weight::from_parts(27_014_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn burn() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 30_525_000 picoseconds. + Weight::from_parts(31_113_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `6232` + // Minimum execution time: 42_955_000 picoseconds. + Weight::from_parts(43_309_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// 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: `447` + // Estimated: `6232` + // Minimum execution time: 37_951_000 picoseconds. + Weight::from_parts(38_330_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn force_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `6232` + // Minimum execution time: 43_061_000 picoseconds. + Weight::from_parts(43_561_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn freeze() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_259_000 picoseconds. + Weight::from_parts(17_516_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn thaw() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_165_000 picoseconds. + Weight::from_parts(17_547_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn freeze_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_634_000 picoseconds. + Weight::from_parts(14_069_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + fn thaw_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_456_000 picoseconds. + Weight::from_parts(13_770_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn transfer_ownership() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 16_083_000 picoseconds. + Weight::from_parts(16_343_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn set_team() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 14_443_000 picoseconds. + Weight::from_parts(14_818_000, 3687) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// 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: `255` + // Estimated: `3687` + // Minimum execution time: 28_260_000 picoseconds. + Weight::from_parts(29_181_263, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `431` + // Estimated: `3687` + // Minimum execution time: 28_580_000 picoseconds. + Weight::from_parts(28_826_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// 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: `94` + // Estimated: `3687` + // Minimum execution time: 14_605_000 picoseconds. + Weight::from_parts(15_107_642, 3687) + // Standard Error: 450 + .saturating_add(Weight::from_parts(6_608, 0).saturating_mul(n.into())) + // Standard Error: 450 + .saturating_add(Weight::from_parts(2_783, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn force_clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `431` + // Estimated: `3687` + // Minimum execution time: 27_925_000 picoseconds. + Weight::from_parts(28_323_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn force_asset_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 13_904_000 picoseconds. + Weight::from_parts(14_431_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn approve_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 31_152_000 picoseconds. + Weight::from_parts(31_715_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer_approved() -> Weight { + // Proof Size summary in bytes: + // Measured: `680` + // Estimated: `6232` + // Minimum execution time: 63_252_000 picoseconds. + Weight::from_parts(63_718_000, 6232) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `471` + // Estimated: `3687` + // Minimum execution time: 34_375_000 picoseconds. + Weight::from_parts(34_640_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn force_cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `471` + // Estimated: `3687` + // Minimum execution time: 34_159_000 picoseconds. + Weight::from_parts(34_693_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn set_min_balance() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 15_114_000 picoseconds. + Weight::from_parts(15_271_000, 3687) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn touch() -> Weight { + // Proof Size summary in bytes: + // Measured: `429` + // Estimated: `3687` + // Minimum execution time: 34_356_000 picoseconds. + Weight::from_parts(34_856_000, 3687) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn touch_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 31_063_000 picoseconds. + Weight::from_parts(31_331_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn refund() -> Weight { + // Proof Size summary in bytes: + // Measured: `567` + // Estimated: `3687` + // Minimum execution time: 31_678_000 picoseconds. + Weight::from_parts(31_941_000, 3687) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn refund_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `426` + // Estimated: `3687` + // Minimum execution time: 28_601_000 picoseconds. + Weight::from_parts(28_966_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn block() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_545_000 picoseconds. + Weight::from_parts(17_959_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 5658d2e833..ad17c0f917 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -259,6 +259,7 @@ runtime-benchmarks = [ "polkadot-runtime/runtime-benchmarks", "orml-xtokens/runtime-benchmarks", "astar-primitives/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index bc94244c62..c483158297 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -69,11 +69,11 @@ use sp_runtime::{ use sp_std::prelude::*; pub use astar_primitives::{ - ethereum_checked::CheckedEthereumTransact, AccountId, Address, AssetId, Balance, BlockNumber, - Hash, Header, Index, Signature, + ethereum_checked::CheckedEthereumTransact, evm::EvmRevertCodeHandler, + xcm::AssetLocationIdConverter, AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, + Index, Signature, }; -use astar_primitives::xcm::AssetLocationIdConverter; use pallet_evm_precompile_assets_erc20::AddressToAssetId; #[cfg(any(feature = "std", test))] @@ -88,6 +88,7 @@ pub use sp_runtime::BuildStorage; mod chain_extensions; mod precompiles; +mod weights; mod xcm_config; pub type ShibuyaAssetLocationIdConverter = AssetLocationIdConverter; @@ -629,10 +630,12 @@ impl pallet_assets::Config for Runtime { type StringLimit = AssetsStringLimit; type Freezer = (); type Extra = (); - type WeightInfo = pallet_assets::weights::SubstrateWeight; + type WeightInfo = weights::pallet_assets::SubstrateWeight; type RemoveItemsLimit = ConstU32<1000>; type AssetIdParameter = Compact; - type CallbackHandle = (); + type CallbackHandle = EvmRevertCodeHandler; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = astar_primitives::benchmarks::AssetsBenchmarkHelper; } parameter_types! { @@ -1221,25 +1224,11 @@ impl pallet_proxy::Config for Runtime { type AnnouncementDepositFactor = AnnouncementDepositFactor; } -pub struct EvmRevertCodeHandler; -impl pallet_xc_asset_config::XcAssetChanged for EvmRevertCodeHandler { - fn xc_asset_registered(asset_id: AssetId) { - let address = Runtime::asset_id_to_address(asset_id); - pallet_evm::AccountCodes::::insert(address, vec![0x60, 0x00, 0x60, 0x00, 0xfd]); - } - - fn xc_asset_unregistered(asset_id: AssetId) { - let address = Runtime::asset_id_to_address(asset_id); - pallet_evm::AccountCodes::::remove(address); - } -} - impl pallet_xc_asset_config::Config for Runtime { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; - type XcAssetChanged = EvmRevertCodeHandler; // Good enough for testnet since we lack pallet-assets hooks for now - type ManagerOrigin = EitherOfDiverse, EnsureSigned>; + type ManagerOrigin = EnsureRoot; type WeightInfo = pallet_xc_asset_config::weights::SubstrateWeight; } @@ -1421,6 +1410,7 @@ mod benches { define_benchmarks!( [frame_benchmarking, BaselineBench::] [frame_system, SystemBench::] + [pallet_assets, Assets] [pallet_balances, Balances] [pallet_timestamp, Timestamp] [pallet_dapps_staking, DappsStaking] diff --git a/runtime/shibuya/src/weights/mod.rs b/runtime/shibuya/src/weights/mod.rs new file mode 100644 index 0000000000..2db3ac12ab --- /dev/null +++ b/runtime/shibuya/src/weights/mod.rs @@ -0,0 +1,19 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +pub mod pallet_assets; diff --git a/runtime/shibuya/src/weights/pallet_assets.rs b/runtime/shibuya/src/weights/pallet_assets.rs new file mode 100644 index 0000000000..676729637e --- /dev/null +++ b/runtime/shibuya/src/weights/pallet_assets.rs @@ -0,0 +1,496 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. 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-08-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("astar-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=astar-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_assets +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/assets_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weights for pallet_assets using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl pallet_assets::WeightInfo for SubstrateWeight { + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:1 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `659` + // Estimated: `4124` + // Minimum execution time: 35_155_000 picoseconds. + Weight::from_parts(35_760_000, 4124) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:1 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn force_create() -> Weight { + // Proof Size summary in bytes: + // Measured: `519` + // Estimated: `3984` + // Minimum execution time: 20_004_000 picoseconds. + Weight::from_parts(20_348_000, 3984) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn start_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_682_000 picoseconds. + Weight::from_parts(14_059_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1001 w:1000) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, 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]`. + fn destroy_accounts(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `255 + c * (208 ±0)` + // Estimated: `3687 + c * (2621 ±0)` + // Minimum execution time: 17_910_000 picoseconds. + Weight::from_parts(18_110_000, 3687) + // Standard Error: 6_525 + .saturating_add(Weight::from_parts(11_623_553, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2621).saturating_mul(c.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1001 w:1000) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + /// The range of component `a` is `[0, 1000]`. + fn destroy_approvals(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `438 + a * (86 ±0)` + // Estimated: `3687 + a * (2635 ±0)` + // Minimum execution time: 18_065_000 picoseconds. + Weight::from_parts(18_372_000, 3687) + // Standard Error: 4_985 + .saturating_add(Weight::from_parts(13_662_720, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 2635).saturating_mul(a.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:0 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn finish_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 16_700_000 picoseconds. + Weight::from_parts(17_418_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 26_305_000 picoseconds. + Weight::from_parts(27_014_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn burn() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 30_525_000 picoseconds. + Weight::from_parts(31_113_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `6232` + // Minimum execution time: 42_955_000 picoseconds. + Weight::from_parts(43_309_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// 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: `447` + // Estimated: `6232` + // Minimum execution time: 37_951_000 picoseconds. + Weight::from_parts(38_330_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn force_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `6232` + // Minimum execution time: 43_061_000 picoseconds. + Weight::from_parts(43_561_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn freeze() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_259_000 picoseconds. + Weight::from_parts(17_516_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn thaw() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_165_000 picoseconds. + Weight::from_parts(17_547_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn freeze_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_634_000 picoseconds. + Weight::from_parts(14_069_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + fn thaw_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_456_000 picoseconds. + Weight::from_parts(13_770_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn transfer_ownership() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 16_083_000 picoseconds. + Weight::from_parts(16_343_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn set_team() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 14_443_000 picoseconds. + Weight::from_parts(14_818_000, 3687) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// 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: `255` + // Estimated: `3687` + // Minimum execution time: 28_260_000 picoseconds. + Weight::from_parts(29_181_263, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `431` + // Estimated: `3687` + // Minimum execution time: 28_580_000 picoseconds. + Weight::from_parts(28_826_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// 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: `94` + // Estimated: `3687` + // Minimum execution time: 14_605_000 picoseconds. + Weight::from_parts(15_107_642, 3687) + // Standard Error: 450 + .saturating_add(Weight::from_parts(6_608, 0).saturating_mul(n.into())) + // Standard Error: 450 + .saturating_add(Weight::from_parts(2_783, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn force_clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `431` + // Estimated: `3687` + // Minimum execution time: 27_925_000 picoseconds. + Weight::from_parts(28_323_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn force_asset_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 13_904_000 picoseconds. + Weight::from_parts(14_431_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn approve_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 31_152_000 picoseconds. + Weight::from_parts(31_715_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer_approved() -> Weight { + // Proof Size summary in bytes: + // Measured: `680` + // Estimated: `6232` + // Minimum execution time: 63_252_000 picoseconds. + Weight::from_parts(63_718_000, 6232) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `471` + // Estimated: `3687` + // Minimum execution time: 34_375_000 picoseconds. + Weight::from_parts(34_640_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn force_cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `471` + // Estimated: `3687` + // Minimum execution time: 34_159_000 picoseconds. + Weight::from_parts(34_693_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn set_min_balance() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 15_114_000 picoseconds. + Weight::from_parts(15_271_000, 3687) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn touch() -> Weight { + // Proof Size summary in bytes: + // Measured: `429` + // Estimated: `3687` + // Minimum execution time: 34_356_000 picoseconds. + Weight::from_parts(34_856_000, 3687) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn touch_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 31_063_000 picoseconds. + Weight::from_parts(31_331_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn refund() -> Weight { + // Proof Size summary in bytes: + // Measured: `567` + // Estimated: `3687` + // Minimum execution time: 31_678_000 picoseconds. + Weight::from_parts(31_941_000, 3687) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn refund_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `426` + // Estimated: `3687` + // Minimum execution time: 28_601_000 picoseconds. + Weight::from_parts(28_966_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn block() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_545_000 picoseconds. + Weight::from_parts(17_959_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 2d3c6e0e4c..b9861b7f2e 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -229,6 +229,7 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "polkadot-runtime/runtime-benchmarks", "astar-primitives/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 6a87d6f7e6..220f1e4bc4 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -68,10 +68,10 @@ use sp_runtime::{ use sp_std::prelude::*; pub use astar_primitives::{ - AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, + evm::EvmRevertCodeHandler, xcm::AssetLocationIdConverter, AccountId, Address, AssetId, Balance, + BlockNumber, Hash, Header, Index, Signature, }; -use astar_primitives::xcm::AssetLocationIdConverter; use pallet_evm_precompile_assets_erc20::AddressToAssetId; #[cfg(any(feature = "std", test))] @@ -85,6 +85,7 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::BuildStorage; mod precompiles; +mod weights; mod xcm_config; pub type ShidenAssetLocationIdConverter = AssetLocationIdConverter; @@ -583,10 +584,12 @@ impl pallet_assets::Config for Runtime { type StringLimit = AssetsStringLimit; type Freezer = (); type Extra = (); - type WeightInfo = pallet_assets::weights::SubstrateWeight; + type WeightInfo = weights::pallet_assets::SubstrateWeight; type RemoveItemsLimit = ConstU32<1000>; type AssetIdParameter = Compact; - type CallbackHandle = (); + type CallbackHandle = EvmRevertCodeHandler; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = astar_primitives::benchmarks::AssetsBenchmarkHelper; } parameter_types! { @@ -822,23 +825,9 @@ impl pallet_sudo::Config for Runtime { type WeightInfo = pallet_sudo::weights::SubstrateWeight; } -pub struct EvmRevertCodeHandler; -impl pallet_xc_asset_config::XcAssetChanged for EvmRevertCodeHandler { - fn xc_asset_registered(asset_id: AssetId) { - let address = Runtime::asset_id_to_address(asset_id); - pallet_evm::AccountCodes::::insert(address, vec![0x60, 0x00, 0x60, 0x00, 0xfd]); - } - - fn xc_asset_unregistered(asset_id: AssetId) { - let address = Runtime::asset_id_to_address(asset_id); - pallet_evm::AccountCodes::::remove(address); - } -} - impl pallet_xc_asset_config::Config for Runtime { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; - type XcAssetChanged = EvmRevertCodeHandler; type ManagerOrigin = EnsureRoot; type WeightInfo = pallet_xc_asset_config::weights::SubstrateWeight; } @@ -1153,6 +1142,7 @@ mod benches { define_benchmarks!( [frame_benchmarking, BaselineBench::] [frame_system, SystemBench::] + [pallet_assets, Assets] [pallet_balances, Balances] [pallet_timestamp, Timestamp] [pallet_dapps_staking, DappsStaking] diff --git a/runtime/shiden/src/weights/mod.rs b/runtime/shiden/src/weights/mod.rs new file mode 100644 index 0000000000..2db3ac12ab --- /dev/null +++ b/runtime/shiden/src/weights/mod.rs @@ -0,0 +1,19 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +pub mod pallet_assets; diff --git a/runtime/shiden/src/weights/pallet_assets.rs b/runtime/shiden/src/weights/pallet_assets.rs new file mode 100644 index 0000000000..676729637e --- /dev/null +++ b/runtime/shiden/src/weights/pallet_assets.rs @@ -0,0 +1,496 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. 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-08-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("astar-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=astar-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_assets +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/assets_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weights for pallet_assets using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl pallet_assets::WeightInfo for SubstrateWeight { + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:1 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `659` + // Estimated: `4124` + // Minimum execution time: 35_155_000 picoseconds. + Weight::from_parts(35_760_000, 4124) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:1 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn force_create() -> Weight { + // Proof Size summary in bytes: + // Measured: `519` + // Estimated: `3984` + // Minimum execution time: 20_004_000 picoseconds. + Weight::from_parts(20_348_000, 3984) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn start_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_682_000 picoseconds. + Weight::from_parts(14_059_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1001 w:1000) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, 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]`. + fn destroy_accounts(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `255 + c * (208 ±0)` + // Estimated: `3687 + c * (2621 ±0)` + // Minimum execution time: 17_910_000 picoseconds. + Weight::from_parts(18_110_000, 3687) + // Standard Error: 6_525 + .saturating_add(Weight::from_parts(11_623_553, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2621).saturating_mul(c.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1001 w:1000) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + /// The range of component `a` is `[0, 1000]`. + fn destroy_approvals(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `438 + a * (86 ±0)` + // Estimated: `3687 + a * (2635 ±0)` + // Minimum execution time: 18_065_000 picoseconds. + Weight::from_parts(18_372_000, 3687) + // Standard Error: 4_985 + .saturating_add(Weight::from_parts(13_662_720, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 2635).saturating_mul(a.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:0 w:1) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + fn finish_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 16_700_000 picoseconds. + Weight::from_parts(17_418_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 26_305_000 picoseconds. + Weight::from_parts(27_014_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn burn() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 30_525_000 picoseconds. + Weight::from_parts(31_113_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `6232` + // Minimum execution time: 42_955_000 picoseconds. + Weight::from_parts(43_309_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// 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: `447` + // Estimated: `6232` + // Minimum execution time: 37_951_000 picoseconds. + Weight::from_parts(38_330_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn force_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `6232` + // Minimum execution time: 43_061_000 picoseconds. + Weight::from_parts(43_561_000, 6232) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn freeze() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_259_000 picoseconds. + Weight::from_parts(17_516_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn thaw() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_165_000 picoseconds. + Weight::from_parts(17_547_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn freeze_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_634_000 picoseconds. + Weight::from_parts(14_069_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + fn thaw_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 13_456_000 picoseconds. + Weight::from_parts(13_770_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn transfer_ownership() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 16_083_000 picoseconds. + Weight::from_parts(16_343_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn set_team() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 14_443_000 picoseconds. + Weight::from_parts(14_818_000, 3687) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// 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: `255` + // Estimated: `3687` + // Minimum execution time: 28_260_000 picoseconds. + Weight::from_parts(29_181_263, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `431` + // Estimated: `3687` + // Minimum execution time: 28_580_000 picoseconds. + Weight::from_parts(28_826_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + /// 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: `94` + // Estimated: `3687` + // Minimum execution time: 14_605_000 picoseconds. + Weight::from_parts(15_107_642, 3687) + // Standard Error: 450 + .saturating_add(Weight::from_parts(6_608, 0).saturating_mul(n.into())) + // Standard Error: 450 + .saturating_add(Weight::from_parts(2_783, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(152), added: 2627, mode: MaxEncodedLen) + fn force_clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `431` + // Estimated: `3687` + // Minimum execution time: 27_925_000 picoseconds. + Weight::from_parts(28_323_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_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(222), added: 2697, mode: MaxEncodedLen) + fn force_asset_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 13_904_000 picoseconds. + Weight::from_parts(14_431_000, 3687) + .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(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn approve_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3687` + // Minimum execution time: 31_152_000 picoseconds. + Weight::from_parts(31_715_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer_approved() -> Weight { + // Proof Size summary in bytes: + // Measured: `680` + // Estimated: `6232` + // Minimum execution time: 63_252_000 picoseconds. + Weight::from_parts(63_718_000, 6232) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `471` + // Estimated: `3687` + // Minimum execution time: 34_375_000 picoseconds. + Weight::from_parts(34_640_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(160), added: 2635, mode: MaxEncodedLen) + fn force_cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `471` + // Estimated: `3687` + // Minimum execution time: 34_159_000 picoseconds. + Weight::from_parts(34_693_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn set_min_balance() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 15_114_000 picoseconds. + Weight::from_parts(15_271_000, 3687) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn touch() -> Weight { + // Proof Size summary in bytes: + // Measured: `429` + // Estimated: `3687` + // Minimum execution time: 34_356_000 picoseconds. + Weight::from_parts(34_856_000, 3687) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn touch_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `255` + // Estimated: `3687` + // Minimum execution time: 31_063_000 picoseconds. + Weight::from_parts(31_331_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn refund() -> Weight { + // Proof Size summary in bytes: + // Measured: `567` + // Estimated: `3687` + // Minimum execution time: 31_678_000 picoseconds. + Weight::from_parts(31_941_000, 3687) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + fn refund_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `426` + // Estimated: `3687` + // Minimum execution time: 28_601_000 picoseconds. + Weight::from_parts(28_966_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(222), added: 2697, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(146), added: 2621, mode: MaxEncodedLen) + fn block() -> Weight { + // Proof Size summary in bytes: + // Measured: `375` + // Estimated: `3687` + // Minimum execution time: 17_545_000 picoseconds. + Weight::from_parts(17_959_000, 3687) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} diff --git a/scripts/templates/weight-template.hbs b/scripts/templates/weight-template.hbs index 0df6bef5d3..1bc7767bd6 100644 --- a/scripts/templates/weight-template.hbs +++ b/scripts/templates/weight-template.hbs @@ -1,4 +1,22 @@ {{header}} +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + //! Autogenerated weights for {{pallet}} //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index 26ca026e01..834f6dd902 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -17,6 +17,7 @@ pallet-evm = { workspace = true } # frame dependencies frame-support = { workspace = true } frame-system = { workspace = true } +pallet-assets = { workspace = true } pallet-balances = { workspace = true } pallet-contracts = { workspace = true } pallet-contracts-primitives = { workspace = true } @@ -29,6 +30,7 @@ sp-runtime = { workspace = true } # astar dependencies pallet-ethereum-checked = { workspace = true } +pallet-evm-precompile-assets-erc20 = { workspace = true } astar-primitives = { workspace = true } astar-runtime = { workspace = true, features = ["std"], optional = true } diff --git a/tests/integration/src/assets.rs b/tests/integration/src/assets.rs new file mode 100644 index 0000000000..7deb49e18d --- /dev/null +++ b/tests/integration/src/assets.rs @@ -0,0 +1,81 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +use crate::setup::*; + +use astar_primitives::evm::EVM_REVERT_CODE; +use pallet_evm_precompile_assets_erc20::AddressToAssetId; + +#[test] +fn asset_create_and_destroy_work_for_evm_revert_code() { + new_test_ext().execute_with(|| { + let asset_id = 19; + let precompile_address = Runtime::asset_id_to_address(asset_id); + + // Asset creation results in insertion of the revert opt code at the precompile address + assert!( + !pallet_evm::AccountCodes::::contains_key(&precompile_address), + "Precompile address should be empty." + ); + assert_ok!(Assets::create( + RuntimeOrigin::signed(ALICE), + asset_id.into(), + ALICE.into(), + 1, + )); + assert_eq!( + pallet_evm::AccountCodes::::get(&precompile_address), + EVM_REVERT_CODE.to_vec(), + "Precompile address should contain the revert code." + ); + + // Asset destroy results in removal of the revert opt code from the precompile address + assert_ok!(Assets::start_destroy( + RuntimeOrigin::signed(ALICE), + asset_id.into(), + )); + assert_ok!(Assets::finish_destroy( + RuntimeOrigin::signed(ALICE), + asset_id.into(), + )); + assert!( + !pallet_evm::AccountCodes::::contains_key(&precompile_address), + "After asset is destroyed, precompile address should be empty." + ); + }); +} + +#[test] +fn asset_create_fails_if_account_code_is_non_empty() { + new_test_ext().execute_with(|| { + let asset_id = 19; + let precompile_address = Runtime::asset_id_to_address(asset_id); + + // Asset registration must fail if the precompile address is not empty + pallet_evm::AccountCodes::::insert(&precompile_address, EVM_REVERT_CODE.to_vec()); + assert_noop!( + Assets::create( + RuntimeOrigin::signed(ALICE), + asset_id.into(), + ALICE.into(), + 1, + ), + pallet_assets::Error::::CallbackFailed + ); + }); +} diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index 6b01e7cf77..c36fc93edc 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -26,5 +26,8 @@ mod setup; #[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))] mod proxy; +#[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))] +mod assets; + #[cfg(feature = "shibuya")] mod xvm; diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 3407614818..594ca745b0 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -19,7 +19,7 @@ //! Runtime integration tests setup & imports. pub use frame_support::{ - assert_ok, + assert_noop, assert_ok, traits::{OnFinalize, OnIdle, OnInitialize}, weights::Weight, }; diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 8be1841ff6..0c00aa5d48 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -156,6 +156,8 @@ impl pallet_assets::Config for Runtime { type RemoveItemsLimit = ConstU32<100>; type CallbackHandle = (); type WeightInfo = pallet_assets::weights::SubstrateWeight; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } impl pallet_timestamp::Config for Runtime { @@ -391,7 +393,6 @@ parameter_types! { impl pallet_xc_asset_config::Config for Runtime { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; - type XcAssetChanged = (); type ManagerOrigin = EnsureRoot; type WeightInfo = pallet_xc_asset_config::weights::SubstrateWeight; }