mirror of
https://github.com/pezkuwichain/pezkuwi-runtime-templates.git
synced 2026-04-22 02:07:55 +00:00
xtokens config (#331)
* added trader * loosing the logic for bridged assets * simplify logic * better inline docs * match against all X1, X2, etc. variants * simplify the xcm config --------- Co-authored-by: Alistair Singh <alistair.singh7@gmail.com>
This commit is contained in:
Generated
+73
-3
@@ -3007,7 +3007,9 @@ dependencies = [
|
|||||||
"frame-try-runtime",
|
"frame-try-runtime",
|
||||||
"hex-literal",
|
"hex-literal",
|
||||||
"log",
|
"log",
|
||||||
|
"orml-traits",
|
||||||
"orml-xcm-support",
|
"orml-xcm-support",
|
||||||
|
"orml-xtokens",
|
||||||
"pallet-asset-manager",
|
"pallet-asset-manager",
|
||||||
"pallet-assets",
|
"pallet-assets",
|
||||||
"pallet-aura",
|
"pallet-aura",
|
||||||
@@ -3016,6 +3018,7 @@ dependencies = [
|
|||||||
"pallet-base-fee",
|
"pallet-base-fee",
|
||||||
"pallet-collator-selection",
|
"pallet-collator-selection",
|
||||||
"pallet-conviction-voting",
|
"pallet-conviction-voting",
|
||||||
|
"pallet-erc20-xcm-bridge",
|
||||||
"pallet-ethereum",
|
"pallet-ethereum",
|
||||||
"pallet-evm",
|
"pallet-evm",
|
||||||
"pallet-evm-chain-id",
|
"pallet-evm-chain-id",
|
||||||
@@ -3037,6 +3040,7 @@ dependencies = [
|
|||||||
"pallet-utility",
|
"pallet-utility",
|
||||||
"pallet-whitelist",
|
"pallet-whitelist",
|
||||||
"pallet-xcm",
|
"pallet-xcm",
|
||||||
|
"pallet-xcm-weight-trader",
|
||||||
"parachains-common",
|
"parachains-common",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"polkadot-parachain-primitives",
|
"polkadot-parachain-primitives",
|
||||||
@@ -6871,6 +6875,7 @@ dependencies = [
|
|||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"paste",
|
"paste",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
|
"serde",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-io",
|
"sp-io",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
@@ -6886,6 +6891,7 @@ dependencies = [
|
|||||||
"frame-support",
|
"frame-support",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
|
"serde",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-io",
|
"sp-io",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
@@ -6906,6 +6912,27 @@ dependencies = [
|
|||||||
"staging-xcm-executor",
|
"staging-xcm-executor",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "orml-xtokens"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "git+https://github.com/OpenZeppelin/open-runtime-module-library?branch=polkadot-stable2407-1#aafe9077c9ec61dd8b3a42e899ef8353b2b050c0"
|
||||||
|
dependencies = [
|
||||||
|
"frame-support",
|
||||||
|
"frame-system",
|
||||||
|
"log",
|
||||||
|
"orml-traits",
|
||||||
|
"orml-xcm-support",
|
||||||
|
"pallet-xcm",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"scale-info",
|
||||||
|
"serde",
|
||||||
|
"sp-io",
|
||||||
|
"sp-runtime",
|
||||||
|
"sp-std",
|
||||||
|
"staging-xcm",
|
||||||
|
"staging-xcm-executor",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "overload"
|
name = "overload"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@@ -6933,7 +6960,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "pallet-asset-manager"
|
name = "pallet-asset-manager"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/OpenZeppelin/moonbeam.git?branch=polkadot-stable2407-1#3ed33a712c6968af7a33d970ec4300293c5345b9"
|
source = "git+https://github.com/OpenZeppelin/moonbeam.git?branch=polkadot-stable2407-1#fab6e72fbaaeaa065ad983556d09d4c0e8755dfa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
@@ -7343,6 +7370,28 @@ dependencies = [
|
|||||||
"sp-staking",
|
"sp-staking",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pallet-erc20-xcm-bridge"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "git+https://github.com/OpenZeppelin/moonbeam.git?branch=polkadot-stable2407-1#fab6e72fbaaeaa065ad983556d09d4c0e8755dfa"
|
||||||
|
dependencies = [
|
||||||
|
"environmental",
|
||||||
|
"ethereum-types",
|
||||||
|
"fp-evm",
|
||||||
|
"frame-support",
|
||||||
|
"frame-system",
|
||||||
|
"log",
|
||||||
|
"pallet-evm",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"scale-info",
|
||||||
|
"serde",
|
||||||
|
"sp-core",
|
||||||
|
"sp-runtime",
|
||||||
|
"sp-std",
|
||||||
|
"staging-xcm",
|
||||||
|
"staging-xcm-executor",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pallet-ethereum"
|
name = "pallet-ethereum"
|
||||||
version = "4.0.0-dev"
|
version = "4.0.0-dev"
|
||||||
@@ -8134,6 +8183,27 @@ dependencies = [
|
|||||||
"staging-xcm-executor",
|
"staging-xcm-executor",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pallet-xcm-weight-trader"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/OpenZeppelin/moonbeam.git?branch=polkadot-stable2407-1#fab6e72fbaaeaa065ad983556d09d4c0e8755dfa"
|
||||||
|
dependencies = [
|
||||||
|
"frame-benchmarking",
|
||||||
|
"frame-support",
|
||||||
|
"frame-system",
|
||||||
|
"log",
|
||||||
|
"pallet-balances",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"scale-info",
|
||||||
|
"sp-core",
|
||||||
|
"sp-io",
|
||||||
|
"sp-runtime",
|
||||||
|
"sp-std",
|
||||||
|
"staging-xcm",
|
||||||
|
"staging-xcm-executor",
|
||||||
|
"xcm-runtime-apis",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parachains-common"
|
name = "parachains-common"
|
||||||
version = "17.0.0"
|
version = "17.0.0"
|
||||||
@@ -9941,7 +10011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4"
|
checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"heck 0.5.0",
|
"heck 0.4.1",
|
||||||
"itertools 0.12.1",
|
"itertools 0.12.1",
|
||||||
"log",
|
"log",
|
||||||
"multimap 0.10.0",
|
"multimap 0.10.0",
|
||||||
@@ -15781,7 +15851,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "xcm-primitives"
|
name = "xcm-primitives"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "git+https://github.com/OpenZeppelin/moonbeam.git?branch=polkadot-stable2407-1#3ed33a712c6968af7a33d970ec4300293c5345b9"
|
source = "git+https://github.com/OpenZeppelin/moonbeam.git?branch=polkadot-stable2407-1#fab6e72fbaaeaa065ad983556d09d4c0e8755dfa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cumulus-primitives-core",
|
"cumulus-primitives-core",
|
||||||
"ethereum",
|
"ethereum",
|
||||||
|
|||||||
@@ -161,12 +161,17 @@ pallet-evm-precompile-sha3fips = { git = "https://github.com/OpenZeppelin/fronti
|
|||||||
pallet-evm-precompile-simple = { git = "https://github.com/OpenZeppelin/frontier", branch = "polkadot-stable2407-1", default-features = false }
|
pallet-evm-precompile-simple = { git = "https://github.com/OpenZeppelin/frontier", branch = "polkadot-stable2407-1", default-features = false }
|
||||||
|
|
||||||
# ORML
|
# ORML
|
||||||
|
orml-traits = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
|
||||||
orml-xcm-support = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
|
orml-xcm-support = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
|
||||||
|
orml-xtokens = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
|
||||||
|
|
||||||
# Moonbeam
|
# Moonbeam
|
||||||
pallet-asset-manager = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
|
pallet-asset-manager = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
|
||||||
|
pallet-erc20-xcm-bridge = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
|
||||||
|
pallet-xcm-weight-trader = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
|
||||||
xcm-primitives = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
|
xcm-primitives = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
|
||||||
|
|
||||||
|
|
||||||
# Fuzzer
|
# Fuzzer
|
||||||
substrate-runtimes-fuzzers = { git = "https://github.com/srlabs/substrate-runtime-fuzzer.git", default-features = false, tag = "polkadot-v1.12.0" }
|
substrate-runtimes-fuzzers = { git = "https://github.com/srlabs/substrate-runtime-fuzzer.git", default-features = false, tag = "polkadot-v1.12.0" }
|
||||||
ziggy = { version = "0.8", default-features = false }
|
ziggy = { version = "0.8", default-features = false }
|
||||||
|
|||||||
@@ -96,13 +96,17 @@ pallet-evm-precompile-sha3fips = { workspace = true }
|
|||||||
pallet-evm-precompile-simple = { workspace = true }
|
pallet-evm-precompile-simple = { workspace = true }
|
||||||
|
|
||||||
# ORML
|
# ORML
|
||||||
|
orml-traits = { workspace = true }
|
||||||
orml-xcm-support = { workspace = true }
|
orml-xcm-support = { workspace = true }
|
||||||
|
orml-xtokens = { workspace = true }
|
||||||
|
|
||||||
# Moonbeam
|
# Moonbeam
|
||||||
pallet-asset-manager = { workspace = true }
|
pallet-asset-manager = { workspace = true }
|
||||||
|
pallet-erc20-xcm-bridge = { workspace = true }
|
||||||
|
pallet-xcm-weight-trader = { workspace = true }
|
||||||
xcm-primitives = { workspace = true }
|
xcm-primitives = { workspace = true }
|
||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sp-io = { workspace = true }
|
sp-io = { workspace = true }
|
||||||
|
|
||||||
@@ -136,6 +140,7 @@ std = [
|
|||||||
"frame-system/std",
|
"frame-system/std",
|
||||||
"frame-try-runtime?/std",
|
"frame-try-runtime?/std",
|
||||||
"log/std",
|
"log/std",
|
||||||
|
"orml-xtokens/std",
|
||||||
"pallet-asset-manager/std",
|
"pallet-asset-manager/std",
|
||||||
"pallet-assets/std",
|
"pallet-assets/std",
|
||||||
"pallet-aura/std",
|
"pallet-aura/std",
|
||||||
@@ -144,6 +149,7 @@ std = [
|
|||||||
"pallet-base-fee/std",
|
"pallet-base-fee/std",
|
||||||
"pallet-collator-selection/std",
|
"pallet-collator-selection/std",
|
||||||
"pallet-conviction-voting/std",
|
"pallet-conviction-voting/std",
|
||||||
|
"pallet-erc20-xcm-bridge/std",
|
||||||
"pallet-ethereum/std",
|
"pallet-ethereum/std",
|
||||||
"pallet-evm-chain-id/std",
|
"pallet-evm-chain-id/std",
|
||||||
"pallet-evm/std",
|
"pallet-evm/std",
|
||||||
@@ -161,6 +167,7 @@ std = [
|
|||||||
"pallet-treasury/std",
|
"pallet-treasury/std",
|
||||||
"pallet-utility/std",
|
"pallet-utility/std",
|
||||||
"pallet-whitelist/std",
|
"pallet-whitelist/std",
|
||||||
|
"pallet-xcm-weight-trader/std",
|
||||||
"pallet-xcm/std",
|
"pallet-xcm/std",
|
||||||
"parachain-info/std",
|
"parachain-info/std",
|
||||||
"parachains-common/std",
|
"parachains-common/std",
|
||||||
@@ -217,6 +224,7 @@ runtime-benchmarks = [
|
|||||||
"pallet-treasury/runtime-benchmarks",
|
"pallet-treasury/runtime-benchmarks",
|
||||||
"pallet-utility/runtime-benchmarks",
|
"pallet-utility/runtime-benchmarks",
|
||||||
"pallet-whitelist/runtime-benchmarks",
|
"pallet-whitelist/runtime-benchmarks",
|
||||||
|
"pallet-xcm-weight-trader/runtime-benchmarks",
|
||||||
"pallet-xcm/runtime-benchmarks",
|
"pallet-xcm/runtime-benchmarks",
|
||||||
"parachains-common/runtime-benchmarks",
|
"parachains-common/runtime-benchmarks",
|
||||||
"polkadot-parachain-primitives/runtime-benchmarks",
|
"polkadot-parachain-primitives/runtime-benchmarks",
|
||||||
@@ -236,6 +244,7 @@ try-runtime = [
|
|||||||
"frame-support/try-runtime",
|
"frame-support/try-runtime",
|
||||||
"frame-system/try-runtime",
|
"frame-system/try-runtime",
|
||||||
"frame-try-runtime/try-runtime",
|
"frame-try-runtime/try-runtime",
|
||||||
|
"orml-xtokens/try-runtime",
|
||||||
"pallet-asset-manager/try-runtime",
|
"pallet-asset-manager/try-runtime",
|
||||||
"pallet-assets/try-runtime",
|
"pallet-assets/try-runtime",
|
||||||
"pallet-aura/try-runtime",
|
"pallet-aura/try-runtime",
|
||||||
@@ -244,6 +253,7 @@ try-runtime = [
|
|||||||
"pallet-base-fee/try-runtime",
|
"pallet-base-fee/try-runtime",
|
||||||
"pallet-collator-selection/try-runtime",
|
"pallet-collator-selection/try-runtime",
|
||||||
"pallet-conviction-voting/try-runtime",
|
"pallet-conviction-voting/try-runtime",
|
||||||
|
"pallet-erc20-xcm-bridge/try-runtime",
|
||||||
"pallet-ethereum/try-runtime",
|
"pallet-ethereum/try-runtime",
|
||||||
"pallet-evm-chain-id/try-runtime",
|
"pallet-evm-chain-id/try-runtime",
|
||||||
"pallet-message-queue/try-runtime",
|
"pallet-message-queue/try-runtime",
|
||||||
@@ -260,6 +270,7 @@ try-runtime = [
|
|||||||
"pallet-treasury/try-runtime",
|
"pallet-treasury/try-runtime",
|
||||||
"pallet-utility/try-runtime",
|
"pallet-utility/try-runtime",
|
||||||
"pallet-whitelist/try-runtime",
|
"pallet-whitelist/try-runtime",
|
||||||
|
"pallet-xcm-weight-trader/try-runtime",
|
||||||
"pallet-xcm/try-runtime",
|
"pallet-xcm/try-runtime",
|
||||||
"parachain-info/try-runtime",
|
"parachain-info/try-runtime",
|
||||||
"polkadot-runtime-common/try-runtime",
|
"polkadot-runtime-common/try-runtime",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use frame_support::{
|
|||||||
use frame_system::{EnsureRoot, EnsureSigned};
|
use frame_system::{EnsureRoot, EnsureSigned};
|
||||||
use parity_scale_codec::{Compact, Decode, Encode};
|
use parity_scale_codec::{Compact, Decode, Encode};
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_core::H256;
|
use sp_core::{H160, H256};
|
||||||
use sp_runtime::traits::Hash as THash;
|
use sp_runtime::traits::Hash as THash;
|
||||||
use sp_std::{
|
use sp_std::{
|
||||||
convert::{From, Into},
|
convert::{From, Into},
|
||||||
@@ -184,3 +184,41 @@ impl pallet_asset_manager::Config for Runtime {
|
|||||||
/// Rerun benchmarks if you are making changes to runtime configuration.
|
/// Rerun benchmarks if you are making changes to runtime configuration.
|
||||||
type WeightInfo = weights::pallet_asset_manager::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_asset_manager::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This trait ensure we can convert AccountIds to AssetIds.
|
||||||
|
pub trait AccountIdAssetIdConversion<Account, AssetId> {
|
||||||
|
// Get assetId and prefix from account
|
||||||
|
fn account_to_asset_id(account: Account) -> Option<(Vec<u8>, AssetId)>;
|
||||||
|
|
||||||
|
// Get AccountId from AssetId and prefix
|
||||||
|
fn asset_id_to_account(prefix: &[u8], asset_id: AssetId) -> Account;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX: &[u8] = &[255u8; 4];
|
||||||
|
|
||||||
|
// Instruct how to go from an H160 to an AssetID
|
||||||
|
// We just take the lowest 128 bits
|
||||||
|
impl AccountIdAssetIdConversion<AccountId, AssetId> for Runtime {
|
||||||
|
/// The way to convert an account to assetId is by ensuring that the prefix is 0XFFFFFFFF
|
||||||
|
/// and by taking the lowest 128 bits as the assetId
|
||||||
|
fn account_to_asset_id(account: AccountId) -> Option<(Vec<u8>, AssetId)> {
|
||||||
|
let h160_account: H160 = account.into();
|
||||||
|
let mut data = [0u8; 16];
|
||||||
|
let (prefix_part, id_part) = h160_account.as_fixed_bytes().split_at(4);
|
||||||
|
if prefix_part == FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX {
|
||||||
|
data.copy_from_slice(id_part);
|
||||||
|
let asset_id: AssetId = u128::from_be_bytes(data);
|
||||||
|
Some((prefix_part.to_vec(), asset_id))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The opposite conversion
|
||||||
|
fn asset_id_to_account(prefix: &[u8], asset_id: AssetId) -> AccountId {
|
||||||
|
let mut data = [0u8; 20];
|
||||||
|
data[0..4].copy_from_slice(prefix);
|
||||||
|
data[4..20].copy_from_slice(&asset_id.to_be_bytes());
|
||||||
|
AccountId::from(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ use frame_support::{
|
|||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use frame_system::EnsureRoot;
|
use frame_system::EnsureRoot;
|
||||||
|
use orml_traits::{location::Reserve, parameter_type_with_key};
|
||||||
use orml_xcm_support::MultiNativeAsset;
|
use orml_xcm_support::MultiNativeAsset;
|
||||||
use pallet_xcm::XcmPassthrough;
|
use pallet_xcm::XcmPassthrough;
|
||||||
|
use parity_scale_codec::{Decode, Encode};
|
||||||
use polkadot_parachain_primitives::primitives::{self, Sibling};
|
use polkadot_parachain_primitives::primitives::{self, Sibling};
|
||||||
|
use scale_info::TypeInfo;
|
||||||
|
use sp_core::H160;
|
||||||
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountKey20Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, Case,
|
AccountKey20Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, Case,
|
||||||
@@ -16,23 +20,22 @@ use xcm_builder::{
|
|||||||
FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, HandleFee,
|
FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, HandleFee,
|
||||||
IsChildSystemParachain, IsConcrete, NoChecking, ParentIsPreset, RelayChainAsNative,
|
IsChildSystemParachain, IsConcrete, NoChecking, ParentIsPreset, RelayChainAsNative,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountKey20AsNative,
|
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountKey20AsNative,
|
||||||
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
|
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, WithComputedOrigin,
|
||||||
WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
|
WithUniqueTopic, XcmFeeManagerFromComponents,
|
||||||
};
|
};
|
||||||
use xcm_executor::{
|
use xcm_executor::{
|
||||||
traits::{FeeReason, JustTry, TransactAsset},
|
traits::{ConvertLocation, FeeReason, JustTry, TransactAsset},
|
||||||
XcmExecutor,
|
XcmExecutor,
|
||||||
};
|
};
|
||||||
use xcm_primitives::{AbsoluteAndRelativeReserve, AsAssetType};
|
use xcm_primitives::{AbsoluteAndRelativeReserve, AccountIdToLocation, AsAssetType};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
configs::{
|
configs::{
|
||||||
AssetType, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
|
AssetType, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmpQueue,
|
||||||
XcmpQueue,
|
|
||||||
},
|
},
|
||||||
types::{AccountId, AssetId, Balance, XcmFeesToAccount},
|
types::{AccountId, AssetId, Balance},
|
||||||
weights, AllPalletsWithSystem, AssetManager, Assets, Balances, ParachainInfo, PolkadotXcm,
|
weights, AllPalletsWithSystem, AssetManager, Assets, Balances, Erc20XcmBridge, ParachainInfo,
|
||||||
Treasury,
|
PolkadotXcm, Treasury,
|
||||||
};
|
};
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -42,6 +45,16 @@ parameter_types! {
|
|||||||
pub BalancesPalletLocation: Location = PalletInstance(<Balances as PalletInfoAccess>::index() as u8).into();
|
pub BalancesPalletLocation: Location = PalletInstance(<Balances as PalletInfoAccess>::index() as u8).into();
|
||||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||||
pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||||
|
// Self Reserve location, defines the multilocation identifiying the self-reserve currency
|
||||||
|
// This is used to match it also against our Balances pallet when we receive such
|
||||||
|
// a Location: (Self Balances pallet index)
|
||||||
|
// We use the RELATIVE multilocation
|
||||||
|
pub SelfReserve: Location = Location {
|
||||||
|
parents:0,
|
||||||
|
interior: [
|
||||||
|
PalletInstance(<Balances as PalletInfoAccess>::index() as u8)
|
||||||
|
].into()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `AssetId/Balancer` converter for `TrustBackedAssets`
|
/// `AssetId/Balancer` converter for `TrustBackedAssets`
|
||||||
@@ -232,6 +245,8 @@ parameter_types! {
|
|||||||
pub TreasuryAccount: AccountId = Treasury::account_id();
|
pub TreasuryAccount: AccountId = Treasury::account_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type XcmWeigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
||||||
|
|
||||||
pub struct XcmConfig;
|
pub struct XcmConfig;
|
||||||
impl xcm_executor::Config for XcmConfig {
|
impl xcm_executor::Config for XcmConfig {
|
||||||
type Aliasers = Nothing;
|
type Aliasers = Nothing;
|
||||||
@@ -240,7 +255,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type AssetLocker = ();
|
type AssetLocker = ();
|
||||||
// How to withdraw and deposit an asset.
|
// How to withdraw and deposit an asset.
|
||||||
type AssetTransactor = AssetTransactors;
|
type AssetTransactor = AssetTransactors;
|
||||||
type AssetTrap = PolkadotXcm;
|
type AssetTrap = pallet_erc20_xcm_bridge::AssetTrapWrapper<PolkadotXcm, Runtime>;
|
||||||
type Barrier = Barrier;
|
type Barrier = Barrier;
|
||||||
type CallDispatcher = RuntimeCall;
|
type CallDispatcher = RuntimeCall;
|
||||||
/// When changing this config, keep in mind, that you should collect fees.
|
/// When changing this config, keep in mind, that you should collect fees.
|
||||||
@@ -264,15 +279,12 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type RuntimeCall = RuntimeCall;
|
type RuntimeCall = RuntimeCall;
|
||||||
type SafeCallFilter = Everything;
|
type SafeCallFilter = Everything;
|
||||||
type SubscriptionService = PolkadotXcm;
|
type SubscriptionService = PolkadotXcm;
|
||||||
type Trader = (
|
type Trader = pallet_xcm_weight_trader::Trader<Runtime>;
|
||||||
UsingComponents<WeightToFee, BalancesPalletLocation, AccountId, Balances, ()>,
|
|
||||||
xcm_primitives::FirstAssetTrader<AssetType, AssetManager, XcmFeesToAccount>,
|
|
||||||
);
|
|
||||||
type TransactionalProcessor = FrameTransactionalProcessor;
|
type TransactionalProcessor = FrameTransactionalProcessor;
|
||||||
type UniversalAliases = Nothing;
|
type UniversalAliases = Nothing;
|
||||||
// Teleporting is disabled.
|
// Teleporting is disabled.
|
||||||
type UniversalLocation = UniversalLocation;
|
type UniversalLocation = UniversalLocation;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
type Weigher = XcmWeigher;
|
||||||
type XcmRecorder = PolkadotXcm;
|
type XcmRecorder = PolkadotXcm;
|
||||||
type XcmSender = XcmRouter;
|
type XcmSender = XcmRouter;
|
||||||
}
|
}
|
||||||
@@ -334,7 +346,7 @@ impl pallet_xcm::Config for Runtime {
|
|||||||
type SovereignAccountOf = LocationToAccountId;
|
type SovereignAccountOf = LocationToAccountId;
|
||||||
type TrustedLockers = ();
|
type TrustedLockers = ();
|
||||||
type UniversalLocation = UniversalLocation;
|
type UniversalLocation = UniversalLocation;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
|
type Weigher = XcmWeigher;
|
||||||
/// Rerun benchmarks if you are making changes to runtime configuration.
|
/// Rerun benchmarks if you are making changes to runtime configuration.
|
||||||
type WeightInfo = weights::pallet_xcm::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_xcm::WeightInfo<Runtime>;
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
@@ -372,3 +384,206 @@ parameter_types! {
|
|||||||
].into()
|
].into()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_type_with_key! {
|
||||||
|
pub ParachainMinFee: |location: Location| -> Option<u128> {
|
||||||
|
match (location.parents, location.first_interior()) {
|
||||||
|
// Polkadot AssetHub fee
|
||||||
|
(1, Some(Parachain(1000u32))) => Some(50_000_000u128),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Our currencyId. We distinguish for now between SelfReserve, and Others, defined by their Id.
|
||||||
|
#[derive(Clone, Eq, Debug, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)]
|
||||||
|
pub enum CurrencyId {
|
||||||
|
// Our native token
|
||||||
|
SelfReserve,
|
||||||
|
// Assets representing other chains native tokens
|
||||||
|
ForeignAsset(AssetId),
|
||||||
|
// Erc20 token
|
||||||
|
Erc20 { contract_address: H160 },
|
||||||
|
}
|
||||||
|
|
||||||
|
// How to convert from CurrencyId to Location
|
||||||
|
pub struct CurrencyIdToLocation<AssetXConverter>(sp_std::marker::PhantomData<AssetXConverter>);
|
||||||
|
impl<AssetXConverter> sp_runtime::traits::Convert<CurrencyId, Option<Location>>
|
||||||
|
for CurrencyIdToLocation<AssetXConverter>
|
||||||
|
where
|
||||||
|
AssetXConverter: sp_runtime::traits::MaybeEquivalence<Location, AssetId>,
|
||||||
|
{
|
||||||
|
fn convert(currency: CurrencyId) -> Option<Location> {
|
||||||
|
match currency {
|
||||||
|
CurrencyId::SelfReserve => {
|
||||||
|
let multi: Location = SelfReserve::get();
|
||||||
|
Some(multi)
|
||||||
|
}
|
||||||
|
CurrencyId::ForeignAsset(asset) => AssetXConverter::convert_back(&asset),
|
||||||
|
CurrencyId::Erc20 { contract_address } => {
|
||||||
|
let mut location = Erc20XcmBridgePalletLocation::get();
|
||||||
|
location
|
||||||
|
.push_interior(Junction::AccountKey20 {
|
||||||
|
key: contract_address.0,
|
||||||
|
network: None,
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
Some(location)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wrapper type around `LocationToAccountId` to convert an `AccountId` to type `H160`.
|
||||||
|
pub struct LocationToH160;
|
||||||
|
impl ConvertLocation<H160> for LocationToH160 {
|
||||||
|
fn convert_location(location: &Location) -> Option<H160> {
|
||||||
|
<LocationToAccountId as ConvertLocation<AccountId>>::convert_location(location)
|
||||||
|
.map(Into::into)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
// This is the relative view of erc20 assets.
|
||||||
|
// Identified by this prefix + AccountKey20(contractAddress)
|
||||||
|
// We use the RELATIVE multilocation
|
||||||
|
pub Erc20XcmBridgePalletLocation: Location = Location {
|
||||||
|
parents:0,
|
||||||
|
interior: [
|
||||||
|
PalletInstance(<Erc20XcmBridge as PalletInfoAccess>::index() as u8)
|
||||||
|
].into()
|
||||||
|
};
|
||||||
|
|
||||||
|
// To be able to support almost all erc20 implementations,
|
||||||
|
// we provide a sufficiently high gas limit.
|
||||||
|
pub Erc20XcmBridgeTransferGasLimit: u64 = 800_000;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pallet_erc20_xcm_bridge::Config for Runtime {
|
||||||
|
type AccountIdConverter = LocationToH160;
|
||||||
|
type Erc20MultilocationPrefix = Erc20XcmBridgePalletLocation;
|
||||||
|
type Erc20TransferGasLimit = Erc20XcmBridgeTransferGasLimit;
|
||||||
|
type EvmRunner = pallet_evm::runner::stack::Runner<Self>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The `DOTReserveProvider` overrides the default reserve location for DOT (Polkadot's native token).
|
||||||
|
///
|
||||||
|
/// DOT can exist in multiple locations, and this provider ensures that the reserve is correctly set
|
||||||
|
/// to the AssetHub parachain.
|
||||||
|
///
|
||||||
|
/// - **Default Location:** `{ parents: 1, location: Here }`
|
||||||
|
/// - **Reserve Location on AssetHub:** `{ parents: 1, location: X1(Parachain(AssetHubParaId)) }`
|
||||||
|
///
|
||||||
|
/// This provider ensures that if the asset's ID points to the default "Here" location,
|
||||||
|
/// it will instead be mapped to the AssetHub parachain.
|
||||||
|
pub struct DOTReserveProvider;
|
||||||
|
|
||||||
|
impl Reserve for DOTReserveProvider {
|
||||||
|
fn reserve(asset: &Asset) -> Option<Location> {
|
||||||
|
let AssetId(location) = &asset.id;
|
||||||
|
|
||||||
|
let dot_here = Location::new(1, Here);
|
||||||
|
let dot_asset_hub = AssetHubLocation::get();
|
||||||
|
|
||||||
|
if location == &dot_here {
|
||||||
|
Some(dot_asset_hub) // Reserve is on AssetHub.
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The `BridgedAssetReserveProvider` handles assets that are bridged from external consensus systems
|
||||||
|
/// (e.g., Ethereum) and may have multiple valid reserve locations.
|
||||||
|
///
|
||||||
|
/// Specifically, these bridged assets can have two known reserves:
|
||||||
|
/// 1. **Ethereum-based Reserve:**
|
||||||
|
/// `{ parents: 1, location: X1(GlobalConsensus(Ethereum{ chain_id: 1 })) }`
|
||||||
|
/// 2. **AssetHub Parachain Reserve:**
|
||||||
|
/// `{ parents: 1, location: X1(Parachain(AssetHubParaId)) }`
|
||||||
|
///
|
||||||
|
/// This provider maps the reserve for bridged assets to AssetHub when the asset originates
|
||||||
|
/// from a global consensus system, such as Ethereum.
|
||||||
|
pub struct BridgedAssetReserveProvider;
|
||||||
|
|
||||||
|
impl Reserve for BridgedAssetReserveProvider {
|
||||||
|
fn reserve(asset: &Asset) -> Option<Location> {
|
||||||
|
let AssetId(location) = &asset.id;
|
||||||
|
|
||||||
|
let asset_hub_reserve = AssetHubLocation::get();
|
||||||
|
|
||||||
|
// any asset that has parents > 1 and interior that starts with GlobalConsensus(_) pattern
|
||||||
|
// can be considered a bridged asset.
|
||||||
|
//
|
||||||
|
// `split_global` will return an `Err` if the first item is not a `GlobalConsensus`
|
||||||
|
if location.parents > 1 && location.interior.clone().split_global().is_ok() {
|
||||||
|
Some(asset_hub_reserve)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ReserveProviders;
|
||||||
|
|
||||||
|
impl Reserve for ReserveProviders {
|
||||||
|
fn reserve(asset: &Asset) -> Option<Location> {
|
||||||
|
// Try each provider's reserve method in sequence.
|
||||||
|
DOTReserveProvider::reserve(asset)
|
||||||
|
.or_else(|| BridgedAssetReserveProvider::reserve(asset))
|
||||||
|
.or_else(|| AbsoluteAndRelativeReserve::<SelfLocationAbsolute>::reserve(asset))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl orml_xtokens::Config for Runtime {
|
||||||
|
type AccountIdToLocation = AccountIdToLocation<AccountId>;
|
||||||
|
type Balance = Balance;
|
||||||
|
type BaseXcmWeight = BaseXcmWeight;
|
||||||
|
type CurrencyId = CurrencyId;
|
||||||
|
type CurrencyIdConvert = CurrencyIdToLocation<AsAssetType<AssetId, AssetType, AssetManager>>;
|
||||||
|
type LocationsFilter = Everything;
|
||||||
|
type MaxAssetsForTransfer = MaxAssetsForTransfer;
|
||||||
|
type MinXcmFee = ParachainMinFee;
|
||||||
|
type RateLimiter = ();
|
||||||
|
type RateLimiterId = ();
|
||||||
|
type ReserveProvider = ReserveProviders;
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type SelfLocation = SelfLocation;
|
||||||
|
type UniversalLocation = UniversalLocation;
|
||||||
|
type Weigher = XcmWeigher;
|
||||||
|
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AssetFeesFilter;
|
||||||
|
impl frame_support::traits::Contains<Location> for AssetFeesFilter {
|
||||||
|
fn contains(location: &Location) -> bool {
|
||||||
|
location.parent_count() > 0
|
||||||
|
&& location.first_interior() != Erc20XcmBridgePalletLocation::get().first_interior()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// implement your own business logic for who can add/edit/remove/resume supported assets
|
||||||
|
pub type AddSupportedAssetOrigin = EnsureRoot<AccountId>;
|
||||||
|
pub type EditSupportedAssetOrigin = EnsureRoot<AccountId>;
|
||||||
|
pub type RemoveSupportedAssetOrigin = EnsureRoot<AccountId>;
|
||||||
|
pub type ResumeSupportedAssetOrigin = EnsureRoot<AccountId>;
|
||||||
|
|
||||||
|
impl pallet_xcm_weight_trader::Config for Runtime {
|
||||||
|
type AccountIdToLocation = AccountIdToLocation<AccountId>;
|
||||||
|
type AddSupportedAssetOrigin = AddSupportedAssetOrigin;
|
||||||
|
type AssetLocationFilter = AssetFeesFilter;
|
||||||
|
type AssetTransactor = AssetTransactors;
|
||||||
|
type Balance = Balance;
|
||||||
|
type EditSupportedAssetOrigin = EditSupportedAssetOrigin;
|
||||||
|
type NativeLocation = SelfReserve;
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
type NotFilteredLocation = RelayLocation;
|
||||||
|
type PauseSupportedAssetOrigin = EditSupportedAssetOrigin;
|
||||||
|
type RemoveSupportedAssetOrigin = RemoveSupportedAssetOrigin;
|
||||||
|
type ResumeSupportedAssetOrigin = ResumeSupportedAssetOrigin;
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
// TODO: update this when we update benchmarks
|
||||||
|
type WeightInfo = weights::pallet_xcm_weight_trader::WeightInfo<Runtime>;
|
||||||
|
type WeightToFee = <Runtime as pallet_transaction_payment::Config>::WeightToFee;
|
||||||
|
type XcmFeesAccount = TreasuryAccount;
|
||||||
|
}
|
||||||
|
|||||||
@@ -262,6 +262,10 @@ mod runtime {
|
|||||||
pub type CumulusXcm = cumulus_pallet_xcm;
|
pub type CumulusXcm = cumulus_pallet_xcm;
|
||||||
#[runtime::pallet_index(33)]
|
#[runtime::pallet_index(33)]
|
||||||
pub type MessageQueue = pallet_message_queue;
|
pub type MessageQueue = pallet_message_queue;
|
||||||
|
#[runtime::pallet_index(34)]
|
||||||
|
pub type XTokens = orml_xtokens;
|
||||||
|
#[runtime::pallet_index(35)]
|
||||||
|
pub type XcmWeightTrader = pallet_xcm_weight_trader;
|
||||||
|
|
||||||
// EVM
|
// EVM
|
||||||
#[runtime::pallet_index(40)]
|
#[runtime::pallet_index(40)]
|
||||||
@@ -272,6 +276,8 @@ mod runtime {
|
|||||||
pub type BaseFee = pallet_base_fee;
|
pub type BaseFee = pallet_base_fee;
|
||||||
#[runtime::pallet_index(43)]
|
#[runtime::pallet_index(43)]
|
||||||
pub type EVMChainId = pallet_evm_chain_id;
|
pub type EVMChainId = pallet_evm_chain_id;
|
||||||
|
#[runtime::pallet_index(44)]
|
||||||
|
pub type Erc20XcmBridge = pallet_erc20_xcm_bridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
cumulus_pallet_parachain_system::register_validate_block! {
|
cumulus_pallet_parachain_system::register_validate_block! {
|
||||||
|
|||||||
@@ -11,19 +11,16 @@ use sp_runtime::{
|
|||||||
traits::{BlakeTwo256, IdentifyAccount, Verify},
|
traits::{BlakeTwo256, IdentifyAccount, Verify},
|
||||||
};
|
};
|
||||||
use xcm::VersionedLocation;
|
use xcm::VersionedLocation;
|
||||||
use xcm_builder::{ConvertedConcreteId, PayOverXcm};
|
use xcm_builder::PayOverXcm;
|
||||||
use xcm_executor::traits::JustTry;
|
|
||||||
use xcm_primitives::AsAssetType;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
configs::{xcm_config, TreasuryInteriorLocation},
|
configs::{xcm_config, TreasuryInteriorLocation},
|
||||||
constants::HOURS,
|
constants::HOURS,
|
||||||
AssetManager, Assets,
|
|
||||||
};
|
};
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
configs::{
|
configs::{
|
||||||
xcm_config::RelayLocation, AssetType, FeeAssetId, StakingAdminBodyId,
|
xcm_config::RelayLocation, FeeAssetId, StakingAdminBodyId, ToSiblingBaseDeliveryFee,
|
||||||
ToSiblingBaseDeliveryFee, TransactionByteFee, TreasuryAccount,
|
TransactionByteFee,
|
||||||
},
|
},
|
||||||
constants::{
|
constants::{
|
||||||
BLOCK_PROCESSING_VELOCITY, RELAY_CHAIN_SLOT_DURATION_MILLIS, UNINCLUDED_SEGMENT_CAPACITY,
|
BLOCK_PROCESSING_VELOCITY, RELAY_CHAIN_SLOT_DURATION_MILLIS, UNINCLUDED_SEGMENT_CAPACITY,
|
||||||
@@ -111,23 +108,6 @@ pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
|
|||||||
EnsureXcm<IsVoiceOfBody<RelayLocation, StakingAdminBodyId>>,
|
EnsureXcm<IsVoiceOfBody<RelayLocation, StakingAdminBodyId>>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/// This is the struct that will handle the revenue from xcm fees
|
|
||||||
/// We do not burn anything because we want to mimic exactly what
|
|
||||||
/// the sovereign account has
|
|
||||||
pub type XcmFeesToAccount = xcm_primitives::XcmFeesToAccount<
|
|
||||||
Assets,
|
|
||||||
(
|
|
||||||
ConvertedConcreteId<
|
|
||||||
AssetId,
|
|
||||||
Balance,
|
|
||||||
AsAssetType<AssetId, AssetType, AssetManager>,
|
|
||||||
JustTry,
|
|
||||||
>,
|
|
||||||
),
|
|
||||||
AccountId,
|
|
||||||
TreasuryAccount,
|
|
||||||
>;
|
|
||||||
|
|
||||||
/// These aliases are describing the Beneficiary and AssetKind for the Treasury pallet
|
/// These aliases are describing the Beneficiary and AssetKind for the Treasury pallet
|
||||||
pub type Beneficiary = VersionedLocation;
|
pub type Beneficiary = VersionedLocation;
|
||||||
pub type AssetKind = VersionedLocatableAsset;
|
pub type AssetKind = VersionedLocatableAsset;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ pub mod pallet_treasury;
|
|||||||
pub mod pallet_utility;
|
pub mod pallet_utility;
|
||||||
pub mod pallet_whitelist;
|
pub mod pallet_whitelist;
|
||||||
pub mod pallet_xcm;
|
pub mod pallet_xcm;
|
||||||
|
pub mod pallet_xcm_weight_trader;
|
||||||
pub mod paritydb_weights;
|
pub mod paritydb_weights;
|
||||||
pub mod rocksdb_weights;
|
pub mod rocksdb_weights;
|
||||||
pub use block_weights::constants::BlockExecutionWeight;
|
pub use block_weights::constants::BlockExecutionWeight;
|
||||||
|
|||||||
@@ -50,26 +50,6 @@ impl<T: frame_system::Config> pallet_asset_manager::WeightInfo for WeightInfo<T>
|
|||||||
.saturating_add(T::DbWeight::get().reads(3))
|
.saturating_add(T::DbWeight::get().reads(3))
|
||||||
.saturating_add(T::DbWeight::get().writes(4))
|
.saturating_add(T::DbWeight::get().writes(4))
|
||||||
}
|
}
|
||||||
/// Storage: `AssetManager::AssetTypeId` (r:1 w:0)
|
|
||||||
/// Proof: `AssetManager::AssetTypeId` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `AssetManager::SupportedFeePaymentAssets` (r:1 w:1)
|
|
||||||
/// Proof: `AssetManager::SupportedFeePaymentAssets` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `AssetManager::AssetTypeUnitsPerSecond` (r:0 w:1)
|
|
||||||
/// Proof: `AssetManager::AssetTypeUnitsPerSecond` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// The range of component `x` is `[5, 100]`.
|
|
||||||
fn set_asset_units_per_second(x: u32, ) -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `611 + x * (9 ±0)`
|
|
||||||
// Estimated: `4000 + x * (10 ±0)`
|
|
||||||
// Minimum execution time: 24_022_000 picoseconds.
|
|
||||||
Weight::from_parts(24_974_937, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 4000))
|
|
||||||
// Standard Error: 3_934
|
|
||||||
.saturating_add(Weight::from_parts(658_977, 0).saturating_mul(x.into()))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(2))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
|
||||||
.saturating_add(Weight::from_parts(0, 10).saturating_mul(x.into()))
|
|
||||||
}
|
|
||||||
/// Storage: `AssetManager::SupportedFeePaymentAssets` (r:1 w:1)
|
/// Storage: `AssetManager::SupportedFeePaymentAssets` (r:1 w:1)
|
||||||
/// Proof: `AssetManager::SupportedFeePaymentAssets` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
/// Proof: `AssetManager::SupportedFeePaymentAssets` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||||
/// Storage: `AssetManager::AssetIdType` (r:1 w:1)
|
/// Storage: `AssetManager::AssetIdType` (r:1 w:1)
|
||||||
@@ -79,36 +59,15 @@ impl<T: frame_system::Config> pallet_asset_manager::WeightInfo for WeightInfo<T>
|
|||||||
/// Storage: `AssetManager::AssetTypeId` (r:0 w:2)
|
/// Storage: `AssetManager::AssetTypeId` (r:0 w:2)
|
||||||
/// Proof: `AssetManager::AssetTypeId` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
/// Proof: `AssetManager::AssetTypeId` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||||
/// The range of component `x` is `[5, 100]`.
|
/// The range of component `x` is `[5, 100]`.
|
||||||
fn change_existing_asset_type(x: u32, ) -> Weight {
|
fn change_existing_asset_type() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `926 + x * (13 ±0)`
|
// Measured: `82`
|
||||||
// Estimated: `4309 + x * (15 ±0)`
|
// Estimated: `3639`
|
||||||
// Minimum execution time: 37_311_000 picoseconds.
|
// Minimum execution time: 39_040_000 picoseconds.
|
||||||
Weight::from_parts(38_598_190, 0)
|
Weight::from_parts(39_649_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 4309))
|
.saturating_add(Weight::from_parts(0, 3639))
|
||||||
// Standard Error: 3_797
|
|
||||||
.saturating_add(Weight::from_parts(702_853, 0).saturating_mul(x.into()))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(3))
|
.saturating_add(T::DbWeight::get().reads(3))
|
||||||
.saturating_add(T::DbWeight::get().writes(6))
|
.saturating_add(T::DbWeight::get().writes(4))
|
||||||
.saturating_add(Weight::from_parts(0, 15).saturating_mul(x.into()))
|
|
||||||
}
|
|
||||||
/// Storage: `AssetManager::SupportedFeePaymentAssets` (r:1 w:1)
|
|
||||||
/// Proof: `AssetManager::SupportedFeePaymentAssets` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
|
||||||
/// Storage: `AssetManager::AssetTypeUnitsPerSecond` (r:0 w:1)
|
|
||||||
/// Proof: `AssetManager::AssetTypeUnitsPerSecond` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
|
||||||
/// The range of component `x` is `[5, 100]`.
|
|
||||||
fn remove_supported_asset(x: u32, ) -> Weight {
|
|
||||||
// Proof Size summary in bytes:
|
|
||||||
// Measured: `196 + x * (5 ±0)`
|
|
||||||
// Estimated: `1678 + x * (5 ±0)`
|
|
||||||
// Minimum execution time: 19_119_000 picoseconds.
|
|
||||||
Weight::from_parts(19_212_212, 0)
|
|
||||||
.saturating_add(Weight::from_parts(0, 1678))
|
|
||||||
// Standard Error: 3_489
|
|
||||||
.saturating_add(Weight::from_parts(562_250, 0).saturating_mul(x.into()))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(1))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(2))
|
|
||||||
.saturating_add(Weight::from_parts(0, 5).saturating_mul(x.into()))
|
|
||||||
}
|
}
|
||||||
/// Storage: `AssetManager::SupportedFeePaymentAssets` (r:1 w:1)
|
/// Storage: `AssetManager::SupportedFeePaymentAssets` (r:1 w:1)
|
||||||
/// Proof: `AssetManager::SupportedFeePaymentAssets` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
/// Proof: `AssetManager::SupportedFeePaymentAssets` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
|
||||||
@@ -119,17 +78,14 @@ impl<T: frame_system::Config> pallet_asset_manager::WeightInfo for WeightInfo<T>
|
|||||||
/// Storage: `AssetManager::AssetTypeId` (r:0 w:1)
|
/// Storage: `AssetManager::AssetTypeId` (r:0 w:1)
|
||||||
/// Proof: `AssetManager::AssetTypeId` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
/// Proof: `AssetManager::AssetTypeId` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||||
/// The range of component `x` is `[5, 100]`.
|
/// The range of component `x` is `[5, 100]`.
|
||||||
fn remove_existing_asset_type(x: u32, ) -> Weight {
|
fn remove_existing_asset_type() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `482 + x * (10 ±0)`
|
// Measured: `82`
|
||||||
// Estimated: `3955 + x * (10 ±0)`
|
// Estimated: `3639`
|
||||||
// Minimum execution time: 26_737_000 picoseconds.
|
// Minimum execution time: 39_040_000 picoseconds.
|
||||||
Weight::from_parts(27_944_215, 0)
|
Weight::from_parts(39_649_000, 0)
|
||||||
.saturating_add(Weight::from_parts(0, 3955))
|
.saturating_add(Weight::from_parts(0, 3639))
|
||||||
// Standard Error: 4_073
|
.saturating_add(T::DbWeight::get().reads(3))
|
||||||
.saturating_add(Weight::from_parts(587_318, 0).saturating_mul(x.into()))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(2))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(4))
|
.saturating_add(T::DbWeight::get().writes(4))
|
||||||
.saturating_add(Weight::from_parts(0, 10).saturating_mul(x.into()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
// Copyright 2024 Moonbeam foundation
|
||||||
|
// This file is part of Moonbeam.
|
||||||
|
|
||||||
|
// Moonbeam 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.
|
||||||
|
|
||||||
|
// Moonbeam 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 Moonbeam. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Autogenerated weights for `pallet_xcm_weight_trader`
|
||||||
|
//!
|
||||||
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||||
|
//! DATE: 2024-09-13, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||||
|
//! WORST CASE MAP SIZE: `1000000`
|
||||||
|
//! HOSTNAME: `ip-10-0-0-176`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz`
|
||||||
|
//! WASM-EXECUTION: Compiled, CHAIN: Some("moonbase-dev"), DB CACHE: 1024
|
||||||
|
|
||||||
|
// Executed Command:
|
||||||
|
// ./target/production/moonbeam
|
||||||
|
// benchmark
|
||||||
|
// pallet
|
||||||
|
// --chain=moonbase-dev
|
||||||
|
// --steps=50
|
||||||
|
// --repeat=20
|
||||||
|
// --pallet=pallet_xcm_weight_trader
|
||||||
|
// --extrinsic=*
|
||||||
|
// --wasm-execution=compiled
|
||||||
|
// --header=./file_header.txt
|
||||||
|
// --template=./benchmarking/frame-weight-template.hbs
|
||||||
|
// --output=./runtime/common/src/weights/
|
||||||
|
|
||||||
|
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
|
#![allow(unused_parens)]
|
||||||
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
|
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||||
|
use sp_std::marker::PhantomData;
|
||||||
|
|
||||||
|
/// Weights for `pallet_xcm_weight_trader`.
|
||||||
|
pub struct WeightInfo<T>(PhantomData<T>);
|
||||||
|
impl<T: frame_system::Config> pallet_xcm_weight_trader::WeightInfo for WeightInfo<T> {
|
||||||
|
/// Storage: `XcmWeightTrader::SupportedAssets` (r:1 w:1)
|
||||||
|
/// Proof: `XcmWeightTrader::SupportedAssets` (`max_values`: None, `max_size`: Some(635), added: 3110, mode: `MaxEncodedLen`)
|
||||||
|
fn add_asset() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `42`
|
||||||
|
// Estimated: `4100`
|
||||||
|
// Minimum execution time: 9_432_000 picoseconds.
|
||||||
|
Weight::from_parts(9_644_000, 4100)
|
||||||
|
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||||
|
}
|
||||||
|
/// Storage: `XcmWeightTrader::SupportedAssets` (r:1 w:1)
|
||||||
|
/// Proof: `XcmWeightTrader::SupportedAssets` (`max_values`: None, `max_size`: Some(635), added: 3110, mode: `MaxEncodedLen`)
|
||||||
|
fn edit_asset() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `102`
|
||||||
|
// Estimated: `4100`
|
||||||
|
// Minimum execution time: 10_261_000 picoseconds.
|
||||||
|
Weight::from_parts(10_540_000, 4100)
|
||||||
|
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||||
|
}
|
||||||
|
/// Storage: `XcmWeightTrader::SupportedAssets` (r:1 w:1)
|
||||||
|
/// Proof: `XcmWeightTrader::SupportedAssets` (`max_values`: None, `max_size`: Some(635), added: 3110, mode: `MaxEncodedLen`)
|
||||||
|
fn resume_asset_support() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `102`
|
||||||
|
// Estimated: `4100`
|
||||||
|
// Minimum execution time: 10_153_000 picoseconds.
|
||||||
|
Weight::from_parts(10_537_000, 4100)
|
||||||
|
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||||
|
}
|
||||||
|
/// Storage: `XcmWeightTrader::SupportedAssets` (r:1 w:1)
|
||||||
|
/// Proof: `XcmWeightTrader::SupportedAssets` (`max_values`: None, `max_size`: Some(635), added: 3110, mode: `MaxEncodedLen`)
|
||||||
|
fn pause_asset_support() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `102`
|
||||||
|
// Estimated: `4100`
|
||||||
|
// Minimum execution time: 10_029_000 picoseconds.
|
||||||
|
Weight::from_parts(10_456_000, 4100)
|
||||||
|
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||||
|
}
|
||||||
|
/// Storage: `XcmWeightTrader::SupportedAssets` (r:1 w:1)
|
||||||
|
/// Proof: `XcmWeightTrader::SupportedAssets` (`max_values`: None, `max_size`: Some(635), added: 3110, mode: `MaxEncodedLen`)
|
||||||
|
fn remove_asset() -> Weight {
|
||||||
|
// Proof Size summary in bytes:
|
||||||
|
// Measured: `102`
|
||||||
|
// Estimated: `4100`
|
||||||
|
// Minimum execution time: 9_844_000 picoseconds.
|
||||||
|
Weight::from_parts(10_218_000, 4100)
|
||||||
|
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||||
|
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user