From 3f1302da70dd2b305b4ebd4b94ddccb05932b44e Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Tue, 28 May 2024 15:13:20 +0200 Subject: [PATCH] Basilisk Integration (#51) --- .gitignore | 2 +- Cargo.lock | 155 ++++- Cargo.toml | 14 +- README.md | 9 +- chopsticks/bajun.yml | 2 +- chopsticks/basilisk.yml | 27 + runtime/bajun/Cargo.toml | 29 + runtime/bajun/src/assets.rs | 98 ++++ runtime/bajun/src/lib.rs | 32 +- runtime/bajun/src/weights/mod.rs | 3 + .../src/weights/pallet_asset_registry.rs | 82 +++ runtime/bajun/src/weights/pallet_assets.rs | 530 ++++++++++++++++++ runtime/bajun/src/weights/pallet_xcm.rs | 418 ++++++++++++++ runtime/bajun/src/xcm_config.rs | 460 ++++++++++++--- 14 files changed, 1769 insertions(+), 92 deletions(-) create mode 100644 chopsticks/basilisk.yml create mode 100644 runtime/bajun/src/assets.rs create mode 100644 runtime/bajun/src/weights/pallet_asset_registry.rs create mode 100644 runtime/bajun/src/weights/pallet_assets.rs create mode 100644 runtime/bajun/src/weights/pallet_xcm.rs diff --git a/.gitignore b/.gitignore index 76f7310..186bf65 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ build/ /target # Chopsticks -/chopsticks/*.db.sqlite* +/chopsticks/dbs/ # genesis state and chain-spec dumps /chain_dumps diff --git a/Cargo.lock b/Cargo.lock index 6daa097..17d39ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -439,6 +439,30 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "assets-common" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c72ef4a7873eb1aeaf57fa0aa2d330c1ef6e2ba2bfcb26b338612d6133c789f" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "impl-trait-for-tuples", + "log", + "pallet-asset-conversion", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -657,7 +681,7 @@ dependencies = [ [[package]] name = "bajun-node" -version = "0.4.1" +version = "0.5.0" dependencies = [ "async-trait", "bajun-runtime", @@ -734,8 +758,9 @@ dependencies = [ [[package]] name = "bajun-runtime" -version = "0.4.1" +version = "0.5.0" dependencies = [ + "assets-common", "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", @@ -754,12 +779,18 @@ dependencies = [ "hex-literal", "log", "orml-pallets-benchmarking", + "orml-traits", "orml-vesting", + "orml-xcm", + "orml-xcm-support", + "orml-xtokens", "pallet-ajuna-affiliates", "pallet-ajuna-awesome-avatars", "pallet-ajuna-awesome-avatars-benchmarking", "pallet-ajuna-nft-transfer", "pallet-ajuna-tournament", + "pallet-asset-registry", + "pallet-assets", "pallet-aura", "pallet-authorship", "pallet-balances", @@ -810,6 +841,7 @@ dependencies = [ "staging-xcm-builder", "staging-xcm-executor", "substrate-wasm-builder", + "xcm-primitives", ] [[package]] @@ -6064,6 +6096,43 @@ dependencies = [ "sp-std", ] +[[package]] +name = "orml-traits" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598e41658df928ddcb07743ab376fdd0c2467ca0f1124c15e82283dfd96dc5d0" +dependencies = [ + "frame-support", + "impl-trait-for-tuples", + "num-traits", + "orml-utilities", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "staging-xcm", +] + +[[package]] +name = "orml-utilities" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "539cb12181b6cd6587ea3501acc05de3190ae9498fcc08fb54afad01c3ccc99a" +dependencies = [ + "frame-support", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "orml-vesting" version = "0.10.0" @@ -6080,6 +6149,58 @@ dependencies = [ "sp-std", ] +[[package]] +name = "orml-xcm" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66ad1094bb068a95738ca9f25df77f1a4cd32990662409a7d24c85d358b046d7" +dependencies = [ + "frame-support", + "frame-system", + "pallet-xcm", + "parity-scale-codec", + "scale-info", + "sp-std", + "staging-xcm", +] + +[[package]] +name = "orml-xcm-support" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d05104ca96aa79b4dd48bd2d9e43ed58520a029108ecee26924fe1e909f0046" +dependencies = [ + "frame-support", + "orml-traits", + "parity-scale-codec", + "sp-runtime", + "sp-std", + "staging-xcm", + "staging-xcm-executor", +] + +[[package]] +name = "orml-xtokens" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e50b4d05d1c4a15cf672580f4253404dd9c8c31282d7ec291b69b2148c4ba222" +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]] name = "pallet-ajuna-affiliates" version = "0.7.1" @@ -6200,6 +6321,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-asset-registry" +version = "0.0.1" +source = "git+https://github.com/integritee-network/pallets.git?branch=cl/polkadot-v1.10.0#81fa886ff4ce61097351ca2c18ada29087c111fb" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-assets", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", + "staging-xcm", + "xcm-primitives", +] + [[package]] name = "pallet-asset-tx-payment" version = "32.0.0" @@ -14881,6 +15020,18 @@ dependencies = [ "staging-xcm", ] +[[package]] +name = "xcm-primitives" +version = "0.0.1" +source = "git+https://github.com/integritee-network/pallets.git?branch=cl/polkadot-v1.10.0#81fa886ff4ce61097351ca2c18ada29087c111fb" +dependencies = [ + "frame-support", + "sp-runtime", + "sp-std", + "staging-xcm", + "staging-xcm-executor", +] + [[package]] name = "xcm-procedural" version = "8.0.0" diff --git a/Cargo.toml b/Cargo.toml index 3785e4f..1aa0fae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ authors = [ "Ajuna Network " ] edition = "2021" homepage = "https://ajuna.io" repository = "https://github.com/ajuna-network/Ajuna" -version = "0.4.1" +version = "0.5.0" [workspace] resolver = "2" @@ -32,6 +32,7 @@ parity-scale-codec = { version = "3.0.0", default-features = false } scale-info = { version = "2.1.1", default-features = false } # Substrate +assets-common = { version = "0.11.0", default-features = false } frame-benchmarking = { version = "32.0.0", default-features = false } frame-benchmarking-cli = { version = "36.0.0" } frame-executive = { version = "32.0.0", default-features = false } @@ -40,6 +41,7 @@ frame-system = { version = "32.0.0", default-featu frame-system-benchmarking = { version = "32.0.0", default-features = false } frame-system-rpc-runtime-api = { version = "30.0.0", default-features = false } frame-try-runtime = { version = "0.38.0", default-features = false } +pallet-assets = { version = "33.0.0", default-features = false } pallet-aura = { version = "31.0.0", default-features = false } pallet-authorship = { version = "32.0.0", default-features = false } pallet-balances = { version = "33.0.0", default-features = false } @@ -145,12 +147,16 @@ cumulus-relay-chain-inprocess-interface = { version = "0.11.0", default-features cumulus-relay-chain-interface = { version = "0.11.0" } cumulus-relay-chain-minimal-node = { version = "0.11.0", default-features = false } cumulus-relay-chain-rpc-interface = { version = "0.11.0", default-features = false } -pallet-collator-selection = { version = "13.0.0", default-features = false } +pallet-collator-selection = { version = "13.0.1", default-features = false } parachains-common = { version = "11.0.0", default-features = false } staging-parachain-info = { version = "0.11.0", default-features = false } # ORML +orml-traits = { version = "0.10.0", default-features = false } orml-vesting = { version = "0.10.0", default-features = false } +orml-xcm = { version = "0.10.0", default-features = false } +orml-xcm-support = { version = "0.10.0", default-features = false } +orml-xtokens = { version = "0.10.0", default-features = false } # Runtime bajun-runtime = { path = "runtime/bajun" } @@ -165,6 +171,10 @@ pallet-ajuna-nft-staking = { git = "https://github.com/ajuna-ne pallet-ajuna-tournament = { git = "https://github.com/ajuna-network/ajuna-pallets.git", tag = "v0.7.1", default-features = false } orml-pallets-benchmarking = { git = "https://github.com/ajuna-network/ajuna-pallets.git", tag = "v0.7.1", default-features = false } +# integritee pallets +pallet-asset-registry = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "cl/polkadot-v1.10.0" } +xcm-primitives = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "cl/polkadot-v1.10.0" } + [profile.production] codegen-units = 1 inherits = "release" diff --git a/README.md b/README.md index 861bf32..4522f0a 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,14 @@ Then we can send an arbitrary extrinsic to trigger the next block and observe th ### Test XCM stuff -TBD when we actually start setting up XCM. +Test Basilisk integration. Note: the tx links will work only if the local setup with chopsticks is running. + +1. Setup local network + with `npx @acala-network/chopsticks@latest xcm --p=chopsticks/bajun.yml --p=chopsticks/basilisk.yml` +2. Transfer from Bajun to Basilisk: Our token has token id 18 on basilisk, so you can send this + tx: [Transfer Bajun to Alice on Basilisk](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2Flocalhost%3A8000#/extrinsics/decode/0x2300000010a5d4e8000000000000000000000003010200a9200100d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d00) +3. Transfer from Basilisk to + Bajun: [Transfer Bajun to Alice Stash on Bajun](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2Flocalhost%3A8001#/extrinsics/decode/0x9a001200000000e87648170000000000000000000000030102001d210100be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f00) ### Test Governance execution diff --git a/chopsticks/bajun.yml b/chopsticks/bajun.yml index e1e0681..112801f 100644 --- a/chopsticks/bajun.yml +++ b/chopsticks/bajun.yml @@ -6,7 +6,7 @@ endpoint: - wss://bajun.public.curie.radiumblock.co/ws mock-signature-host: true block: ${env.BAJUN_PARACHAIN_BLOCK_NUMBER} -db: ./chopsticks/bajun-parachain.db.sqlite +db: ./chopsticks/dbs/bajun/db.sqlite runtime-log-level: 5 # wasm-override: bajun_runtime.wasm diff --git a/chopsticks/basilisk.yml b/chopsticks/basilisk.yml new file mode 100644 index 0000000..200f6ca --- /dev/null +++ b/chopsticks/basilisk.yml @@ -0,0 +1,27 @@ +endpoint: + - wss://basilisk-rpc.dwellir.com +mock-signature-host: true +db: ./chopsticks/dbs/basilisk/db.sqlite +runtime-log-level: 5 + +import-storage: + System: + Account: # Give our dev accounts some funds + - - - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice + - providers: 1 + data: + free: 1000000000000000 + - - - 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty # Bob + - providers: 1 + data: + free: 1000000000000000 + - - - 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y # Charlie + - providers: 1 + data: + free: 1000000000000000 + Council: + Members: + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + TechnicalCommittee: + Members: + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \ No newline at end of file diff --git a/runtime/bajun/Cargo.toml b/runtime/bajun/Cargo.toml index 0ca5ced..e4dd7e8 100644 --- a/runtime/bajun/Cargo.toml +++ b/runtime/bajun/Cargo.toml @@ -22,6 +22,7 @@ parity-scale-codec = { workspace = true } scale-info = { workspace = true, features = [ "derive" ] } # Substrate +assets-common = { workspace = true } frame-benchmarking = { workspace = true, optional = true } frame-executive = { workspace = true } frame-support = { workspace = true } @@ -29,6 +30,7 @@ frame-system = { workspace = true } frame-system-benchmarking = { workspace = true, optional = true } frame-system-rpc-runtime-api = { workspace = true } frame-try-runtime = { workspace = true, optional = true } +pallet-assets = { workspace = true } pallet-aura = { workspace = true } pallet-authorship = { workspace = true } pallet-balances = { workspace = true } @@ -88,7 +90,11 @@ parachains-common = { workspace = true } staging-parachain-info = { workspace = true } # ORML +orml-traits = { workspace = true } orml-vesting = { workspace = true } +orml-xcm = { workspace = true } +orml-xcm-support = { workspace = true } +orml-xtokens = { workspace = true } # Ajuna Pallets pallet-ajuna-affiliates = { workspace = true } @@ -98,9 +104,14 @@ pallet-ajuna-nft-transfer = { workspace = true } pallet-ajuna-tournament = { workspace = true } orml-pallets-benchmarking = { workspace = true, optional = true } +# integritee pallets +pallet-asset-registry = { workspace = true } +xcm-primitives = { workspace = true } + [features] default = [ "std" ] std = [ + "assets-common/std", "parity-scale-codec/std", "log/std", "scale-info/std", @@ -120,8 +131,13 @@ std = [ "frame-system-rpc-runtime-api/std", "frame-system/std", "frame-try-runtime/std", + "orml-traits/std", "orml-vesting/std", + "orml-xcm/std", + "orml-xcm-support/std", + "orml-xtokens/std", "orml-pallets-benchmarking?/std", + "pallet-assets/std", "pallet-aura/std", "pallet-authorship/std", "pallet-balances/std", @@ -167,6 +183,9 @@ std = [ "staging-xcm/std", "staging-xcm-builder/std", "staging-xcm-executor/std", + # integritee + "pallet-asset-registry/std", + "xcm-primitives/std", # ajuna "pallet-ajuna-affiliates/std", "pallet-ajuna-awesome-avatars/std", @@ -176,6 +195,7 @@ std = [ ] runtime-benchmarks = [ + "assets-common/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", @@ -187,7 +207,9 @@ runtime-benchmarks = [ "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "orml-vesting/runtime-benchmarks", + "orml-xtokens/runtime-benchmarks", "orml-pallets-benchmarking/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "pallet-collective/runtime-benchmarks", @@ -212,6 +234,8 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "staging-xcm-builder/runtime-benchmarks", "staging-xcm-executor/runtime-benchmarks", + # integritee + "pallet-asset-registry/runtime-benchmarks", # ajuna "pallet-ajuna-affiliates/runtime-benchmarks", "pallet-ajuna-awesome-avatars/runtime-benchmarks", @@ -230,6 +254,9 @@ try-runtime = [ "frame-support/try-runtime", "frame-try-runtime/try-runtime", "orml-vesting/try-runtime", + "orml-xcm/try-runtime", + "orml-xtokens/try-runtime", + "pallet-assets/try-runtime", "pallet-aura/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", @@ -256,6 +283,8 @@ try-runtime = [ "polkadot-runtime-common/try-runtime", "sp-runtime/try-runtime", "staging-parachain-info/try-runtime", + # integritee + "pallet-asset-registry/try-runtime", # ajuna "pallet-ajuna-affiliates/try-runtime", "pallet-ajuna-awesome-avatars/try-runtime", diff --git a/runtime/bajun/src/assets.rs b/runtime/bajun/src/assets.rs new file mode 100644 index 0000000..dac2321 --- /dev/null +++ b/runtime/bajun/src/assets.rs @@ -0,0 +1,98 @@ +// Ajuna Node +// Copyright (C) 2022 BlogaTech AG + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program 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 Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +use crate::{ + weights, AccountId, Assets, Balance, Balances, Runtime, RuntimeEvent, RuntimeOrigin, BAJUN, + MILLI_BAJUN, +}; +use frame_support::{ + pallet_prelude::ConstU32, + traits::{ConstU128, EnsureOriginWithArg}, +}; +use frame_system::EnsureRoot; +use parachains_common::AssetIdForTrustBackedAssets; + +pub type AssetBalance = Balance; + +/// always denies creation of assets +pub struct NoAssetCreators; +impl EnsureOriginWithArg for NoAssetCreators { + type Success = AccountId; + + fn try_origin( + o: RuntimeOrigin, + _a: &AssetIdForTrustBackedAssets, + ) -> Result { + Err(o) + } + + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin(_a: &AssetIdForTrustBackedAssets) -> Result { + Err(()) + } +} + +pub type MainAssetsInstance = pallet_assets::Instance1; +impl pallet_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = AssetBalance; + type RemoveItemsLimit = ConstU32<1000>; + type AssetId = AssetIdForTrustBackedAssets; + type AssetIdParameter = parity_scale_codec::Compact; + type Currency = Balances; + type CreateOrigin = NoAssetCreators; //assets can only be created by root + type ForceOrigin = EnsureRoot; + type AssetDeposit = ConstU128<{ BAJUN }>; + type AssetAccountDeposit = ConstU128<{ BAJUN }>; + type MetadataDepositBase = ConstU128<{ BAJUN }>; + type MetadataDepositPerByte = ConstU128<{ 10 * MILLI_BAJUN }>; + type ApprovalDeposit = ConstU128<{ 10 * MILLI_BAJUN }>; + type StringLimit = ConstU32<50>; + type Freezer = (); + type Extra = (); + type CallbackHandle = (); + type WeightInfo = weights::pallet_assets::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); +} + +#[cfg(feature = "runtime-benchmarks")] +pub struct AssetRegistryBenchmarkHelper; +#[cfg(feature = "runtime-benchmarks")] +impl pallet_asset_registry::BenchmarkHelper + for AssetRegistryBenchmarkHelper +{ + fn get_registered_asset() -> AssetIdForTrustBackedAssets { + use sp_runtime::traits::StaticLookup; + + let root = frame_system::RawOrigin::Root.into(); + let asset_id = 1; + let caller = frame_benchmarking::whitelisted_caller(); + let caller_lookup = ::Lookup::unlookup(caller); + Assets::force_create(root, asset_id.into(), caller_lookup, true, 1) + .expect("Should have been able to force create asset"); + asset_id + } +} + +impl pallet_asset_registry::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type ReserveAssetModifierOrigin = EnsureRoot; + type Assets = Assets; + type WeightInfo = weights::pallet_asset_registry::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = AssetRegistryBenchmarkHelper; +} diff --git a/runtime/bajun/src/lib.rs b/runtime/bajun/src/lib.rs index 5b09321..7a0d9dd 100644 --- a/runtime/bajun/src/lib.rs +++ b/runtime/bajun/src/lib.rs @@ -22,13 +22,14 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +mod assets; mod gov; mod proxy_type; mod weights; pub mod xcm_config; use crate::gov::EnsureRootOrMoreThanHalfCouncil; -use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; +use cumulus_primitives_core::AggregateMessageOrigin; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use smallvec::smallvec; use sp_api::impl_runtime_apis; @@ -54,7 +55,7 @@ use frame_support::{ traits::{ fungible::HoldConsideration, tokens::{PayFromAccount, UnityAssetBalanceConversion}, - AsEnsureOriginWithArg, ConstBool, Contains, LinearStoragePrice, TransformOrigin, + AsEnsureOriginWithArg, ConstBool, Contains, LinearStoragePrice, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -72,7 +73,6 @@ use pallet_transaction_payment::CurrencyAdapter; use scale_info::TypeInfo; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; -use xcm_config::XcmOriginToTransactDispatchOrigin; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -86,11 +86,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use staging_xcm::latest::prelude::BodyId; use pallet_nfts::{AttributeNamespace, Call as NftsCall}; -use parachains_common::{ - message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - BlockNumber, Hash, Header, -}; -use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; +use parachains_common::{message_queue::NarrowOriginToSibling, BlockNumber, Hash, Header}; use sp_runtime::traits::{IdentifyAccount, IdentityLookup, Verify}; parameter_types! { @@ -219,7 +215,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("bajun"), impl_name: create_runtime_str!("bajun"), authoring_version: 1, - spec_version: 401, + spec_version: 500, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -582,18 +578,6 @@ impl staging_parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} -impl cumulus_pallet_xcmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ChannelInfo = ParachainSystem; - type VersionWrapper = (); - type MaxInboundSuspended = sp_core::ConstU32<1_000>; - type ControllerOrigin = EnsureRoot; - type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; - type PriceForSiblingDelivery = NoPriceForMessageDelivery; - type XcmpQueue = TransformOrigin; -} - parameter_types! { pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block; } @@ -960,6 +944,8 @@ construct_runtime!( CumulusXcm: cumulus_pallet_xcm = 32, // DmpQueue: cumulus_pallet_dmp_queue = 33, MessageQueue: pallet_message_queue = 34, + XTokens: orml_xtokens = 35, + OrmlXcm: orml_xcm = 36, // Governance Sudo: pallet_sudo = 40, @@ -987,6 +973,10 @@ construct_runtime!( // Indexes 80-89 should be reserved for Tournament instances TournamentAAA: pallet_ajuna_tournament:: = 80, + + // Assets related stuff + Assets: pallet_assets:: = 90, + AssetRegistry: pallet_asset_registry = 91, } ); diff --git a/runtime/bajun/src/weights/mod.rs b/runtime/bajun/src/weights/mod.rs index 0399748..c651ce3 100644 --- a/runtime/bajun/src/weights/mod.rs +++ b/runtime/bajun/src/weights/mod.rs @@ -26,6 +26,8 @@ pub mod cumulus_pallet_parachain_system; pub mod cumulus_pallet_xcmp_queue; pub mod frame_system; pub mod orml_vesting; +pub mod pallet_asset_registry; +pub mod pallet_assets; pub mod pallet_balances; pub mod pallet_collator_selection; pub mod pallet_collective; @@ -44,3 +46,4 @@ pub mod pallet_sudo; pub mod pallet_timestamp; pub mod pallet_treasury; pub mod pallet_utility; +pub mod pallet_xcm; diff --git a/runtime/bajun/src/weights/pallet_asset_registry.rs b/runtime/bajun/src/weights/pallet_asset_registry.rs new file mode 100644 index 0000000..c51f8be --- /dev/null +++ b/runtime/bajun/src/weights/pallet_asset_registry.rs @@ -0,0 +1,82 @@ +// Ajuna Node +// Copyright (C) 2022 BlogaTech AG + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program 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 Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +//! Autogenerated weights for `pallet_asset_registry` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-10-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `runner-nbnwcyh-project-647-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("trappist-dev")`, DB CACHE: 1024 + +// Executed Command: +// ./target/production/trappist-node +// benchmark +// pallet +// --chain=trappist-dev +// --steps=50 +// --repeat=20 +// --no-storage-info +// --no-median-slopes +// --no-min-squares +// --pallet=pallet_asset_registry +// --extrinsic=* +// --wasm-execution=compiled +// --header=./templates/file_header.txt +// --output=./runtime/trappist/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_registry`. +pub struct WeightInfo(PhantomData); +impl pallet_asset_registry::WeightInfo for WeightInfo { + /// Storage: `Assets::Asset` (r:1 w:0) + /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::AssetIdLocation` (r:1 w:1) + /// Proof: `AssetRegistry::AssetIdLocation` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::AssetLocationId` (r:0 w:1) + /// Proof: `AssetRegistry::AssetLocationId` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn register_reserve_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `123` + // Estimated: `4087` + // Minimum execution time: 19_271_000 picoseconds. + Weight::from_parts(19_590_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `AssetRegistry::AssetIdLocation` (r:1 w:1) + /// Proof: `AssetRegistry::AssetIdLocation` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::AssetLocationId` (r:0 w:1) + /// Proof: `AssetRegistry::AssetLocationId` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn unregister_reserve_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `107` + // Estimated: `4087` + // Minimum execution time: 15_981_000 picoseconds. + Weight::from_parts(16_448_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } +} diff --git a/runtime/bajun/src/weights/pallet_assets.rs b/runtime/bajun/src/weights/pallet_assets.rs new file mode 100644 index 0000000..23e6eb1 --- /dev/null +++ b/runtime/bajun/src/weights/pallet_assets.rs @@ -0,0 +1,530 @@ +// Ajuna Node +// Copyright (C) 2022 BlogaTech AG + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program 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 Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +//! Autogenerated weights for `pallet_assets` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-06-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), 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=* +// --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 +// --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(PhantomData); +impl pallet_assets::WeightInfo for WeightInfo { + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `3675` + // Minimum execution time: 26_803_000 picoseconds. + Weight::from_parts(27_212_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn force_create() -> Weight { + // Proof Size summary in bytes: + // Measured: `6` + // Estimated: `3675` + // Minimum execution time: 11_413_000 picoseconds. + Weight::from_parts(11_755_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn start_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `277` + // Estimated: `3675` + // Minimum execution time: 13_649_000 picoseconds. + Weight::from_parts(13_992_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1001 w:1000) + /// Proof: Assets 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]`. + 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_659_000 picoseconds. + Weight::from_parts(16_877_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + // Standard Error: 4_837 + .saturating_add(Weight::from_parts(12_015_579, 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: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1001 w:1000) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) + /// The range of component `a` is `[0, 1000]`. + /// The range of component `a` is `[0, 1000]`. + fn destroy_approvals(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `414 + a * (86 ±0)` + // Estimated: `3675 + a * (2623 ±0)` + // Minimum execution time: 17_700_000 picoseconds. + Weight::from_parts(17_937_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + // Standard Error: 3_243 + .saturating_add(Weight::from_parts(13_846_653, 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) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + fn finish_destroy() -> Weight { + // Proof Size summary in bytes: + // Measured: `243` + // Estimated: `3675` + // Minimum execution time: 13_768_000 picoseconds. + Weight::from_parts(14_051_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + fn mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `243` + // Estimated: `3675` + // Minimum execution time: 25_151_000 picoseconds. + Weight::from_parts(25_580_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + fn burn() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 30_470_000 picoseconds. + Weight::from_parts(31_052_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets 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: `351` + // Estimated: `6208` + // Minimum execution time: 41_875_000 picoseconds. + Weight::from_parts(42_493_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets 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: `351` + // Estimated: `6208` + // Minimum execution time: 36_879_000 picoseconds. + Weight::from_parts(38_073_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets 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: `351` + // Estimated: `6208` + // Minimum execution time: 41_787_000 picoseconds. + Weight::from_parts(42_372_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + fn freeze() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 16_915_000 picoseconds. + Weight::from_parts(17_359_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + fn thaw() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 16_837_000 picoseconds. + Weight::from_parts(17_598_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn freeze_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `277` + // Estimated: `3675` + // Minimum execution time: 13_493_000 picoseconds. + Weight::from_parts(13_959_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn thaw_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `277` + // Estimated: `3675` + // Minimum execution time: 13_178_000 picoseconds. + Weight::from_parts(13_574_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + fn transfer_ownership() -> Weight { + // Proof Size summary in bytes: + // Measured: `243` + // Estimated: `3675` + // Minimum execution time: 14_461_000 picoseconds. + Weight::from_parts(14_999_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn set_team() -> Weight { + // Proof Size summary in bytes: + // Measured: `243` + // Estimated: `3675` + // Minimum execution time: 13_465_000 picoseconds. + Weight::from_parts(13_898_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 50]`. + /// The range of component `s` is `[0, 50]`. + /// The range of component `n` is `[0, 50]`. + /// The range of component `s` is `[0, 50]`. + fn set_metadata(n: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `243` + // Estimated: `3675` + // Minimum execution time: 28_106_000 picoseconds. + Weight::from_parts(28_109_577, 0) + .saturating_add(Weight::from_parts(0, 3675)) + // Standard Error: 4_194 + .saturating_add(Weight::from_parts(15_049, 0).saturating_mul(n.into())) + // Standard Error: 4_194 + .saturating_add(Weight::from_parts(19_600, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + fn clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `407` + // Estimated: `3675` + // Minimum execution time: 28_488_000 picoseconds. + Weight::from_parts(28_852_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 50]`. + /// The range of component `s` is `[0, 50]`. + /// The range of component `n` is `[0, 50]`. + /// The range of component `s` is `[0, 50]`. + fn force_set_metadata(_n: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `82` + // Estimated: `3675` + // Minimum execution time: 13_076_000 picoseconds. + Weight::from_parts(13_553_158, 0) + .saturating_add(Weight::from_parts(0, 3675)) + // Standard Error: 1_371 + .saturating_add(Weight::from_parts(5_010, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + fn force_clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `407` + // Estimated: `3675` + // Minimum execution time: 27_960_000 picoseconds. + Weight::from_parts(28_488_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn force_asset_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `243` + // Estimated: `3675` + // Minimum execution time: 12_685_000 picoseconds. + Weight::from_parts(12_972_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) + fn approve_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `277` + // Estimated: `3675` + // Minimum execution time: 31_166_000 picoseconds. + Weight::from_parts(31_861_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets 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: `521` + // Estimated: `6208` + // Minimum execution time: 59_372_000 picoseconds. + Weight::from_parts(60_201_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) + fn cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `3675` + // Minimum execution time: 33_161_000 picoseconds. + Weight::from_parts(33_561_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) + fn force_cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `3675` + // Minimum execution time: 33_624_000 picoseconds. + Weight::from_parts(34_111_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn set_min_balance() -> Weight { + // Proof Size summary in bytes: + // Measured: `243` + // Estimated: `3675` + // Minimum execution time: 13_756_000 picoseconds. + Weight::from_parts(14_098_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn touch() -> Weight { + // Proof Size summary in bytes: + // Measured: `346` + // Estimated: `3675` + // Minimum execution time: 32_493_000 picoseconds. + Weight::from_parts(33_272_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn touch_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `243` + // Estimated: `3675` + // Minimum execution time: 30_824_000 picoseconds. + Weight::from_parts(31_497_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn refund() -> Weight { + // Proof Size summary in bytes: + // Measured: `472` + // Estimated: `3675` + // Minimum execution time: 29_576_000 picoseconds. + Weight::from_parts(30_149_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn refund_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `402` + // Estimated: `3675` + // Minimum execution time: 28_092_000 picoseconds. + Weight::from_parts(28_419_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + fn block() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 16_860_000 picoseconds. + Weight::from_parts(17_197_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/runtime/bajun/src/weights/pallet_xcm.rs b/runtime/bajun/src/weights/pallet_xcm.rs new file mode 100644 index 0000000..ea87b4a --- /dev/null +++ b/runtime/bajun/src/weights/pallet_xcm.rs @@ -0,0 +1,418 @@ +// Ajuna Node +// Copyright (C) 2022 BlogaTech AG + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program 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 Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-02-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn send() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 21_630_000 picoseconds. + Weight::from_parts(22_306_000, 0) + .saturating_add(Weight::from_parts(0, 3610)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn teleport_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 91_802_000 picoseconds. + Weight::from_parts(93_672_000, 0) + .saturating_add(Weight::from_parts(0, 3610)) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::RelevantMessagingState` (r:1 w:0) + /// Proof: `ParachainSystem::RelevantMessagingState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1) + /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1) + /// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn reserve_transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `367` + // Estimated: `6196` + // Minimum execution time: 118_930_000 picoseconds. + Weight::from_parts(122_306_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Assets::Asset` (r:1 w:1) + /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `Assets::Account` (r:2 w:2) + /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `496` + // Estimated: `6208` + // Minimum execution time: 140_527_000 picoseconds. + Weight::from_parts(144_501_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(7)) + } + fn execute() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_556_000 picoseconds. + Weight::from_parts(7_798_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + /// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn force_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_373_000 picoseconds. + Weight::from_parts(6_603_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn force_default_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_941_000 picoseconds. + Weight::from_parts(2_088_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + /// Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::Queries` (r:0 w:1) + /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn force_subscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 27_080_000 picoseconds. + Weight::from_parts(27_820_000, 0) + .saturating_add(Weight::from_parts(0, 3610)) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::Queries` (r:0 w:1) + /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn force_unsubscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `363` + // Estimated: `3828` + // Minimum execution time: 28_850_000 picoseconds. + Weight::from_parts(29_506_000, 0) + .saturating_add(Weight::from_parts(0, 3828)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) + /// Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn force_suspension() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_033_000 picoseconds. + Weight::from_parts(2_201_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `PolkadotXcm::SupportedVersion` (r:5 w:2) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn migrate_supported_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `159` + // Estimated: `13524` + // Minimum execution time: 18_844_000 picoseconds. + Weight::from_parts(19_197_000, 0) + .saturating_add(Weight::from_parts(0, 13524)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `PolkadotXcm::VersionNotifiers` (r:5 w:2) + /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn migrate_version_notifiers() -> Weight { + // Proof Size summary in bytes: + // Measured: `163` + // Estimated: `13528` + // Minimum execution time: 18_940_000 picoseconds. + Weight::from_parts(19_450_000, 0) + .saturating_add(Weight::from_parts(0, 13528)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:0) + /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn already_notified_target() -> Weight { + // Proof Size summary in bytes: + // Measured: `173` + // Estimated: `16013` + // Minimum execution time: 20_521_000 picoseconds. + Weight::from_parts(21_076_000, 0) + .saturating_add(Weight::from_parts(0, 16013)) + .saturating_add(T::DbWeight::get().reads(6)) + } + /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) + /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn notify_current_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `6152` + // Minimum execution time: 26_007_000 picoseconds. + Weight::from_parts(26_448_000, 0) + .saturating_add(Weight::from_parts(0, 6152)) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:0) + /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn notify_target_migration_fail() -> Weight { + // Proof Size summary in bytes: + // Measured: `206` + // Estimated: `11096` + // Minimum execution time: 11_584_000 picoseconds. + Weight::from_parts(12_080_000, 0) + .saturating_add(Weight::from_parts(0, 11096)) + .saturating_add(T::DbWeight::get().reads(4)) + } + /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) + /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn migrate_version_notify_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `170` + // Estimated: `13535` + // Minimum execution time: 19_157_000 picoseconds. + Weight::from_parts(19_513_000, 0) + .saturating_add(Weight::from_parts(0, 13535)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) + /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn migrate_and_notify_old_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `13577` + // Minimum execution time: 34_878_000 picoseconds. + Weight::from_parts(35_623_000, 0) + .saturating_add(Weight::from_parts(0, 13577)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + /// Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::Queries` (r:0 w:1) + /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn new_query() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `1588` + // Minimum execution time: 3_900_000 picoseconds. + Weight::from_parts(4_161_000, 0) + .saturating_add(Weight::from_parts(0, 1588)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `PolkadotXcm::Queries` (r:1 w:1) + /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn take_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `7740` + // Estimated: `11205` + // Minimum execution time: 25_731_000 picoseconds. + Weight::from_parts(26_160_000, 0) + .saturating_add(Weight::from_parts(0, 11205)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + /// Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn claim_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 37_251_000 picoseconds. + Weight::from_parts(38_075_000, 0) + .saturating_add(Weight::from_parts(0, 3625)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + + fn execute_blob() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 37_251_000 picoseconds. + Weight::from_parts(38_075_000, 0) + .saturating_add(Weight::from_parts(0, 3625)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + + fn send_blob() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 37_251_000 picoseconds. + Weight::from_parts(38_075_000, 0) + .saturating_add(Weight::from_parts(0, 3625)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/runtime/bajun/src/xcm_config.rs b/runtime/bajun/src/xcm_config.rs index 1db0b4c..6306cd7 100644 --- a/runtime/bajun/src/xcm_config.rs +++ b/runtime/bajun/src/xcm_config.rs @@ -14,39 +14,116 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +//! XCM configuration for Bajun. + use super::{ - AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, - Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, + AccountId, AssetRegistry, Assets, Balance, Balances, MessageQueue, ParachainInfo, + ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, + TreasuryAccount, XcmpQueue, BAJUN, }; +use crate::weights; +use core::marker::PhantomData; +use cumulus_primitives_core::{AggregateMessageOrigin, GlobalConsensus, ParaId}; +use cumulus_primitives_utility::XcmFeesTo32ByteAccount; use frame_support::{ + pallet_prelude::{Get, PalletInfoAccess, Weight}, parameter_types, - traits::{ConstU32, Contains, Everything, Nothing}, - weights::Weight, + traits::{Contains, ContainsPair, Everything, Nothing, TransformOrigin}, }; use frame_system::EnsureRoot; +use orml_traits::{ + location::{RelativeReserveProvider, Reserve}, + parameter_type_with_key, +}; +use orml_xcm_support::IsNativeConcrete; use pallet_xcm::XcmPassthrough; +use parachains_common::{message_queue::ParaIdToSibling, AssetIdForTrustBackedAssets}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use polkadot_parachain_primitives::primitives::Sibling; -use polkadot_runtime_common::impls::ToAuthor; +use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; +use scale_info::TypeInfo; +use sp_core::ConstU32; +use sp_runtime::{traits::Convert, RuntimeDebug}; +use sp_std::{ + convert::{From, Into}, + prelude::*, +}; use staging_xcm::latest::prelude::*; #[allow(deprecated)] use staging_xcm_builder::CurrencyAdapter; use staging_xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, - DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, - FrameTransactionalProcessor, IsConcrete, NativeAsset, ParentIsPreset, RelayChainAsNative, + AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, + AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, DenyReserveTransferToRelayChain, + DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FixedRateOfFungible, + FixedWeightBounds, FrameTransactionalProcessor, FungiblesAdapter, HashedDescription, + NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, - UsingComponents, WithComputedOrigin, WithUniqueTopic, + WithComputedOrigin, }; -use staging_xcm_executor::XcmExecutor; +use staging_xcm_executor::{traits::JustTry, XcmExecutor}; +use xcm_primitives::{AsAssetLocation, ConvertedRegisteredAssetId}; parameter_types! { - pub const RelayLocation: Location = Location::parent(); - pub const RelayNetwork: Option = None; + pub const MaxInstructions: u32 = 100; +} + +/// Supported local Currencies. Keep this to BAJUN, +/// other assets will be handled through AssetRegistry pallet +#[derive( + Encode, + Decode, + Eq, + PartialEq, + Copy, + Clone, + RuntimeDebug, + PartialOrd, + Ord, + TypeInfo, + MaxEncodedLen, +)] +pub enum CurrencyId { + BAJU, +} + +/// Converts a Locaction into a CurrencyId. Used by XCMP LocalAssetTransactor for asset +/// filtering: we only accept Assets that are convertable to a "CurrencyId". +/// other assets will be handled through AssetRegistry pallet +impl Convert> for CurrencyIdConvert { + fn convert(location: Location) -> Option { + let self_para_id: u32 = ParachainInfo::parachain_id().into(); + + match location.unpack() { + // that's how xTokens with Karura, Bifrost, Moonriver refers to BAJUN + (1, [Parachain(id), BAJU_GENERAL_KEY]) if *id == self_para_id => Some(CurrencyId::BAJU), + // that's how the Asset Hub refers to BAJUN + (1, [Parachain(id)]) if *id == self_para_id => Some(CurrencyId::BAJU), + // same for local location spec. we don't care if parents is 0 or 1 + (0, [BAJU_GENERAL_KEY]) => Some(CurrencyId::BAJU), + (0, []) => Some(CurrencyId::BAJU), + _ => None, + } + } +} + +/// Converts a Asset into a CurrencyId, using the defined Location. +impl Convert> for CurrencyIdConvert { + fn convert(asset: Asset) -> Option { + Self::convert(asset.id.0) + } +} + +parameter_types! { + pub const RelayChainLocation: Location = Location::parent(); + pub AssetHubLocation: Location = Location::new(1, [Parachain(1000)]); + pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into(); - // Potential KSM teleporter account, we don't teleport (yet). If we also have a - // convenience DEX for KSM<>BAJUN at some point, we want to teleport. + // The universal location within the global consensus system + pub UniversalLocation: InteriorLocation = + [GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into(); + pub AssetsPalletLocation: Location = + PalletInstance(::index() as u8).into(); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); } @@ -54,21 +131,23 @@ parameter_types! { /// when determining ownership of accounts for asset transacting and when attempting to use XCM /// `Transact` in order to determine the dispatch Origin. pub type LocationToAccountId = ( - // The parent (Relay-chain) origin converts to the parent `AccountId`. + // The parent (Relay-chain) origin converts to the default `AccountId`. ParentIsPreset, - // Sibling parachain origins convert to AccountId via the `ParaId::into`. + // Sibling parachain origins convert to AccountId via the `ParaIdParaId::into`. SiblingParachainConvertsVia, // Straight up local `AccountId32` origins just alias directly to `AccountId`. AccountId32Aliases, + // Foreign locations alias into accounts according to a hash of their standard description. + HashedDescription>, ); -/// Means for transacting assets on this chain. +/// Means for transacting BAJUN only. #[allow(deprecated)] -pub type LocalAssetTransactor = CurrencyAdapter< +pub type LocalNativeTransactor = CurrencyAdapter< // Use this currency: Balances, - // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + // Matcher: matches concrete fungible assets whose `id` could be converted into `CurrencyId`. + IsNativeConcrete, // Do a simple punn to convert an AccountId32 Location into a native chain account ID: LocationToAccountId, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -77,6 +156,54 @@ pub type LocalAssetTransactor = CurrencyAdapter< (), >; +/// `AssetId/Balancer` converter for `TrustBackedAssets` +pub type TrustBackedAssetsConvertedConcreteId = + assets_common::TrustBackedAssetsConvertedConcreteId; + +/// Means for transacting assets besides the native currency on this chain. +/// Even if we currently don't plan to use this for arbitrary assets on our chain, +/// there is no harm in allowing asset transactions via xcm +pub type LocalFungiblesTransactor = FungiblesAdapter< + // Use this fungibles implementation: + Assets, + // Use this currency when it is a fungible asset matching the given location or name: + TrustBackedAssetsConvertedConcreteId, + // Convert an XCM Location into a local account id: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We don't track any teleports of `Assets`. + NoChecking, + // We don't track any teleports of `Assets`, but a placeholder account is provided due to trait + // bounds. + CheckingAccount, +>; + +/// Means for transacting reserved fungible assets. +/// AsAssetLocation uses pallet_asset_registry to convert between AssetId and Location. +/// This will be used for ROC/KSM/DOT derivatives through pallet AssetRegistry +pub type ReservedFungiblesTransactor = FungiblesAdapter< + // Use this fungibles implementation: + Assets, + // Use this currency when it is a registered fungible asset matching the given location or name + // Assets not found in AssetRegistry will not be used + ConvertedRegisteredAssetId< + AssetIdForTrustBackedAssets, + Balance, + AsAssetLocation, + JustTry, + >, + // Convert an XCM Location into a local account id: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We don't track any teleports of `Assets`. + NoChecking, + // We don't track any teleports of `Assets`, but a placeholder account is provided due to trait + // bounds. + CheckingAccount, +>; + /// 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 /// biases the kind of local `Origin` it will become. @@ -85,26 +212,22 @@ pub type XcmOriginToTransactDispatchOrigin = ( // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when - // recognized. + // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // recognised. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognized. + // recognised. SiblingParachainAsNative, + // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a + // transaction from the Root origin. + ParentAsSuperuser, // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `RuntimeOrigin::Signed` origin of the same 32-byte value. + // `Origin::Signed` origin of the same 32-byte value. SignedAccountId32AsNative, // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. XcmPassthrough, ); -parameter_types! { - // One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate. - pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); - pub const MaxInstructions: u32 = 100; - pub const MaxAssetsIntoHolding: u32 = 64; -} - pub struct ParentOrParentsExecutivePlurality; impl Contains for ParentOrParentsExecutivePlurality { fn contains(location: &Location) -> bool { @@ -112,16 +235,32 @@ impl Contains for ParentOrParentsExecutivePlurality { } } +pub struct ParentOrSiblings; +impl Contains for ParentOrSiblings { + fn contains(location: &Location) -> bool { + matches!(location.unpack(), (1, []) | (1, _)) + } +} + +// The barrier decides if we spend time executing an incoming XCM message pub type Barrier = TrailingSetTopicAsId< DenyThenTry< DenyReserveTransferToRelayChain, ( TakeWeightCredit, + // Expected responses are OK. + AllowKnownQueryResponses, + // Allow XCMs with some computed origins to pass through. WithComputedOrigin< ( + // If the message is one that immediately attempts to pay for execution, then + // allow it. AllowTopLevelPaidExecutionFrom, - AllowExplicitUnpaidExecutionFrom, - // ^^^ Parent and its exec plurality get free execution + // Parent, its pluralities (i.e. governance bodies), and the Fellows plurality + // get free execution. + AllowUnpaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, ), UniversalLocation, ConstU32<8>, @@ -130,77 +269,145 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +pub struct ReserveAssetsFrom(PhantomData); +impl> ContainsPair for ReserveAssetsFrom { + fn contains(asset: &Asset, origin: &Location) -> bool { + let prefix = T::get(); + log::trace!(target: "xcm::AssetsFrom", "prefix: {:?}, origin: {:?}, asset: {:?}", prefix, origin, asset); + &prefix == origin + } +} +pub struct OnlyTeleportNative; +impl Contains<(Location, Vec)> for OnlyTeleportNative { + fn contains(t: &(Location, Vec)) -> bool { + let self_para_id: u32 = ParachainInfo::parachain_id().into(); + t.1.iter().any(|asset| { + log::trace!(target: "xcm::OnlyTeleportNative", "Asset requested to be teleported: {:?}", asset); + + if let Asset { id: AssetId(asset_loc), fun: Fungible(_a) } = asset { + match asset_loc.unpack() { + (0, []) => true, + (1, [Parachain(id)]) if *id == self_para_id => true, + _ => false, + } + } else { + false + } + }) + } +} + +pub type Traders = ( + // for BAJUN + FixedRateOfFungible< + NativePerSecond, + XcmFeesTo32ByteAccount, + >, + // for BAJUN for XCM from Karura, Bifrost, Moonriver + FixedRateOfFungible< + NativeAliasPerSecond, + XcmFeesTo32ByteAccount, + >, + // for KSM aka RelayNative + FixedRateOfFungible< + RelayNativePerSecond, + XcmFeesTo32ByteAccount, + >, +); + +parameter_types! { + pub const MaxAssetsIntoHolding: u32 = 64; + pub NativePerSecond: (AssetId, u128,u128) = (Location::new(0,Here).into(), BAJUN * 70, 0u128); + pub NativeAliasPerSecond: (AssetId, u128,u128) = (Location::new(0,[BAJU_GENERAL_KEY]).into(), BAJUN * 70, 0u128); + pub RelayNativePerSecond: (AssetId, u128,u128) = (Location::new(1,Here).into(), BAJUN * 70, 0u128); + // Weight for one XCM operation. + pub UnitWeightCost: Weight = Weight::from_parts(1_000_000u64, DEFAULT_PROOF_SIZE); + pub const BajunNative: AssetFilter = Wild(AllOf { fun: WildFungible, id: AssetId(Location::here()) }); + pub AssetHubTrustedTeleporter: (AssetFilter, Location) = (BajunNative::get(), AssetHubLocation::get()); +} + +pub type TrustedTeleporters = (staging_xcm_builder::Case,); + +pub type Reserves = (NativeAsset, ReserveAssetsFrom); + +/// The means for routing XCM messages which are not for local execution into the right message +/// queues. +pub type XcmRouter = ( + // Two routers - use UMP to communicate with the relay chain: + cumulus_primitives_utility::ParentAsUmp, + // ..and XCMP to communicate with the sibling chains. + XcmpQueue, +); + +/// Means for transacting assets on this chain. +pub type AssetTransactors = + (LocalNativeTransactor, ReservedFungiblesTransactor, LocalFungiblesTransactor); + +pub struct SafeCallFilter; +impl frame_support::traits::Contains for SafeCallFilter { + fn contains(_call: &RuntimeCall) -> bool { + // This is safe, as we prevent arbitrary xcm-transact executions. + // For rationale, see:https://github.com/paritytech/polkadot/blob/19fdd197aff085f7f66e54942999fd536e7df475/runtime/kusama/src/xcm_config.rs#L171 + true + } +} pub struct XcmConfig; impl staging_xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; // How to withdraw and deposit an asset. - type AssetTransactor = LocalAssetTransactor; + type AssetTransactor = AssetTransactors; type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = NativeAsset; - type IsTeleporter = (); // Teleporting is disabled. + type IsReserve = Reserves; + type IsTeleporter = TrustedTeleporters; + type Aliasers = Nothing; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = - UsingComponents>; + type Trader = Traders; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; - type PalletInstancesInfo = AllPalletsWithSystem; + type PalletInstancesInfo = crate::AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; - type SafeCallFilter = Everything; - type Aliasers = Nothing; + type SafeCallFilter = SafeCallFilter; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); type HrmpChannelClosingHandler = (); } -/// No local origins on this chain are allowed to dispatch XCM sends/executions. +// Converts a Signed Local Origin into a Location pub type LocalOriginToLocation = SignedToAccountId32; -/// The means for routing XCM messages which are not for local execution into the right message -/// queues. -pub type XcmRouter = WithUniqueTopic<( - // Two routers - use UMP to communicate with the relay chain: - cumulus_primitives_utility::ParentAsUmp, - // ..and XCMP to communicate with the sibling chains. - XcmpQueue, -)>; - impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type SendXcmOrigin = EnsureXcmOrigin; + type SendXcmOrigin = EnsureXcmOrigin; // Prohibit sending arbitrary XCMs from users of this chain type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; - type XcmExecuteFilter = Nothing; - // ^ Disable dispatchable execute on the XCM pallet. - // Needs to be `Everything` for local testing. + type ExecuteXcmOrigin = EnsureXcmOrigin; // Allow any local origin in XCM execution. + type XcmExecuteFilter = Nothing; // Disable generic XCM execution. This does not affect Teleport or Reserve Transfer. type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Nothing; + type XcmTeleportFilter = OnlyTeleportNative; + type XcmReserveTransferFilter = Everything; // Transfer are allowed type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - // ^ Override for AdvertisedXcmVersion default type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; type CurrencyMatcher = (); type TrustedLockers = (); type SovereignAccountOf = LocationToAccountId; type MaxLockers = ConstU32<8>; - type WeightInfo = pallet_xcm::TestWeightInfo; + type WeightInfo = weights::pallet_xcm::WeightInfo; type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); @@ -210,3 +417,128 @@ impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; } + +impl cumulus_pallet_xcmp_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type ChannelInfo = ParachainSystem; + type VersionWrapper = PolkadotXcm; + // Enqueue XCMP messages from siblings for later processing. + type XcmpQueue = TransformOrigin; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; + type ControllerOrigin = EnsureRoot; + type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; + type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; + type PriceForSiblingDelivery = NoPriceForMessageDelivery; +} + +/// Copied from moonbeam: https://github.com/PureStake/moonbeam/blob/095031d171b0c163e5649ee35acbc36eef681a82/primitives/xcm/src/ethereum_xcm.rs#L34 +pub const DEFAULT_PROOF_SIZE: u64 = 1024; + +parameter_types! { + pub const BaseXcmWeight: Weight= Weight::from_parts(1_000_000u64, DEFAULT_PROOF_SIZE); + pub const MaxAssetsForTransfer: usize = 2; +} + +// What follows here are specialties only used for xToken reserve-transferring BAJUN to Karura, +// Bifrost and Moonriver + +// The min fee amount in fee asset is split into two parts: +// +// - fee asset sent to fee reserve chain = fee_amount - min_xcm_fee +// - fee asset sent to dest reserve chain = min_xcm_fee +// Check out for more information: +// https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xtokens#transfer-multiple-currencies + +parameter_type_with_key! { + pub ParachainMinFee: |_location: Location| -> Option { + None + }; +} + +const fn baju_general_key() -> Junction { + const BAJU_KEY: [u8; 32] = *b"BAJU\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + GeneralKey { length: 4, data: BAJU_KEY } +} +const BAJU_GENERAL_KEY: Junction = baju_general_key(); + +/// Converts a CurrencyId into a Location, used by xtoken for XCMP. +pub struct CurrencyIdConvert; +impl Convert> for CurrencyIdConvert { + fn convert(id: CurrencyId) -> Option { + match id { + CurrencyId::BAJU => Some(Location::new( + 1, + [Parachain(ParachainInfo::parachain_id().into()), BAJU_GENERAL_KEY], + )), + } + } +} + +parameter_types! { + pub SelfReserveAlias: Location = Location::new( + 0, + [BAJU_GENERAL_KEY] + ); + // This is how we are going to detect whether the asset is a Reserve asset + pub SelfLocation: Location = Location::here(); + // We need this to be able to catch when someone is trying to execute a non- + // cross-chain transfer in xtokens through the absolute path way + pub SelfLocationAbsolute: Location = Location::new( + 1, + Parachain(ParachainInfo::parachain_id().into()) + ); + +} + +/// This struct offers uses RelativeReserveProvider to output relative views of Locations +/// However, additionally accepts a Location that aims at representing the chain part +/// (parent: 1, Parachain(paraId)) of the absolute representation of our chain. +/// If a token reserve matches against this absolute view, we return Some(Location::here()) +/// This helps users by preventing errors when they try to transfer a token through xtokens +/// to our chain (either inserting the relative or the absolute value). +pub struct AbsoluteAndRelativeReserve(PhantomData); +impl Reserve for AbsoluteAndRelativeReserve +where + AbsoluteLocation: Get, +{ + fn reserve(asset: &Asset) -> Option { + RelativeReserveProvider::reserve(asset).map(|relative_reserve| { + if relative_reserve == AbsoluteLocation::get() { + Location::here() + } else { + relative_reserve + } + }) + } +} + +pub struct AccountIdToLocation; +impl Convert for AccountIdToLocation { + fn convert(account: AccountId) -> Location { + [AccountId32 { network: None, id: account.into() }].into() + } +} + +impl orml_xcm::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type SovereignOrigin = EnsureRoot; +} + +impl orml_xtokens::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type CurrencyId = CurrencyId; + type CurrencyIdConvert = CurrencyIdConvert; + type AccountIdToLocation = AccountIdToLocation; + type SelfLocation = SelfLocation; + type MinXcmFee = ParachainMinFee; + type XcmExecutor = XcmExecutor; + type LocationsFilter = Everything; + type Weigher = FixedWeightBounds; + type BaseXcmWeight = BaseXcmWeight; + type UniversalLocation = UniversalLocation; + type MaxAssetsForTransfer = MaxAssetsForTransfer; + type ReserveProvider = AbsoluteAndRelativeReserve; + type RateLimiter = (); + type RateLimiterId = (); +}