Added Asset Conversion in Kusama (#2935)

* Changes for asset conversion in ksm

* applied changes to forbid batch calls in xcm filters for ksm and wnd, fixed tests typing, cleaned up

* updated weights for pallet_asset_conversion in ksm

* updated swap_locally_on_chain_using_local_assets test

* added more call filters, approval deposit fix

* Update parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs

* Update tests to be like master

* set metadata needed for the test.

* Update parachains/runtimes/assets/asset-hub-kusama/src/lib.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update parachains/runtimes/assets/asset-hub-kusama/src/lib.rs

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* removed hardcoded existential_deposit in local swap test

* storage to const

We're not planning on setting this via an on chain vote so let's have it as a const.

* unneeded tests

* const

* shorter line

* missed one

* remove unused import

* Update parachains/runtimes/assets/asset-hub-kusama/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

---------

Co-authored-by: joepetrowski <joe@parity.io>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Pato
2023-08-19 11:24:32 -03:00
committed by GitHub
parent 3288148aa7
commit 8bd3aec7cf
17 changed files with 1461 additions and 201 deletions
+6 -1
View File
@@ -561,12 +561,15 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"
name = "asset-hub-kusama-integration-tests"
version = "1.0.0"
dependencies = [
"assert_matches",
"asset-hub-kusama-runtime",
"cumulus-pallet-dmp-queue",
"cumulus-pallet-parachain-system",
"cumulus-pallet-xcmp-queue",
"frame-support",
"frame-system",
"integration-tests-common",
"pallet-asset-conversion",
"pallet-assets",
"pallet-balances",
"pallet-xcm",
@@ -608,7 +611,8 @@ dependencies = [
"hex-literal",
"kusama-runtime-constants",
"log",
"pallet-asset-tx-payment",
"pallet-asset-conversion",
"pallet-asset-conversion-tx-payment",
"pallet-assets",
"pallet-aura",
"pallet-authorship",
@@ -634,6 +638,7 @@ dependencies = [
"polkadot-core-primitives",
"polkadot-parachain",
"polkadot-runtime-common",
"primitive-types",
"scale-info",
"smallvec",
"sp-api",
@@ -7,6 +7,7 @@ description = "Asset Hub Kusama runtime integration tests with xcm-emulator"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }
assert_matches = "1.5.0"
# Substrate
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -16,6 +17,7 @@ sp-core = { default-features = false, git = "https://github.com/paritytech/subst
sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-asset-conversion = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
# Polkadot
polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
@@ -28,6 +30,7 @@ pallet-xcm = { default-features = false, git = "https://github.com/paritytech/po
# Cumulus
parachains-common = { path = "../../../../common" }
asset-hub-kusama-runtime = { path = "../../../../runtimes/assets/asset-hub-kusama" }
cumulus-pallet-dmp-queue = { path = "../../../../../pallets/dmp-queue" }
cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../pallets/xcmp-queue" }
cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" }
@@ -30,7 +30,7 @@ pub use integration_tests_common::{
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
},
lazy_static::lazy_static,
xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubKusama,
xcm_transact_paid_execution, xcm_transact_unpaid_execution, AccountId, AssetHubKusama,
AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, BridgeHubKusama,
BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot,
BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Collectives,
@@ -40,7 +40,7 @@ pub use integration_tests_common::{
PenpalKusamaBSender, PenpalPolkadotA, PenpalPolkadotAReceiver, PenpalPolkadotASender, Polkadot,
PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender,
};
pub use parachains_common::{AccountId, Balance};
pub use parachains_common::Balance;
pub use polkadot_core_primitives::InboundDownwardMessage;
pub use polkadot_parachain::primitives::{HrmpChannelId, Id};
pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId};
@@ -18,4 +18,5 @@ mod hrmp_channels;
mod reserve_transfer;
mod send;
mod set_xcm_versions;
mod swap;
mod teleport;
@@ -0,0 +1,351 @@
use crate::*;
use asset_hub_kusama_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
use frame_support::{instances::Instance2, BoundedVec};
use sp_runtime::{DispatchError, ModuleError};
#[test]
fn swap_locally_on_chain_using_local_assets() {
let asset_native = Box::new(asset_hub_kusama_runtime::xcm_config::KsmLocation::get());
let asset_one = Box::new(MultiLocation {
parents: 0,
interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())),
});
AssetHubKusama::execute_with(|| {
type RuntimeEvent = <AssetHubKusama as Chain>::RuntimeEvent;
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::Assets::create(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
ASSET_ID.into(),
AssetHubKusamaSender::get().into(),
1000,
));
assert!(<AssetHubKusama as AssetHubKusamaPallet>::Assets::asset_exists(ASSET_ID));
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::Assets::mint(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
ASSET_ID.into(),
AssetHubKusamaSender::get().into(),
100_000_000_000_000,
));
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::Balances::force_set_balance(
<AssetHubKusama as Chain>::RuntimeOrigin::root(),
AssetHubKusamaSender::get().into(),
100_000_000_000_000,
));
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::create_pool(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
asset_native.clone(),
asset_one.clone(),
));
assert_expected_events!(
AssetHubKusama,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {},
]
);
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::add_liquidity(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
asset_native.clone(),
asset_one.clone(),
1_000_000_000_000,
2_000_000_000_000,
0,
0,
AssetHubKusamaSender::get().into()
));
assert_expected_events!(
AssetHubKusama,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {lp_token_minted, .. }) => { lp_token_minted: *lp_token_minted == 1414213562273, },
]
);
let path = BoundedVec::<_, _>::truncate_from(vec![asset_native.clone(), asset_one.clone()]);
assert_ok!(
<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::swap_exact_tokens_for_tokens(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
path,
100,
1,
AssetHubKusamaSender::get().into(),
true
)
);
assert_expected_events!(
AssetHubKusama,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. }) => {
amount_in: *amount_in == 100,
amount_out: *amount_out == 199,
},
]
);
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::remove_liquidity(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
asset_native,
asset_one,
1414213562273 - EXISTENTIAL_DEPOSIT * 2, // all but the 2 EDs can't be retrieved.
0,
0,
AssetHubKusamaSender::get().into(),
));
});
}
#[test]
fn swap_locally_on_chain_using_foreign_assets() {
use frame_support::weights::WeightToFee;
let asset_native = Box::new(asset_hub_kusama_runtime::xcm_config::KsmLocation::get());
let foreign_asset1_at_asset_hub_kusama = Box::new(MultiLocation {
parents: 1,
interior: X3(
Parachain(PenpalKusamaA::para_id().into()),
PalletInstance(ASSETS_PALLET_ID),
GeneralIndex(ASSET_ID.into()),
),
});
let assets_para_destination: VersionedMultiLocation =
MultiLocation { parents: 1, interior: X1(Parachain(AssetHubKusama::para_id().into())) }
.into();
let penpal_location =
MultiLocation { parents: 1, interior: X1(Parachain(PenpalKusamaA::para_id().into())) };
// 1. Create asset on penpal:
PenpalKusamaA::execute_with(|| {
assert_ok!(<PenpalKusamaA as PenpalKusamaAPallet>::Assets::create(
<PenpalKusamaA as Chain>::RuntimeOrigin::signed(PenpalKusamaASender::get()),
ASSET_ID.into(),
PenpalKusamaASender::get().into(),
1000,
));
assert!(<PenpalKusamaA as PenpalKusamaAPallet>::Assets::asset_exists(ASSET_ID));
});
// 2. Create foreign asset on asset_hub_kusama:
let require_weight_at_most = Weight::from_parts(1_100_000_000_000, 30_000);
let origin_kind = OriginKind::Xcm;
let sov_penpal_on_asset_hub_kusama = AssetHubKusama::sovereign_account_id_of(penpal_location);
AssetHubKusama::fund_accounts(vec![
(AssetHubKusamaSender::get().into(), 5_000_000 * KUSAMA_ED), /* An account to swap dot
* for something else. */
(sov_penpal_on_asset_hub_kusama.clone().into(), 1000_000_000_000_000_000 * KUSAMA_ED),
]);
let sov_penpal_on_asset_hub_kusama_as_location: MultiLocation = MultiLocation {
parents: 0,
interior: X1(AccountId32Junction {
network: None,
id: sov_penpal_on_asset_hub_kusama.clone().into(),
}),
};
let call_foreign_assets_create =
<AssetHubKusama as Chain>::RuntimeCall::ForeignAssets(pallet_assets::Call::<
<AssetHubKusama as Chain>::Runtime,
Instance2,
>::create {
id: *foreign_asset1_at_asset_hub_kusama,
min_balance: 1000,
admin: sov_penpal_on_asset_hub_kusama.clone().into(),
})
.encode()
.into();
let buy_execution_fee_amount =
asset_hub_kusama_runtime::constants::fee::WeightToFee::weight_to_fee(&Weight::from_parts(
10_100_000_000_000,
300_000,
));
let buy_execution_fee = MultiAsset {
id: Concrete(MultiLocation { parents: 1, interior: Here }),
fun: Fungible(buy_execution_fee_amount),
};
let xcm = VersionedXcm::from(Xcm(vec![
WithdrawAsset { 0: vec![buy_execution_fee.clone()].into() },
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
Transact { require_weight_at_most, origin_kind, call: call_foreign_assets_create },
RefundSurplus,
DepositAsset {
assets: All.into(),
beneficiary: sov_penpal_on_asset_hub_kusama_as_location,
},
]));
// Send XCM message from penpal => asset_hub_kusama
let sudo_penpal_origin = <PenpalKusamaA as Chain>::RuntimeOrigin::root();
PenpalKusamaA::execute_with(|| {
assert_ok!(<PenpalKusamaA as PenpalKusamaAPallet>::PolkadotXcm::send(
sudo_penpal_origin.clone(),
bx!(assets_para_destination.clone()),
bx!(xcm),
));
type RuntimeEvent = <PenpalKusamaA as Chain>::RuntimeEvent;
assert_expected_events!(
PenpalKusamaA,
vec![
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {},
]
);
});
// Receive XCM message in Assets Parachain
AssetHubKusama::execute_with(|| {
assert!(<AssetHubKusama as AssetHubKusamaPallet>::ForeignAssets::asset_exists(
*foreign_asset1_at_asset_hub_kusama
));
// 3: Mint foreign asset on asset_hub_kusama:
//
// (While it might be nice to use batch,
// currently that's disabled due to safe call filters.)
type RuntimeEvent = <AssetHubKusama as Chain>::RuntimeEvent;
// 3. Mint foreign asset (in reality this should be a teleport or some such)
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::ForeignAssets::mint(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(
sov_penpal_on_asset_hub_kusama.clone().into()
),
*foreign_asset1_at_asset_hub_kusama,
sov_penpal_on_asset_hub_kusama.clone().into(),
3_000_000_000_000,
));
assert_expected_events!(
AssetHubKusama,
vec![
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
]
);
// 4. Create pool:
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::create_pool(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
asset_native.clone(),
foreign_asset1_at_asset_hub_kusama.clone(),
));
assert_expected_events!(
AssetHubKusama,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {},
]
);
// 5. Add liquidity:
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::add_liquidity(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(
sov_penpal_on_asset_hub_kusama.clone()
),
asset_native.clone(),
foreign_asset1_at_asset_hub_kusama.clone(),
1_000_000_000_000,
2_000_000_000_000,
0,
0,
sov_penpal_on_asset_hub_kusama.clone().into()
));
assert_expected_events!(
AssetHubKusama,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {lp_token_minted, .. }) => {
lp_token_minted: *lp_token_minted == 1414213562273,
},
]
);
// 6. Swap!
let path = BoundedVec::<_, _>::truncate_from(vec![
asset_native.clone(),
foreign_asset1_at_asset_hub_kusama.clone(),
]);
assert_ok!(
<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::swap_exact_tokens_for_tokens(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
path,
100000,
1000,
AssetHubKusamaSender::get().into(),
true
)
);
assert_expected_events!(
AssetHubKusama,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. },) => {
amount_in: *amount_in == 100000,
amount_out: *amount_out == 199399,
},
]
);
// 7. Remove liquidity
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::remove_liquidity(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(
sov_penpal_on_asset_hub_kusama.clone()
),
asset_native,
foreign_asset1_at_asset_hub_kusama,
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
0,
0,
sov_penpal_on_asset_hub_kusama.clone().into(),
));
});
}
#[test]
fn cannot_create_pool_from_pool_assets() {
let asset_native = Box::new(asset_hub_kusama_runtime::xcm_config::KsmLocation::get());
let mut asset_one = asset_hub_kusama_runtime::xcm_config::PoolAssetsPalletLocation::get();
asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets");
AssetHubKusama::execute_with(|| {
let pool_owner_account_id = asset_hub_kusama_runtime::AssetConversionOrigin::get();
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::PoolAssets::create(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(pool_owner_account_id.clone()),
ASSET_ID.into(),
pool_owner_account_id.clone().into(),
1000,
));
assert!(<AssetHubKusama as AssetHubKusamaPallet>::PoolAssets::asset_exists(ASSET_ID));
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::PoolAssets::mint(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(pool_owner_account_id),
ASSET_ID.into(),
AssetHubKusamaSender::get().into(),
3_000_000_000_000,
));
assert_matches::assert_matches!(
<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::create_pool(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
asset_native.clone(),
Box::new(asset_one),
),
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("UnsupportedAsset"))
);
});
}
@@ -219,7 +219,9 @@ decl_test_parachains! {
pallets = {
PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm,
Assets: asset_hub_kusama_runtime::Assets,
ForeignAssets: asset_hub_kusama_runtime::Assets,
ForeignAssets: asset_hub_kusama_runtime::ForeignAssets,
PoolAssets: asset_hub_kusama_runtime::PoolAssets,
AssetConversion: asset_hub_kusama_runtime::AssetConversion,
Balances: asset_hub_kusama_runtime::Balances,
}
},
@@ -20,8 +20,9 @@ frame-system = { git = "https://github.com/paritytech/substrate", default-featur
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "master" }
pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-asset-conversion-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-asset-conversion = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -49,6 +50,8 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-weights = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
# num-traits feature needed for dex integer sq root:
primitive-types = { version = "0.12.1", default-features = false, features = ["codec", "scale-info", "num-traits"] }
# Polkadot
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
@@ -99,6 +102,7 @@ runtime-benchmarks = [
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-asset-conversion/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-nft-fractionalization/runtime-benchmarks",
@@ -127,8 +131,9 @@ try-runtime = [
"frame-executive/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-asset-tx-payment/try-runtime",
"pallet-asset-conversion-tx-payment/try-runtime",
"pallet-assets/try-runtime",
"pallet-asset-conversion/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
@@ -155,8 +160,9 @@ std = [
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"kusama-runtime-constants/std",
"pallet-asset-tx-payment/std",
"pallet-asset-conversion-tx-payment/std",
"pallet-assets/std",
"pallet-asset-conversion/std",
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
@@ -29,16 +29,19 @@ mod weights;
pub mod xcm_config;
use assets_common::{
foreign_creators::ForeignCreators, matching::FromSiblingParachain, MultiLocationForAssetId,
foreign_creators::ForeignCreators,
local_and_foreign_assets::{LocalAndForeignAssets, MultiLocationConverter},
matching::FromSiblingParachain,
AssetIdForTrustBackedAssetsConvert, MultiLocationForAssetId,
};
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Verify},
traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Verify},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
ApplyExtrinsicResult, Permill,
};
use sp_std::prelude::*;
@@ -51,9 +54,9 @@ use constants::{consensus::*, currency::*, fee::WeightToFee};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
parameter_types,
ord_parameter_types, parameter_types,
traits::{
AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse,
AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, EitherOfDiverse,
InstanceFilter,
},
weights::{ConstantMultiplier, Weight},
@@ -61,19 +64,20 @@ use frame_support::{
};
use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot, EnsureSigned,
EnsureRoot, EnsureSigned, EnsureSignedBy,
};
use pallet_asset_conversion_tx_payment::AssetConversionAdapter;
use pallet_nfts::PalletFeatures;
pub use parachains_common as common;
use parachains_common::{
impls::{AssetsToBlockAuthor, DealWithFees},
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, Hash, Header, Nonce,
Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT,
impls::DealWithFees, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber,
Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT,
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use xcm::opaque::v3::MultiLocation;
use xcm_config::{
FellowshipLocation, ForeignAssetsConvertedConcreteId, GovernanceLocation, KsmLocation,
TrustBackedAssetsConvertedConcreteId, XcmConfig,
PoolAssetsConvertedConcreteId, TrustBackedAssetsConvertedConcreteId, XcmConfig,
};
#[cfg(any(feature = "std", test))]
@@ -85,7 +89,10 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use xcm::latest::BodyId;
use xcm_executor::XcmExecutor;
use crate::xcm_config::ForeignCreatorsSovereignAccountOf;
use crate::xcm_config::{
ForeignCreatorsSovereignAccountOf, LocalAndForeignAssetsMultiLocationMatcher,
TrustBackedAssetsPalletLocation,
};
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
impl_opaque_keys! {
@@ -278,6 +285,76 @@ impl pallet_assets::Config<TrustBackedAssetsInstance> for Runtime {
type BenchmarkHelper = ();
}
parameter_types! {
pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
pub const AllowMultiAssetPools: bool = false;
// should be non-zero if AllowMultiAssetPools is true, otherwise can be zero
pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
}
ord_parameter_types! {
pub const AssetConversionOrigin: sp_runtime::AccountId32 =
AccountIdConversion::<sp_runtime::AccountId32>::into_account_truncating(&AssetConversionPalletId::get());
}
pub type PoolAssetsInstance = pallet_assets::Instance3;
impl pallet_assets::Config<PoolAssetsInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type RemoveItemsLimit = ConstU32<1000>;
type AssetId = u32;
type AssetIdParameter = u32;
type Currency = Balances;
type CreateOrigin =
AsEnsureOriginWithArg<EnsureSignedBy<AssetConversionOrigin, sp_runtime::AccountId32>>;
type ForceOrigin = AssetsForceOrigin;
// Deposits are zero because creation/admin is limited to Asset Conversion pallet.
type AssetDeposit = ConstU128<0>;
type AssetAccountDeposit = ConstU128<0>;
type MetadataDepositBase = ConstU128<0>;
type MetadataDepositPerByte = ConstU128<0>;
type ApprovalDeposit = ApprovalDeposit;
type StringLimit = ConstU32<50>;
type Freezer = ();
type Extra = ();
type WeightInfo = weights::pallet_assets_pool::WeightInfo<Runtime>;
type CallbackHandle = ();
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}
impl pallet_asset_conversion::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type HigherPrecisionBalance = sp_core::U256;
type Currency = Balances;
type AssetBalance = Balance;
type AssetId = MultiLocation;
type Assets = LocalAndForeignAssets<
Assets,
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>,
ForeignAssets,
>;
type PoolAssets = PoolAssets;
type PoolAssetId = u32;
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
type PoolSetupFeeReceiver = AssetConversionOrigin;
// should be non-zero if `AllowMultiAssetPools` is true, otherwise can be zero.
type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
type LPFee = ConstU32<3>;
type PalletId = AssetConversionPalletId;
type AllowMultiAssetPools = AllowMultiAssetPools;
type MaxSwapPathLength = ConstU32<4>;
type MultiAssetId = Box<MultiLocation>;
type MultiAssetIdConverter =
MultiLocationConverter<KsmLocation, LocalAndForeignAssetsMultiLocationMatcher>;
type MintMinLiquidity = ConstU128<100>;
type WeightInfo = weights::pallet_asset_conversion::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper =
crate::xcm_config::BenchmarkMultiLocationConverter<parachain_info::Pallet<Runtime>>;
}
parameter_types! {
// we just reuse the same deposits
pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
@@ -630,18 +707,14 @@ impl pallet_collator_selection::Config for Runtime {
type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
}
impl pallet_asset_tx_payment::Config for Runtime {
impl pallet_asset_conversion_tx_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Fungibles = Assets;
type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter<
pallet_assets::BalanceToAssetBalance<
Balances,
Runtime,
ConvertInto,
TrustBackedAssetsInstance,
>,
AssetsToBlockAuthor<Runtime, TrustBackedAssetsInstance>,
type Fungibles = LocalAndForeignAssets<
Assets,
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>,
ForeignAssets,
>;
type OnChargeAssetTransaction = AssetConversionAdapter<Balances, AssetConversion>;
}
parameter_types! {
@@ -755,7 +828,7 @@ construct_runtime!(
// Monetary stuff.
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 10,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>} = 11,
AssetTxPayment: pallet_asset_tx_payment::{Pallet, Event<T>} = 12,
AssetTxPayment: pallet_asset_conversion_tx_payment::{Pallet, Event<T>} = 13,
// Collator support. the order of these 5 are important and shall not change.
Authorship: pallet_authorship::{Pallet, Storage} = 20,
@@ -782,6 +855,9 @@ construct_runtime!(
ForeignAssets: pallet_assets::<Instance2>::{Pallet, Call, Storage, Event<T>} = 53,
NftFractionalization: pallet_nft_fractionalization::{Pallet, Call, Storage, Event<T>, HoldReason} = 54,
PoolAssets: pallet_assets::<Instance3>::{Pallet, Call, Storage, Event<T>} = 55,
AssetConversion: pallet_asset_conversion::{Pallet, Call, Storage, Event<T>} = 56,
#[cfg(feature = "state-trie-version-1")]
StateTrieMigration: pallet_state_trie_migration = 70,
}
@@ -804,7 +880,7 @@ pub type SignedExtra = (
frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_asset_tx_payment::ChargeAssetTxPayment<Runtime>,
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
@@ -832,6 +908,8 @@ mod benches {
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Local]
[pallet_assets, Foreign]
[pallet_assets, Pool]
[pallet_asset_conversion, AssetConversion]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[pallet_nft_fractionalization, NftFractionalization]
@@ -945,6 +1023,24 @@ impl_runtime_apis! {
}
}
impl pallet_asset_conversion::AssetConversionApi<
Block,
Balance,
u128,
Box<MultiLocation>,
> for Runtime
{
fn quote_price_exact_tokens_for_tokens(asset1: Box<MultiLocation>, asset2: Box<MultiLocation>, amount: u128, include_fee: bool) -> Option<Balance> {
AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
}
fn quote_price_tokens_for_exact_tokens(asset1: Box<MultiLocation>, asset2: Box<MultiLocation>, amount: u128, include_fee: bool) -> Option<Balance> {
AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
}
fn get_reserves(asset1: Box<MultiLocation>, asset2: Box<MultiLocation>) -> Option<(Balance, Balance)> {
AssetConversion::get_reserves(&asset1, &asset2).ok()
}
}
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
fn query_info(
uxt: <Block as BlockT>::Extrinsic,
@@ -1014,7 +1110,13 @@ impl_runtime_apis! {
)?,
// collect pallet_assets (ForeignAssets)
convert::<_, _, _, _, ForeignAssetsConvertedConcreteId>(
ForeignAssets::account_balances(account)
ForeignAssets::account_balances(account.clone())
.iter()
.filter(|(_, balance)| balance > &0)
)?,
// collect pallet_assets (PoolAssets)
convert::<_, _, _, _, PoolAssetsConvertedConcreteId>(
PoolAssets::account_balances(account)
.iter()
.filter(|(_, balance)| balance > &0)
)?,
@@ -1071,6 +1173,7 @@ impl_runtime_apis! {
// `pallet_assets_local.rs / pallet_assets_foreign.rs`.
type Local = pallet_assets::Pallet::<Runtime, TrustBackedAssetsInstance>;
type Foreign = pallet_assets::Pallet::<Runtime, ForeignAssetsInstance>;
type Pool = pallet_assets::Pallet::<Runtime, PoolAssetsInstance>;
let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
@@ -1082,8 +1185,7 @@ impl_runtime_apis! {
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError,
TrackedStorageKey};
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError};
use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {
@@ -1210,6 +1312,7 @@ impl_runtime_apis! {
type Local = pallet_assets::Pallet::<Runtime, TrustBackedAssetsInstance>;
type Foreign = pallet_assets::Pallet::<Runtime, ForeignAssetsInstance>;
type Pool = pallet_assets::Pallet::<Runtime, PoolAssetsInstance>;
let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
@@ -2,8 +2,10 @@ pub mod block_weights;
pub mod cumulus_pallet_xcmp_queue;
pub mod extrinsic_weights;
pub mod frame_system;
pub mod pallet_asset_conversion;
pub mod pallet_assets_foreign;
pub mod pallet_assets_local;
pub mod pallet_assets_pool;
pub mod pallet_balances;
pub mod pallet_collator_selection;
pub mod pallet_multisig;
@@ -0,0 +1,155 @@
// Copyright Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_asset_conversion`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-07-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-kusama-dev")`, DB CACHE: 1024
// Executed Command:
// target/production/polkadot-parachain
// benchmark
// pallet
// --steps=50
// --repeat=20
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/cumulus/.git/.artifacts/bench.json
// --pallet=pallet_asset_conversion
// --chain=asset-hub-kusama-dev
// --header=./file_header.txt
// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_asset_conversion`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_asset_conversion::WeightInfo for WeightInfo<T> {
/// Storage: `AssetConversion::Pools` (r:1 w:1)
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(1224), added: 3699, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x76a2c49709deec21d9c05f96c1f47351` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x76a2c49709deec21d9c05f96c1f47351` (r:1 w:0)
/// Storage: `System::Account` (r:2 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:1 w:1)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `AssetConversion::NextPoolAssetId` (r:1 w:1)
/// Proof: `AssetConversion::NextPoolAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn create_pool() -> Weight {
// Proof Size summary in bytes:
// Measured: `480`
// Estimated: `6196`
// Minimum execution time: 88_484_000 picoseconds.
Weight::from_parts(92_964_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(7))
}
/// Storage: `AssetConversion::Pools` (r:1 w:0)
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(1224), added: 3699, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:2 w:2)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:2 w:2)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn add_liquidity() -> Weight {
// Proof Size summary in bytes:
// Measured: `1117`
// Estimated: `7404`
// Minimum execution time: 153_015_000 picoseconds.
Weight::from_parts(157_018_000, 0)
.saturating_add(Weight::from_parts(0, 7404))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(7))
}
/// Storage: `AssetConversion::Pools` (r:1 w:0)
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(1224), added: 3699, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:2 w:2)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x2433d831722b1f4aeb1666953f1c0e77` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x2433d831722b1f4aeb1666953f1c0e77` (r:1 w:0)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn remove_liquidity() -> Weight {
// Proof Size summary in bytes:
// Measured: `1106`
// Estimated: `7404`
// Minimum execution time: 141_726_000 picoseconds.
Weight::from_parts(147_865_000, 0)
.saturating_add(Weight::from_parts(0, 7404))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(6))
}
/// Storage: `ForeignAssets::Asset` (r:2 w:2)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:4 w:4)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn swap_exact_tokens_for_tokens() -> Weight {
// Proof Size summary in bytes:
// Measured: `1148`
// Estimated: `13818`
// Minimum execution time: 168_619_000 picoseconds.
Weight::from_parts(174_283_000, 0)
.saturating_add(Weight::from_parts(0, 13818))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(8))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Asset` (r:2 w:2)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:4 w:4)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
fn swap_tokens_for_exact_tokens() -> Weight {
// Proof Size summary in bytes:
// Measured: `1148`
// Estimated: `13818`
// Minimum execution time: 171_565_000 picoseconds.
Weight::from_parts(173_702_000, 0)
.saturating_add(Weight::from_parts(0, 13818))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(8))
}
}
@@ -17,7 +17,7 @@
//! Autogenerated weights for `pallet_assets`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-06-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-kusama-dev")`, DB CACHE: 1024
@@ -26,8 +26,13 @@
// ./target/production/polkadot-parachain
// benchmark
// pallet
// --chain=asset-hub-kusama-dev
// --steps=50
// --repeat=20
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
// --pallet=pallet_assets
// --no-storage-info
// --no-median-slopes
@@ -60,8 +65,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `107`
// Estimated: `4273`
// Minimum execution time: 30_100_000 picoseconds.
Weight::from_parts(30_644_000, 0)
// Minimum execution time: 30_485_000 picoseconds.
Weight::from_parts(31_007_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
@@ -72,8 +77,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `4273`
// Minimum execution time: 12_815_000 picoseconds.
Weight::from_parts(13_088_000, 0)
// Minimum execution time: 12_991_000 picoseconds.
Weight::from_parts(13_304_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -84,50 +89,50 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `276`
// Estimated: `4273`
// Minimum execution time: 15_186_000 picoseconds.
Weight::from_parts(15_663_000, 0)
// Minimum execution time: 15_689_000 picoseconds.
Weight::from_parts(16_063_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:1001 w:1000)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1000 w:1000)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: ForeignAssets Asset (r:1 w:1)
/// Proof: ForeignAssets Asset (max_values: None, max_size: Some(808), added: 3283, mode: MaxEncodedLen)
/// Storage: ForeignAssets Account (r:1001 w:1000)
/// Proof: ForeignAssets Account (max_values: None, max_size: Some(732), added: 3207, mode: MaxEncodedLen)
/// Storage: System Account (r:1000 w:1000)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// The range of component `c` is `[0, 1000]`.
/// The range of component `c` is `[0, 1000]`.
fn destroy_accounts(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + c * (208 ±0)`
// Estimated: `4273 + c * (3207 ±0)`
// Minimum execution time: 17_916_000 picoseconds.
Weight::from_parts(18_252_000, 0)
// Minimum execution time: 18_533_000 picoseconds.
Weight::from_parts(18_791_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
// Standard Error: 8_609
.saturating_add(Weight::from_parts(15_462_880, 0).saturating_mul(c.into()))
// Standard Error: 5_059
.saturating_add(Weight::from_parts(12_049_659, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_parts(0, 3207).saturating_mul(c.into()))
}
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Approvals` (r:1001 w:1000)
/// Proof: `ForeignAssets::Approvals` (`max_values`: None, `max_size`: Some(746), added: 3221, mode: `MaxEncodedLen`)
/// Storage: ForeignAssets Asset (r:1 w:1)
/// Proof: ForeignAssets Asset (max_values: None, max_size: Some(808), added: 3283, mode: MaxEncodedLen)
/// Storage: ForeignAssets Approvals (r:1001 w:1000)
/// Proof: ForeignAssets Approvals (max_values: None, max_size: Some(746), added: 3221, mode: MaxEncodedLen)
/// The range of component `a` is `[0, 1000]`.
/// The range of component `a` is `[0, 1000]`.
fn destroy_approvals(a: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `413 + a * (86 ±0)`
// Estimated: `4273 + a * (3221 ±0)`
// Minimum execution time: 18_610_000 picoseconds.
Weight::from_parts(19_231_000, 0)
// Minimum execution time: 20_028_000 picoseconds.
Weight::from_parts(20_148_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
// Standard Error: 4_798
.saturating_add(Weight::from_parts(15_618_410, 0).saturating_mul(a.into()))
// Standard Error: 3_401
.saturating_add(Weight::from_parts(13_897_319, 0).saturating_mul(a.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into())))
.saturating_add(T::DbWeight::get().writes(1))
@@ -142,8 +147,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `4273`
// Minimum execution time: 15_414_000 picoseconds.
Weight::from_parts(16_091_000, 0)
// Minimum execution time: 15_949_000 picoseconds.
Weight::from_parts(16_241_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -156,8 +161,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `4273`
// Minimum execution time: 26_573_000 picoseconds.
Weight::from_parts(27_130_000, 0)
// Minimum execution time: 27_156_000 picoseconds.
Weight::from_parts(28_182_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -170,8 +175,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `350`
// Estimated: `4273`
// Minimum execution time: 33_847_000 picoseconds.
Weight::from_parts(34_528_000, 0)
// Minimum execution time: 33_503_000 picoseconds.
Weight::from_parts(33_860_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -186,8 +191,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `350`
// Estimated: `7404`
// Minimum execution time: 46_003_000 picoseconds.
Weight::from_parts(47_122_000, 0)
// Minimum execution time: 45_065_000 picoseconds.
Weight::from_parts(45_856_000, 0)
.saturating_add(Weight::from_parts(0, 7404))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
@@ -202,8 +207,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `350`
// Estimated: `7404`
// Minimum execution time: 40_731_000 picoseconds.
Weight::from_parts(41_847_000, 0)
// Minimum execution time: 39_913_000 picoseconds.
Weight::from_parts(40_791_000, 0)
.saturating_add(Weight::from_parts(0, 7404))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
@@ -218,8 +223,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `350`
// Estimated: `7404`
// Minimum execution time: 45_662_000 picoseconds.
Weight::from_parts(47_432_000, 0)
// Minimum execution time: 45_337_000 picoseconds.
Weight::from_parts(45_980_000, 0)
.saturating_add(Weight::from_parts(0, 7404))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
@@ -232,8 +237,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `350`
// Estimated: `4273`
// Minimum execution time: 18_673_000 picoseconds.
Weight::from_parts(19_209_000, 0)
// Minimum execution time: 19_012_000 picoseconds.
Weight::from_parts(19_326_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -246,8 +251,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `350`
// Estimated: `4273`
// Minimum execution time: 18_636_000 picoseconds.
Weight::from_parts(19_556_000, 0)
// Minimum execution time: 18_656_000 picoseconds.
Weight::from_parts(19_205_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -258,8 +263,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `276`
// Estimated: `4273`
// Minimum execution time: 14_685_000 picoseconds.
Weight::from_parts(15_276_000, 0)
// Minimum execution time: 15_440_000 picoseconds.
Weight::from_parts(15_825_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -270,8 +275,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `276`
// Estimated: `4273`
// Minimum execution time: 14_399_000 picoseconds.
Weight::from_parts(14_880_000, 0)
// Minimum execution time: 15_465_000 picoseconds.
Weight::from_parts(15_769_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -284,8 +289,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `4273`
// Minimum execution time: 15_787_000 picoseconds.
Weight::from_parts(16_265_000, 0)
// Minimum execution time: 16_579_000 picoseconds.
Weight::from_parts(16_931_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -296,31 +301,27 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `4273`
// Minimum execution time: 14_148_000 picoseconds.
Weight::from_parts(14_631_000, 0)
// Minimum execution time: 15_138_000 picoseconds.
Weight::from_parts(15_435_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `ForeignAssets::Asset` (r:1 w:0)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Metadata` (r:1 w:1)
/// Proof: `ForeignAssets::Metadata` (`max_values`: None, `max_size`: Some(738), added: 3213, mode: `MaxEncodedLen`)
/// Storage: ForeignAssets Asset (r:1 w:0)
/// Proof: ForeignAssets Asset (max_values: None, max_size: Some(808), added: 3283, mode: MaxEncodedLen)
/// Storage: ForeignAssets Metadata (r:1 w:1)
/// Proof: ForeignAssets Metadata (max_values: None, max_size: Some(738), added: 3213, mode: MaxEncodedLen)
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
fn set_metadata(n: u32, s: u32, ) -> Weight {
fn set_metadata(_n: u32, _s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `4273`
// Minimum execution time: 29_277_000 picoseconds.
Weight::from_parts(30_395_865, 0)
// Minimum execution time: 29_846_000 picoseconds.
Weight::from_parts(31_607_649, 0)
.saturating_add(Weight::from_parts(0, 4273))
// Standard Error: 790
.saturating_add(Weight::from_parts(4_644, 0).saturating_mul(n.into()))
// Standard Error: 790
.saturating_add(Weight::from_parts(2_225, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -332,31 +333,29 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `406`
// Estimated: `4273`
// Minimum execution time: 30_520_000 picoseconds.
Weight::from_parts(31_061_000, 0)
// Minimum execution time: 30_582_000 picoseconds.
Weight::from_parts(31_008_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `ForeignAssets::Asset` (r:1 w:0)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Metadata` (r:1 w:1)
/// Proof: `ForeignAssets::Metadata` (`max_values`: None, `max_size`: Some(738), added: 3213, mode: `MaxEncodedLen`)
/// Storage: ForeignAssets Asset (r:1 w:0)
/// Proof: ForeignAssets Asset (max_values: None, max_size: Some(808), added: 3283, mode: MaxEncodedLen)
/// Storage: ForeignAssets Metadata (r:1 w:1)
/// Proof: ForeignAssets Metadata (max_values: None, max_size: Some(738), added: 3213, mode: MaxEncodedLen)
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
fn force_set_metadata(n: u32, s: u32, ) -> Weight {
fn force_set_metadata(_n: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `81`
// Estimated: `4273`
// Minimum execution time: 13_342_000 picoseconds.
Weight::from_parts(14_077_576, 0)
// Minimum execution time: 14_186_000 picoseconds.
Weight::from_parts(14_717_332, 0)
.saturating_add(Weight::from_parts(0, 4273))
// Standard Error: 277
.saturating_add(Weight::from_parts(1_864, 0).saturating_mul(n.into()))
// Standard Error: 277
.saturating_add(Weight::from_parts(772, 0).saturating_mul(s.into()))
// Standard Error: 517
.saturating_add(Weight::from_parts(2_595, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -368,8 +367,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `406`
// Estimated: `4273`
// Minimum execution time: 29_820_000 picoseconds.
Weight::from_parts(30_466_000, 0)
// Minimum execution time: 29_499_000 picoseconds.
Weight::from_parts(29_918_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -380,8 +379,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `4273`
// Minimum execution time: 13_342_000 picoseconds.
Weight::from_parts(13_735_000, 0)
// Minimum execution time: 13_815_000 picoseconds.
Weight::from_parts(14_138_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -394,8 +393,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `276`
// Estimated: `4273`
// Minimum execution time: 32_714_000 picoseconds.
Weight::from_parts(33_526_000, 0)
// Minimum execution time: 33_029_000 picoseconds.
Weight::from_parts(33_524_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -412,8 +411,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `520`
// Estimated: `7404`
// Minimum execution time: 65_470_000 picoseconds.
Weight::from_parts(66_948_000, 0)
// Minimum execution time: 63_205_000 picoseconds.
Weight::from_parts(64_078_000, 0)
.saturating_add(Weight::from_parts(0, 7404))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(5))
@@ -426,8 +425,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `446`
// Estimated: `4273`
// Minimum execution time: 35_313_000 picoseconds.
Weight::from_parts(36_080_000, 0)
// Minimum execution time: 34_948_000 picoseconds.
Weight::from_parts(35_484_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -440,8 +439,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `446`
// Estimated: `4273`
// Minimum execution time: 36_033_000 picoseconds.
Weight::from_parts(36_906_000, 0)
// Minimum execution time: 35_722_000 picoseconds.
Weight::from_parts(36_266_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -452,8 +451,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `4273`
// Minimum execution time: 15_172_000 picoseconds.
Weight::from_parts(15_806_000, 0)
// Minimum execution time: 15_855_000 picoseconds.
Weight::from_parts(16_182_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
@@ -468,8 +467,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `345`
// Estimated: `4273`
// Minimum execution time: 34_557_000 picoseconds.
Weight::from_parts(35_554_000, 0)
// Minimum execution time: 34_984_000 picoseconds.
Weight::from_parts(35_512_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
@@ -482,8 +481,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `4273`
// Minimum execution time: 32_672_000 picoseconds.
Weight::from_parts(33_691_000, 0)
// Minimum execution time: 33_041_000 picoseconds.
Weight::from_parts(34_124_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -498,8 +497,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `4273`
// Minimum execution time: 31_168_000 picoseconds.
Weight::from_parts(32_109_000, 0)
// Minimum execution time: 31_728_000 picoseconds.
Weight::from_parts(32_012_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
@@ -512,8 +511,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `401`
// Estimated: `4273`
// Minimum execution time: 29_325_000 picoseconds.
Weight::from_parts(30_219_000, 0)
// Minimum execution time: 29_432_000 picoseconds.
Weight::from_parts(29_968_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
@@ -526,8 +525,8 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `350`
// Estimated: `4273`
// Minimum execution time: 18_484_000 picoseconds.
Weight::from_parts(18_958_000, 0)
// Minimum execution time: 18_827_000 picoseconds.
Weight::from_parts(19_172_000, 0)
.saturating_add(Weight::from_parts(0, 4273))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
@@ -121,15 +121,13 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `414 + a * (86 ±0)`
// Estimated: `3675 + a * (2623 ±0)`
// Minimum execution time: 17_105_000 picoseconds.
Weight::from_parts(17_370_000, 0)
// Minimum execution time: 16_745_000 picoseconds.
Weight::from_parts(17_247_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
// Standard Error: 5_012
.saturating_add(Weight::from_parts(15_634_963, 0).saturating_mul(a.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into())))
.saturating_add(Weight::from_parts(0, 2623).saturating_mul(a.into()))
}
/// Storage: `Assets::Asset` (r:1 w:1)
@@ -0,0 +1,531 @@
// Copyright Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_assets`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-07-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-kusama-dev")`, DB CACHE: 1024
// Executed Command:
// target/production/polkadot-parachain
// benchmark
// pallet
// --steps=50
// --repeat=20
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/cumulus/.git/.artifacts/bench.json
// --pallet=pallet_assets
// --chain=asset-hub-kusama-dev
// --header=./file_header.txt
// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_assets`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn create() -> Weight {
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3675`
// Minimum execution time: 11_591_000 picoseconds.
Weight::from_parts(11_901_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn force_create() -> Weight {
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3675`
// Minimum execution time: 11_184_000 picoseconds.
Weight::from_parts(11_640_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn start_destroy() -> Weight {
// Proof Size summary in bytes:
// Measured: `314`
// Estimated: `3675`
// Minimum execution time: 13_809_000 picoseconds.
Weight::from_parts(14_226_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1001 w:1000)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1000 w:1000)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `c` is `[0, 1000]`.
/// The range of component `c` is `[0, 1000]`.
/// The range of component `c` is `[0, 1000]`.
fn destroy_accounts(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + c * (208 ±0)`
// Estimated: `3675 + c * (2609 ±0)`
// Minimum execution time: 16_439_000 picoseconds.
Weight::from_parts(16_743_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
// Standard Error: 4_792
.saturating_add(Weight::from_parts(14_463_991, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_parts(0, 2609).saturating_mul(c.into()))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Approvals` (r:1001 w:1000)
/// Proof: `PoolAssets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`)
/// The range of component `a` is `[0, 1000]`.
/// The range of component `a` is `[0, 1000]`.
/// The range of component `a` is `[0, 1000]`.
fn destroy_approvals(a: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `451 + a * (86 ±0)`
// Estimated: `3675 + a * (2623 ±0)`
// Minimum execution time: 17_218_000 picoseconds.
Weight::from_parts(17_585_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
// Standard Error: 2_056
.saturating_add(Weight::from_parts(5_323_866, 0).saturating_mul(a.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into())))
.saturating_add(Weight::from_parts(0, 2623).saturating_mul(a.into()))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Metadata` (r:1 w:0)
/// Proof: `PoolAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`)
fn finish_destroy() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 13_848_000 picoseconds.
Weight::from_parts(14_325_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn mint() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 24_904_000 picoseconds.
Weight::from_parts(25_607_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn burn() -> Weight {
// Proof Size summary in bytes:
// Measured: `388`
// Estimated: `3675`
// Minimum execution time: 31_477_000 picoseconds.
Weight::from_parts(32_338_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:2 w:2)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, 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: `388`
// Estimated: `6208`
// Minimum execution time: 42_994_000 picoseconds.
Weight::from_parts(44_041_000, 0)
.saturating_add(Weight::from_parts(0, 6208))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:2 w:2)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, 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: `388`
// Estimated: `6208`
// Minimum execution time: 37_551_000 picoseconds.
Weight::from_parts(38_648_000, 0)
.saturating_add(Weight::from_parts(0, 6208))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:2 w:2)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, 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: `388`
// Estimated: `6208`
// Minimum execution time: 42_829_000 picoseconds.
Weight::from_parts(44_029_000, 0)
.saturating_add(Weight::from_parts(0, 6208))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `PoolAssets::Asset` (r:1 w:0)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn freeze() -> Weight {
// Proof Size summary in bytes:
// Measured: `388`
// Estimated: `3675`
// Minimum execution time: 17_304_000 picoseconds.
Weight::from_parts(17_782_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:0)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn thaw() -> Weight {
// Proof Size summary in bytes:
// Measured: `388`
// Estimated: `3675`
// Minimum execution time: 17_040_000 picoseconds.
Weight::from_parts(17_698_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn freeze_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `314`
// Estimated: `3675`
// Minimum execution time: 13_238_000 picoseconds.
Weight::from_parts(13_810_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn thaw_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `314`
// Estimated: `3675`
// Minimum execution time: 13_034_000 picoseconds.
Weight::from_parts(13_603_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Metadata` (r:1 w:0)
/// Proof: `PoolAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`)
fn transfer_ownership() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 14_357_000 picoseconds.
Weight::from_parts(14_774_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn set_team() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 13_040_000 picoseconds.
Weight::from_parts(13_616_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:0)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Metadata` (r:1 w:1)
/// Proof: `PoolAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
fn set_metadata(n: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 15_274_000 picoseconds.
Weight::from_parts(16_096_881, 0)
.saturating_add(Weight::from_parts(0, 3675))
// Standard Error: 239
.saturating_add(Weight::from_parts(1_631, 0).saturating_mul(n.into()))
// Standard Error: 239
.saturating_add(Weight::from_parts(2_334, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:0)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Metadata` (r:1 w:1)
/// Proof: `PoolAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`)
fn clear_metadata() -> Weight {
// Proof Size summary in bytes:
// Measured: `444`
// Estimated: `3675`
// Minimum execution time: 15_900_000 picoseconds.
Weight::from_parts(16_526_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:0)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Metadata` (r:1 w:1)
/// Proof: `PoolAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
/// The range of component `n` is `[0, 50]`.
/// The range of component `s` is `[0, 50]`.
fn force_set_metadata(n: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `119`
// Estimated: `3675`
// Minimum execution time: 13_391_000 picoseconds.
Weight::from_parts(14_047_176, 0)
.saturating_add(Weight::from_parts(0, 3675))
// Standard Error: 172
.saturating_add(Weight::from_parts(2_617, 0).saturating_mul(n.into()))
// Standard Error: 172
.saturating_add(Weight::from_parts(2_081, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:0)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Metadata` (r:1 w:1)
/// Proof: `PoolAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`)
fn force_clear_metadata() -> Weight {
// Proof Size summary in bytes:
// Measured: `444`
// Estimated: `3675`
// Minimum execution time: 15_794_000 picoseconds.
Weight::from_parts(16_279_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn force_asset_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 12_538_000 picoseconds.
Weight::from_parts(13_080_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Approvals` (r:1 w:1)
/// Proof: `PoolAssets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`)
fn approve_transfer() -> Weight {
// Proof Size summary in bytes:
// Measured: `314`
// Estimated: `3675`
// Minimum execution time: 18_991_000 picoseconds.
Weight::from_parts(19_812_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Approvals` (r:1 w:1)
/// Proof: `PoolAssets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:2 w:2)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, 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: `558`
// Estimated: `6208`
// Minimum execution time: 50_336_000 picoseconds.
Weight::from_parts(51_441_000, 0)
.saturating_add(Weight::from_parts(0, 6208))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Approvals` (r:1 w:1)
/// Proof: `PoolAssets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`)
fn cancel_approval() -> Weight {
// Proof Size summary in bytes:
// Measured: `484`
// Estimated: `3675`
// Minimum execution time: 21_195_000 picoseconds.
Weight::from_parts(21_946_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Approvals` (r:1 w:1)
/// Proof: `PoolAssets::Approvals` (`max_values`: None, `max_size`: Some(148), added: 2623, mode: `MaxEncodedLen`)
fn force_cancel_approval() -> Weight {
// Proof Size summary in bytes:
// Measured: `484`
// Estimated: `3675`
// Minimum execution time: 21_568_000 picoseconds.
Weight::from_parts(22_366_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn set_min_balance() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 13_690_000 picoseconds.
Weight::from_parts(14_086_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn touch() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 18_240_000 picoseconds.
Weight::from_parts(19_000_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn touch_other() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3675`
// Minimum execution time: 18_469_000 picoseconds.
Weight::from_parts(19_040_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn refund() -> Weight {
// Proof Size summary in bytes:
// Measured: `406`
// Estimated: `3675`
// Minimum execution time: 14_633_000 picoseconds.
Weight::from_parts(15_296_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
fn refund_other() -> Weight {
// Proof Size summary in bytes:
// Measured: `439`
// Estimated: `3675`
// Minimum execution time: 14_751_000 picoseconds.
Weight::from_parts(15_312_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PoolAssets::Asset` (r:1 w:0)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn block() -> Weight {
// Proof Size summary in bytes:
// Measured: `388`
// Estimated: `3675`
// Minimum execution time: 16_930_000 picoseconds.
Weight::from_parts(17_653_000, 0)
.saturating_add(Weight::from_parts(0, 3675))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -14,12 +14,16 @@
// limitations under the License.
use super::{
AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, ForeignAssets,
ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, ParachainInfo,
ParachainSystem, PolkadotXcm, PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
};
use assets_common::matching::{
FromSiblingParachain, IsForeignConcreteAsset, StartsWith, StartsWithExplicitGlobalConsensus,
use crate::ForeignAssets;
use assets_common::{
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
matching::{
FromSiblingParachain, IsForeignConcreteAsset, StartsWith, StartsWithExplicitGlobalConsensus,
},
};
use frame_support::{
match_types, parameter_types,
@@ -43,6 +47,9 @@ use xcm_builder::{
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
#[cfg(feature = "runtime-benchmarks")]
use {cumulus_primitives_core::ParaId, sp_core::Get};
parameter_types! {
pub const KsmLocation: MultiLocation = MultiLocation::parent();
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Kusama);
@@ -52,6 +59,10 @@ parameter_types! {
pub UniversalLocationNetworkId: NetworkId = UniversalLocation::get().global_consensus().unwrap();
pub TrustBackedAssetsPalletLocation: MultiLocation =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
pub ForeignAssetsPalletLocation: MultiLocation =
PalletInstance(<ForeignAssets as PalletInfoAccess>::index() as u8).into();
pub PoolAssetsPalletLocation: MultiLocation =
PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
pub const FellowshipLocation: MultiLocation = MultiLocation::parent();
@@ -85,7 +96,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
(),
>;
/// `AssetId/Balance` converter for `TrustBackedAssets`
/// `AssetId`/`Balance` converter for `PoolAssets`.
pub type TrustBackedAssetsConvertedConcreteId =
assets_common::TrustBackedAssetsConvertedConcreteId<TrustBackedAssetsPalletLocation, Balance>;
@@ -137,8 +148,48 @@ pub type ForeignFungiblesTransactor = FungiblesAdapter<
CheckingAccount,
>;
/// `AssetId`/`Balance` converter for `PoolAssets`.
pub type PoolAssetsConvertedConcreteId =
assets_common::PoolAssetsConvertedConcreteId<PoolAssetsPalletLocation, Balance>;
/// Means for transacting asset conversion pool assets on this chain.
pub type PoolFungiblesTransactor = FungiblesAdapter<
// Use this fungibles implementation:
PoolAssets,
// Use this currency when it is a fungible asset matching the given location or name:
PoolAssetsConvertedConcreteId,
// Convert an XCM MultiLocation into a local account id:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
// We only want to allow teleports of known assets. We use non-zero issuance as an indication
// that this asset is known.
LocalMint<parachains_common::impls::NonZeroIssuance<AccountId, PoolAssets>>,
// The account to use for tracking teleports.
CheckingAccount,
>;
/// Means for transacting assets on this chain.
pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor, ForeignFungiblesTransactor);
pub type AssetTransactors =
(CurrencyTransactor, FungiblesTransactor, ForeignFungiblesTransactor, PoolFungiblesTransactor);
/// Simple `MultiLocation` matcher for Local and Foreign asset `MultiLocation`.
pub struct LocalAndForeignAssetsMultiLocationMatcher;
impl MatchesLocalAndForeignAssetsMultiLocation for LocalAndForeignAssetsMultiLocationMatcher {
fn is_local(location: &MultiLocation) -> bool {
use assets_common::fungible_conversion::MatchesMultiLocation;
TrustBackedAssetsConvertedConcreteId::contains(location)
}
fn is_foreign(location: &MultiLocation) -> bool {
use assets_common::fungible_conversion::MatchesMultiLocation;
ForeignAssetsConvertedConcreteId::contains(location)
}
}
impl Contains<MultiLocation> for LocalAndForeignAssetsMultiLocationMatcher {
fn contains(location: &MultiLocation) -> bool {
Self::is_local(location) || Self::is_foreign(location)
}
}
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
@@ -227,6 +278,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_assets::Call::destroy_accounts { .. } |
pallet_assets::Call::destroy_approvals { .. } |
pallet_assets::Call::finish_destroy { .. } |
pallet_assets::Call::block { .. } |
pallet_assets::Call::mint { .. } |
pallet_assets::Call::burn { .. } |
pallet_assets::Call::transfer { .. } |
@@ -247,7 +299,9 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_assets::Call::force_cancel_approval { .. } |
pallet_assets::Call::transfer_approved { .. } |
pallet_assets::Call::touch { .. } |
pallet_assets::Call::refund { .. },
pallet_assets::Call::touch_other { .. } |
pallet_assets::Call::refund { .. } |
pallet_assets::Call::refund_other { .. },
) | RuntimeCall::ForeignAssets(
pallet_assets::Call::create { .. } |
pallet_assets::Call::force_create { .. } |
@@ -255,6 +309,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_assets::Call::destroy_accounts { .. } |
pallet_assets::Call::destroy_approvals { .. } |
pallet_assets::Call::finish_destroy { .. } |
pallet_assets::Call::block { .. } |
pallet_assets::Call::mint { .. } |
pallet_assets::Call::burn { .. } |
pallet_assets::Call::transfer { .. } |
@@ -275,7 +330,40 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_assets::Call::force_cancel_approval { .. } |
pallet_assets::Call::transfer_approved { .. } |
pallet_assets::Call::touch { .. } |
pallet_assets::Call::refund { .. },
pallet_assets::Call::touch_other { .. } |
pallet_assets::Call::refund { .. } |
pallet_assets::Call::refund_other { .. },
) | RuntimeCall::PoolAssets(
pallet_assets::Call::force_create { .. } |
pallet_assets::Call::block { .. } |
pallet_assets::Call::burn { .. } |
pallet_assets::Call::transfer { .. } |
pallet_assets::Call::transfer_keep_alive { .. } |
pallet_assets::Call::force_transfer { .. } |
pallet_assets::Call::freeze { .. } |
pallet_assets::Call::thaw { .. } |
pallet_assets::Call::freeze_asset { .. } |
pallet_assets::Call::thaw_asset { .. } |
pallet_assets::Call::transfer_ownership { .. } |
pallet_assets::Call::set_team { .. } |
pallet_assets::Call::set_metadata { .. } |
pallet_assets::Call::clear_metadata { .. } |
pallet_assets::Call::force_clear_metadata { .. } |
pallet_assets::Call::force_asset_status { .. } |
pallet_assets::Call::approve_transfer { .. } |
pallet_assets::Call::cancel_approval { .. } |
pallet_assets::Call::force_cancel_approval { .. } |
pallet_assets::Call::transfer_approved { .. } |
pallet_assets::Call::touch { .. } |
pallet_assets::Call::touch_other { .. } |
pallet_assets::Call::refund { .. } |
pallet_assets::Call::refund_other { .. },
) | RuntimeCall::AssetConversion(
pallet_asset_conversion::Call::create_pool { .. } |
pallet_asset_conversion::Call::add_liquidity { .. } |
pallet_asset_conversion::Call::remove_liquidity { .. } |
pallet_asset_conversion::Call::swap_tokens_for_exact_tokens { .. } |
pallet_asset_conversion::Call::swap_exact_tokens_for_tokens { .. },
) | RuntimeCall::NftFractionalization(
pallet_nft_fractionalization::Call::fractionalize { .. } |
pallet_nft_fractionalization::Call::unify { .. },
@@ -506,3 +594,30 @@ impl pallet_assets::BenchmarkHelper<MultiLocation> for XcmBenchmarkHelper {
MultiLocation { parents: 1, interior: X1(Parachain(id)) }
}
}
#[cfg(feature = "runtime-benchmarks")]
pub struct BenchmarkMultiLocationConverter<SelfParaId> {
_phantom: sp_std::marker::PhantomData<SelfParaId>,
}
#[cfg(feature = "runtime-benchmarks")]
impl<SelfParaId>
pallet_asset_conversion::BenchmarkHelper<MultiLocation, sp_std::boxed::Box<MultiLocation>>
for BenchmarkMultiLocationConverter<SelfParaId>
where
SelfParaId: Get<ParaId>,
{
fn asset_id(asset_id: u32) -> MultiLocation {
MultiLocation {
parents: 1,
interior: X3(
Parachain(SelfParaId::get().into()),
PalletInstance(<Assets as PalletInfoAccess>::index() as u8),
GeneralIndex(asset_id.into()),
),
}
}
fn multiasset_id(asset_id: u32) -> sp_std::boxed::Box<MultiLocation> {
sp_std::boxed::Box::new(Self::asset_id(asset_id))
}
}
@@ -266,13 +266,14 @@ impl pallet_assets::Config<TrustBackedAssetsInstance> for Runtime {
parameter_types! {
pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
pub storage AllowMultiAssetPools: bool = false;
pub const AllowMultiAssetPools: bool = false;
// should be non-zero if AllowMultiAssetPools is true, otherwise can be zero
pub storage LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
}
ord_parameter_types! {
pub const AssetConversionOrigin: sp_runtime::AccountId32 = AccountIdConversion::<sp_runtime::AccountId32>::into_account_truncating(&AssetConversionPalletId::get());
pub const AssetConversionOrigin: sp_runtime::AccountId32 =
AccountIdConversion::<sp_runtime::AccountId32>::into_account_truncating(&AssetConversionPalletId::get());
}
pub type PoolAssetsInstance = pallet_assets::Instance3;
@@ -18,7 +18,7 @@ use super::{
ParachainSystem, PolkadotXcm, PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
};
use crate::{AllowMultiAssetPools, ForeignAssets, LiquidityWithdrawalFee};
use crate::ForeignAssets;
use assets_common::{
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
matching::{
@@ -241,16 +241,6 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}
// Allow to change dedicated storage items (called by governance-like)
match call {
RuntimeCall::System(frame_system::Call::set_storage { items })
if items.iter().any(|(k, _)| {
k.eq(&AllowMultiAssetPools::key()) | k.eq(&LiquidityWithdrawalFee::key())
}) =>
return true,
_ => (),
};
matches!(
call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
@@ -280,6 +270,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_assets::Call::destroy_accounts { .. } |
pallet_assets::Call::destroy_approvals { .. } |
pallet_assets::Call::finish_destroy { .. } |
pallet_assets::Call::block { .. } |
pallet_assets::Call::mint { .. } |
pallet_assets::Call::burn { .. } |
pallet_assets::Call::transfer { .. } |
@@ -300,7 +291,9 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_assets::Call::force_cancel_approval { .. } |
pallet_assets::Call::transfer_approved { .. } |
pallet_assets::Call::touch { .. } |
pallet_assets::Call::refund { .. },
pallet_assets::Call::touch_other { .. } |
pallet_assets::Call::refund { .. } |
pallet_assets::Call::refund_other { .. },
) | RuntimeCall::ForeignAssets(
pallet_assets::Call::create { .. } |
pallet_assets::Call::force_create { .. } |
@@ -308,6 +301,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_assets::Call::destroy_accounts { .. } |
pallet_assets::Call::destroy_approvals { .. } |
pallet_assets::Call::finish_destroy { .. } |
pallet_assets::Call::block { .. } |
pallet_assets::Call::mint { .. } |
pallet_assets::Call::burn { .. } |
pallet_assets::Call::transfer { .. } |
@@ -328,7 +322,40 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_assets::Call::force_cancel_approval { .. } |
pallet_assets::Call::transfer_approved { .. } |
pallet_assets::Call::touch { .. } |
pallet_assets::Call::refund { .. },
pallet_assets::Call::touch_other { .. } |
pallet_assets::Call::refund { .. } |
pallet_assets::Call::refund_other { .. },
) | RuntimeCall::PoolAssets(
pallet_assets::Call::create { .. } |
pallet_assets::Call::force_create { .. } |
pallet_assets::Call::start_destroy { .. } |
pallet_assets::Call::destroy_accounts { .. } |
pallet_assets::Call::destroy_approvals { .. } |
pallet_assets::Call::finish_destroy { .. } |
pallet_assets::Call::block { .. } |
pallet_assets::Call::mint { .. } |
pallet_assets::Call::burn { .. } |
pallet_assets::Call::transfer { .. } |
pallet_assets::Call::transfer_keep_alive { .. } |
pallet_assets::Call::force_transfer { .. } |
pallet_assets::Call::freeze { .. } |
pallet_assets::Call::thaw { .. } |
pallet_assets::Call::freeze_asset { .. } |
pallet_assets::Call::thaw_asset { .. } |
pallet_assets::Call::transfer_ownership { .. } |
pallet_assets::Call::set_team { .. } |
pallet_assets::Call::set_metadata { .. } |
pallet_assets::Call::clear_metadata { .. } |
pallet_assets::Call::force_clear_metadata { .. } |
pallet_assets::Call::force_asset_status { .. } |
pallet_assets::Call::approve_transfer { .. } |
pallet_assets::Call::cancel_approval { .. } |
pallet_assets::Call::force_cancel_approval { .. } |
pallet_assets::Call::transfer_approved { .. } |
pallet_assets::Call::touch { .. } |
pallet_assets::Call::touch_other { .. } |
pallet_assets::Call::refund { .. } |
pallet_assets::Call::refund_other { .. },
) | RuntimeCall::AssetConversion(
pallet_asset_conversion::Call::create_pool { .. } |
pallet_asset_conversion::Call::add_liquidity { .. } |
@@ -29,8 +29,8 @@ use asset_hub_westend_runtime::{
AssetFeeAsExistentialDepositMultiplierFeeCharger, ForeignCreatorsSovereignAccountOf,
WestendLocation,
},
AllPalletsWithoutSystem, LiquidityWithdrawalFee, MetadataDepositBase, MetadataDepositPerByte,
RuntimeCall, RuntimeEvent,
AllPalletsWithoutSystem, MetadataDepositBase, MetadataDepositPerByte, RuntimeCall,
RuntimeEvent,
};
use asset_test_utils::{CollatorSessionKeys, ExtBuilder, XcmReceivedFrom};
use codec::{Decode, DecodeLimit, Encode};
@@ -41,10 +41,7 @@ use frame_support::{
weights::{Weight, WeightToFee as WeightToFeeT},
};
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance};
use sp_runtime::{
traits::{CheckedAdd, CheckedSub, MaybeEquivalence},
Permill,
};
use sp_runtime::traits::MaybeEquivalence;
use std::convert::Into;
use xcm::{latest::prelude::*, VersionedXcm, MAX_XCM_DECODE_DEPTH};
use xcm_executor::{
@@ -667,39 +664,3 @@ fn plain_receive_teleported_asset_works() {
assert_eq!(outcome.ensure_complete(), Ok(()));
})
}
#[test]
fn change_allow_multi_asset_pools_by_governance_works() {
asset_test_utils::test_cases::change_storage_constant_by_governance_works::<
Runtime,
AllowMultiAssetPools,
bool,
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
|| (AllowMultiAssetPools::key().to_vec(), AllowMultiAssetPools::get()),
|old_value| !old_value,
)
}
#[test]
fn change_liquidity_withdrawal_fee_by_governance_works() {
asset_test_utils::test_cases::change_storage_constant_by_governance_works::<
Runtime,
LiquidityWithdrawalFee,
Permill,
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
|| (LiquidityWithdrawalFee::key().to_vec(), LiquidityWithdrawalFee::get()),
|old_value| {
if let Some(new_value) = old_value.checked_add(&Permill::from_percent(2)) {
new_value
} else {
old_value.checked_sub(&Permill::from_percent(2)).unwrap()
}
},
)
}