diff --git a/Cargo.lock b/Cargo.lock index 2b938bec..2798a998 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -444,6 +444,31 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "assets-common" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d2d5b75d36daec8ffad11f121f581cc3aec2b7b117d8ab68f6e3ac914a5569" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "impl-trait-for-tuples", + "log", + "pallet-asset-conversion", + "pallet-asset-tx-payment", + "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" @@ -1196,7 +1221,7 @@ dependencies = [ [[package]] name = "claims-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "parity-scale-codec", "rustc-hex", @@ -1328,7 +1353,7 @@ checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" [[package]] name = "common-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "derive_more", "parity-scale-codec", @@ -2785,7 +2810,7 @@ dependencies = [ [[package]] name = "enclave-bridge-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "common-primitives", "log", @@ -4198,7 +4223,7 @@ dependencies = [ [[package]] name = "integritee-collator" -version = "1.9.0" +version = "1.9.1" dependencies = [ "assert_cmd", "async-trait", @@ -4305,8 +4330,9 @@ dependencies = [ [[package]] name = "integritee-runtime" -version = "1.9.47" +version = "1.9.48" dependencies = [ + "assets-common", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -4331,6 +4357,8 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-asset-registry", + "pallet-assets", "pallet-aura", "pallet-balances", "pallet-bounties", @@ -4381,6 +4409,7 @@ dependencies = [ "staging-xcm-builder", "staging-xcm-executor", "substrate-wasm-builder", + "xcm-primitives", "xcm-transactor-primitives", ] @@ -6221,6 +6250,25 @@ dependencies = [ "staging-xcm-executor", ] +[[package]] +name = "pallet-asset-conversion" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2139677a59351fbd8513ddd92be4a7443d7d92f8f6897b2bbc78f55d1c6b8a" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-asset-rate" version = "7.0.0" @@ -6237,6 +6285,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-asset-registry" +version = "0.0.1" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" +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 = "28.0.0" @@ -6494,7 +6560,7 @@ dependencies = [ [[package]] name = "pallet-claims" version = "0.9.12" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "claims-primitives", "frame-benchmarking", @@ -6648,7 +6714,7 @@ dependencies = [ [[package]] name = "pallet-enclave-bridge" version = "0.12.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "enclave-bridge-primitives", "frame-benchmarking", @@ -7127,7 +7193,7 @@ dependencies = [ [[package]] name = "pallet-sidechain" version = "0.11.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "enclave-bridge-primitives", "frame-benchmarking", @@ -7265,7 +7331,7 @@ dependencies = [ [[package]] name = "pallet-teeracle" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "frame-benchmarking", "frame-support", @@ -7289,7 +7355,7 @@ dependencies = [ [[package]] name = "pallet-teerex" version = "0.10.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "frame-benchmarking", "frame-support", @@ -7516,7 +7582,7 @@ dependencies = [ [[package]] name = "pallet-xcm-transactor" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "cumulus-primitives-core", "frame-benchmarking", @@ -11555,7 +11621,7 @@ dependencies = [ [[package]] name = "sgx-verify" version = "0.1.4" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "base64 0.13.1", "chrono", @@ -11726,7 +11792,7 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "sidechain-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "parity-scale-codec", "scale-info", @@ -13234,7 +13300,7 @@ checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" [[package]] name = "teeracle-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "common-primitives", "sp-std", @@ -13244,7 +13310,7 @@ dependencies = [ [[package]] name = "teerex-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "common-primitives", "derive_more", @@ -13298,7 +13364,7 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test-utils" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "log", "sgx-verify", @@ -15006,6 +15072,18 @@ dependencies = [ "time", ] +[[package]] +name = "xcm-primitives" +version = "0.0.1" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" +dependencies = [ + "frame-support", + "sp-runtime", + "sp-std", + "staging-xcm", + "staging-xcm-executor", +] + [[package]] name = "xcm-procedural" version = "7.0.0" @@ -15021,7 +15099,7 @@ dependencies = [ [[package]] name = "xcm-transactor-primitives" version = "0.1.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#45d88ce8d3f3c080af723babed9c45c070763eef" +source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v1.6.0#2c5e3bcfe334fdc0114dadf7cdad966059824119" dependencies = [ "common-primitives", "cumulus-primitives-core", diff --git a/Cargo.toml b/Cargo.toml index d47bc4e3..16f7f5eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,15 +24,18 @@ serde_json = "1.0" smallvec = "1.11.0" # integritee pallets +pallet-asset-registry = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } pallet-claims = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } pallet-enclave-bridge = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } pallet-sidechain = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } pallet-teeracle = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } pallet-teerex = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } pallet-xcm-transactor = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } +xcm-primitives = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } xcm-transactor-primitives = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } # Polkadot-sdk and ecosystem crates [no_std] +assets-common = { version = "0.7.0", default-features = false } cumulus-pallet-aura-ext = { version = "0.7.0", default-features = false } cumulus-pallet-dmp-queue = { version = "0.7.0", default-features = false } cumulus-pallet-parachain-system = { version = "0.7.0", default-features = false } @@ -52,6 +55,7 @@ orml-traits = { version = "0.7", default-features = false } orml-xcm = { version = "0.7", default-features = false } orml-xcm-support = { version = "0.7", default-features = false } orml-xtokens = { version = "0.7", default-features = false } +pallet-assets = { version = "29.0.0", default-features = false } pallet-aura = { version = "27.0.0", default-features = false } pallet-authorship = { version = "28.0.0", default-features = false } pallet-balances = { version = "28.0.0", default-features = false } @@ -161,6 +165,7 @@ substrate-wasm-builder = "17.0.0" #claims-primitives = { path = '../pallets/primitives/claims' } #common-primitives = { path = '../pallets/primitives/common' } #enclave-bridge-primitives = { path = '../pallets/primitives/enclave-bridge' } +#pallet-asset-registry = { path = '../pallets/asset-registry' } #pallet-claims = { path = '../pallets/claims' } #pallet-enclave-bridge = { path = '../pallets/enclave-bridge' } #pallet-sidechain = { path = '../pallets/sidechain' } @@ -170,8 +175,9 @@ substrate-wasm-builder = "17.0.0" #sgx-verify = { path = '../pallets/teerex/sgx-verify' } #teeracle-primitives = { path = '../pallets/primitives/teeracle' } #teerex-primitives = { path = '../pallets/primitives/teerex' } -#xcm-transactor-primitives = { path = '../pallets/primitives/xcm-transactor' } #test-utils = { path = '../pallets/test-utils' } +#xcm-primitives = { path = '../pallets/primitives/xcm' } +#xcm-transactor-primitives = { path = '../pallets/primitives/xcm-transactor' } [patch.crates-io] ring = { git = "https://github.com/betrusted-io/ring-xous", branch = "0.16.20-cleanup" } diff --git a/polkadot-parachains/Cargo.toml b/polkadot-parachains/Cargo.toml index 0d42aabf..ce8142a8 100644 --- a/polkadot-parachains/Cargo.toml +++ b/polkadot-parachains/Cargo.toml @@ -2,7 +2,7 @@ name = "integritee-collator" description = "The Integritee parachain collator binary" # align major.minor revision with the runtimes. bump patch revision ad lib. make this the github release tag -version = "1.9.0" +version = "1.9.1" authors = ["Integritee AG "] homepage = "https://integritee.network/" repository = "https://github.com/integritee-network/parachain" diff --git a/polkadot-parachains/integritee-runtime/Cargo.toml b/polkadot-parachains/integritee-runtime/Cargo.toml index 95d80111..4791bf1b 100644 --- a/polkadot-parachains/integritee-runtime/Cargo.toml +++ b/polkadot-parachains/integritee-runtime/Cargo.toml @@ -2,7 +2,7 @@ name = "integritee-runtime" description = "The Integritee parachain runtime" # patch revision must match runtime spec_version -version = "1.9.47" +version = "1.9.48" authors = ["Integritee AG "] homepage = "https://integritee.network/" repository = "https://github.com/integritee-network/parachain" @@ -18,6 +18,7 @@ integritee-parachains-common = { path = "../common", default-features = false } # Substrate dependencies # pallets +assets-common = { workspace = true } cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-dmp-queue = { workspace = true } cumulus-pallet-parachain-system = { workspace = true, features = ["parameterized-consensus-hook"] } @@ -35,6 +36,8 @@ orml-traits = { workspace = true } orml-xcm = { workspace = true } orml-xcm-support = { workspace = true } orml-xtokens = { workspace = true } +pallet-asset-registry = { workspace = true } +pallet-assets = { workspace = true } pallet-aura = { workspace = true } pallet-balances = { workspace = true } pallet-bounties = { workspace = true } @@ -80,6 +83,7 @@ staging-parachain-info = { workspace = true } staging-xcm = { workspace = true } staging-xcm-builder = { workspace = true } staging-xcm-executor = { workspace = true } +xcm-primitives = { workspace = true } xcm-transactor-primitives = { workspace = true } # Benchmarking @@ -100,6 +104,7 @@ substrate-wasm-builder = { workspace = true, optional = true } [features] default = ["std"] std = [ + "assets-common/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", @@ -121,6 +126,8 @@ std = [ "orml-xcm-support/std", "orml-xcm/std", "orml-xtokens/std", + "pallet-assets/std", + "pallet-asset-registry/std", "pallet-aura/std", "pallet-balances/std", "pallet-bounties/std", @@ -172,6 +179,7 @@ std = [ "xcm-transactor-primitives/std", ] runtime-benchmarks = [ + "assets-common/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", "cumulus-primitives-utility/runtime-benchmarks", @@ -181,6 +189,8 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "hex-literal", "orml-xtokens/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-asset-registry/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-bounties/runtime-benchmarks", "pallet-child-bounties/runtime-benchmarks", @@ -221,6 +231,8 @@ try-runtime = [ "frame-try-runtime/try-runtime", "orml-xcm/try-runtime", "orml-xtokens/try-runtime", + "pallet-assets/try-runtime", + "pallet-asset-registry/try-runtime", "pallet-aura/try-runtime", "pallet-balances/try-runtime", "pallet-bounties/try-runtime", diff --git a/polkadot-parachains/integritee-runtime/src/lib.rs b/polkadot-parachains/integritee-runtime/src/lib.rs index 464defa7..f228fa43 100644 --- a/polkadot-parachains/integritee-runtime/src/lib.rs +++ b/polkadot-parachains/integritee-runtime/src/lib.rs @@ -25,10 +25,11 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use frame_support::traits::{ - fungible::HoldConsideration, tokens::PayFromAccount, ConstBool, EqualPrivilegeOnly, Imbalance, - InstanceFilter, LinearStoragePrice, OnUnbalanced, + fungible::HoldConsideration, tokens::PayFromAccount, ConstBool, EnsureOriginWithArg, + EqualPrivilegeOnly, Imbalance, InstanceFilter, LinearStoragePrice, OnUnbalanced, }; use pallet_collective; +use parachains_common::AssetIdForTrustBackedAssets; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, ConstU32, OpaqueMetadata}; @@ -82,6 +83,7 @@ pub use pallet_balances::Call as BalancesCall; pub use pallet_timestamp::Call as TimestampCall; use parachains_common::message_queue::NarrowOriginToSibling; use scale_info::TypeInfo; +use sp_core::ConstU128; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; use sp_runtime::RuntimeDebug; @@ -120,7 +122,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("integritee-parachain"), impl_name: create_runtime_str!("integritee-full"), authoring_version: 2, - spec_version: 47, + spec_version: 48, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 6, @@ -793,6 +795,76 @@ impl orml_xcm::Config for Runtime { type SovereignOrigin = EnsureRoot; } +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, + ) -> sp_std::result::Result { + return Err(o) + } + + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin(_a: &AssetIdForTrustBackedAssets) -> Result { + Err(()) + } +} + +impl pallet_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = AssetBalance; + type RemoveItemsLimit = frame_support::traits::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<{ TEER }>; + type AssetAccountDeposit = ConstU128<{ TEER }>; + type MetadataDepositBase = ConstU128<{ TEER }>; + type MetadataDepositPerByte = ConstU128<{ 10 * MILLITEER }>; + type ApprovalDeposit = ConstU128<{ 10 * MILLITEER }>; + 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; +} + construct_runtime!( pub enum Runtime { @@ -834,6 +906,8 @@ construct_runtime!( XTokens: orml_xtokens = 34, OrmlXcm: orml_xcm = 35, XcmTransactor: pallet_xcm_transactor = 36, + Assets: pallet_assets = 41, + AssetRegistry: pallet_asset_registry = 42, // Integritee pallets. Teerex: pallet_teerex = 50, @@ -888,6 +962,8 @@ extern crate frame_benchmarking; mod benches { define_benchmarks!( [frame_system, SystemBench::] + [pallet_asset_registry, AssetRegistry] + [pallet_assets, Assets] [pallet_balances, Balances] [pallet_bounties, Bounties] [pallet_child_bounties, ChildBounties] diff --git a/polkadot-parachains/integritee-runtime/src/weights/mod.rs b/polkadot-parachains/integritee-runtime/src/weights/mod.rs index e43af35f..0b76d9a4 100644 --- a/polkadot-parachains/integritee-runtime/src/weights/mod.rs +++ b/polkadot-parachains/integritee-runtime/src/weights/mod.rs @@ -3,7 +3,10 @@ // the generated files do not pass clippy #![allow(clippy::all)] +pub mod cumulus_pallet_parachain_system; pub mod frame_system; +pub mod pallet_asset_registry; +pub mod pallet_assets; pub mod pallet_balances; pub mod pallet_bounties; pub mod pallet_child_bounties; @@ -24,5 +27,3 @@ pub mod pallet_treasury; pub mod pallet_utility; pub mod pallet_vesting; pub mod pallet_xcm; - -pub mod cumulus_pallet_parachain_system; diff --git a/polkadot-parachains/integritee-runtime/src/weights/pallet_asset_registry.rs b/polkadot-parachains/integritee-runtime/src/weights/pallet_asset_registry.rs new file mode 100644 index 00000000..34345af2 --- /dev/null +++ b/polkadot-parachains/integritee-runtime/src/weights/pallet_asset_registry.rs @@ -0,0 +1,83 @@ +// This file is part of Trappist. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! 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::AssetIdMultiLocation` (r:1 w:1) + /// Proof: `AssetRegistry::AssetIdMultiLocation` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::AssetMultiLocationId` (r:0 w:1) + /// Proof: `AssetRegistry::AssetMultiLocationId` (`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::AssetIdMultiLocation` (r:1 w:1) + /// Proof: `AssetRegistry::AssetIdMultiLocation` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::AssetMultiLocationId` (r:0 w:1) + /// Proof: `AssetRegistry::AssetMultiLocationId` (`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/polkadot-parachains/integritee-runtime/src/weights/pallet_assets.rs b/polkadot-parachains/integritee-runtime/src/weights/pallet_assets.rs new file mode 100644 index 00000000..c16559d0 --- /dev/null +++ b/polkadot-parachains/integritee-runtime/src/weights/pallet_assets.rs @@ -0,0 +1,530 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! 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/polkadot-parachains/integritee-runtime/src/xcm_config.rs b/polkadot-parachains/integritee-runtime/src/xcm_config.rs index 875b24d0..8b348dc5 100644 --- a/polkadot-parachains/integritee-runtime/src/xcm_config.rs +++ b/polkadot-parachains/integritee-runtime/src/xcm_config.rs @@ -19,27 +19,28 @@ //! use super::{ - AccountId, Balance, Balances, EnsureRootOrMoreThanHalfCouncil, MaxInstructions, MessageQueue, - ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - XcmpQueue, TEER, + AccountId, AssetRegistry, Assets, Balance, Balances, EnsureRootOrMoreThanHalfCouncil, + MaxInstructions, MessageQueue, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, + RuntimeCall, RuntimeEvent, RuntimeOrigin, TreasuryAccount, XcmpQueue, TEER, }; use crate::weights; use core::marker::PhantomData; use cumulus_primitives_core::{AggregateMessageOrigin, GlobalConsensus}; +use cumulus_primitives_utility::XcmFeesTo32ByteAccount; use frame_support::{ - pallet_prelude::{Get, Weight}, + match_types, + pallet_prelude::{Get, PalletInfoAccess, Weight}, parameter_types, - traits::{Everything, Nothing, TransformOrigin}, - weights::IdentityFee, + 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, MultiNativeAsset}; +use orml_xcm_support::IsNativeConcrete; use pallet_xcm::XcmPassthrough; -use parachains_common::message_queue::ParaIdToSibling; +use parachains_common::{message_queue::ParaIdToSibling, AssetIdForTrustBackedAssets}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; @@ -55,38 +56,19 @@ use staging_xcm::latest::prelude::*; use staging_xcm_builder::CurrencyAdapter; use staging_xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, - FixedWeightBounds, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, DenyReserveTransferToRelayChain, + DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FixedRateOfFungible, + FixedWeightBounds, FungiblesAdapter, HashedDescription, NativeAsset, NoChecking, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, WithComputedOrigin, }; -use staging_xcm_executor::XcmExecutor; +use staging_xcm_executor::{traits::JustTry, XcmExecutor}; +use xcm_primitives::{AsAssetMultiLocation, ConvertedRegisteredAssetId}; use xcm_transactor_primitives::*; -const fn teer_general_key() -> Junction { - const TEER_KEY: [u8; 32] = *b"TEER\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: TEER_KEY } -} - -const TEER_GENERAL_KEY: Junction = teer_general_key(); - -parameter_types! { - pub const RelayChainLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - // The universal location within the global consensus system - pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())); - - pub SelfReserve: MultiLocation = MultiLocation { - parents:0, - //todo: why not `interior: Here` ? - interior: Junctions::X1(TEER_GENERAL_KEY) - }; - pub CheckingAccount: AccountId = PolkadotXcm::check_account(); -} - -// Supported Currencies. +/// Supported local Currencies. Keep this to TEER, +/// other assets will be handled through AssetRegistry pallet #[derive( Encode, Decode, @@ -104,34 +86,28 @@ pub enum CurrencyId { TEER, } -/// Converts a CurrencyId into a Multilocation, used by xtoken for XCMP. -pub struct CurrencyIdConvert; -impl Convert> for CurrencyIdConvert { - fn convert(id: CurrencyId) -> Option { - match id { - CurrencyId::TEER => Some(MultiLocation::new( - 1, - X2(Parachain(ParachainInfo::parachain_id().into()), TEER_GENERAL_KEY), - )), - } - } -} - /// Converts a Mulitloaction 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: MultiLocation) -> Option { let self_para_id: u32 = ParachainInfo::parachain_id().into(); match location { + // semi-absolute location spec MultiLocation { parents, interior } if parents == 1 => match interior { + // that's how xTokens with Karura, Bifrost, Moonriver refers to TEER X2(Parachain(para_id), junction) if junction == TEER_GENERAL_KEY && para_id == self_para_id => Some(CurrencyId::TEER), + // that's how the Asset Hub refers to TEER + X1(Parachain(para_id)) if para_id == self_para_id => Some(CurrencyId::TEER), _ => None, }, + // same for local location spec. we don't care if parents is 0 or 1 MultiLocation { parents, interior } if parents == 0 => match interior { X1(junction) if junction == TEER_GENERAL_KEY => Some(CurrencyId::TEER), + Here => Some(CurrencyId::TEER), _ => None, }, _ => None, @@ -150,14 +126,18 @@ impl Convert> for CurrencyIdConvert { } } -/// 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, -); +parameter_types! { + pub const RelayChainLocation: MultiLocation = MultiLocation::parent(); + pub AssetHubLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(1000))); + pub const RelayNetwork: NetworkId = NetworkId::Kusama; + pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); + // The universal location within the global consensus system + pub UniversalLocation: InteriorMultiLocation = + X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())); + pub AssetsPalletLocation: MultiLocation = + PalletInstance(::index() as u8).into(); + pub CheckingAccount: AccountId = PolkadotXcm::check_account(); +} /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// when determining ownership of accounts for asset transacting and when attempting to use XCM @@ -169,11 +149,13 @@ pub type LocationToAccountId = ( 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 TEER only. #[allow(deprecated)] -pub type LocalAssetTransactor = CurrencyAdapter< +pub type LocalNativeTransactor = CurrencyAdapter< // Use this currency: Balances, // Matcher: matches concrete fungible assets whose `id` could be converted into `CurrencyId`. @@ -186,6 +168,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 MultiLocation 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. +/// AsAssetMultiLocation uses pallet_asset_registry to convert between AssetId and MultiLocation. +/// 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, + AsAssetMultiLocation, + JustTry, + >, + // Convert an XCM MultiLocation into a local account id: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We 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. @@ -210,47 +240,125 @@ pub type XcmOriginToTransactDispatchOrigin = ( XcmPassthrough, ); -/// This struct offers uses RelativeReserveProvider to output relative views of multilocations -/// However, additionally accepts a MultiLocation 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(MultiLocation::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 - AbsoluteMultiLocation: Get, -{ - fn reserve(asset: &MultiAsset) -> Option { - RelativeReserveProvider::reserve(asset).map(|relative_reserve| { - if relative_reserve == AbsoluteMultiLocation::get() { - MultiLocation::here() +match_types! { + pub type ParentOrParentsExecutivePlurality: impl Contains = { + MultiLocation { parents: 1, interior: Here } | + MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) } + }; +} +match_types! { + pub type ParentOrSiblings: impl Contains = { + MultiLocation { parents: 1, interior: Here } | + MultiLocation { parents: 1, interior: X1(_) } + }; +} + +// 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, + // 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>, + >, + ), + >, +>; + +pub struct ReserveAssetsFrom(PhantomData); +impl> ContainsPair for ReserveAssetsFrom { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { + let prefix = T::get(); + log::trace!(target: "xcm::AssetsFrom", "prefix: {:?}, origin: {:?}, asset: {:?}", prefix, origin, asset); + &prefix == origin + } +} +pub struct OnlyTeleportNative; +impl Contains<(MultiLocation, Vec)> for OnlyTeleportNative { + fn contains(t: &(MultiLocation, 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 MultiAsset { + id: staging_xcm::latest::AssetId::Concrete(asset_loc), + fun: Fungible(_a), + } = asset + { + match asset_loc { + MultiLocation { parents: 0, interior: Here } => true, + MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } + if *para_id == self_para_id => + true, + _ => false, + } } else { - relative_reserve + false } }) } } +pub type Traders = ( + // for TEER + FixedRateOfFungible< + NativePerSecond, + XcmFeesTo32ByteAccount, + >, + // for TEER for XCM from Karura, Bifrost, Moonriver + FixedRateOfFungible< + NativeAliasPerSecond, + XcmFeesTo32ByteAccount, + >, + // for KSM aka RelayNative + FixedRateOfFungible< + RelayNativePerSecond, + XcmFeesTo32ByteAccount, + >, +); + parameter_types! { - // Weight for one XCM operation. Copied from moonbeam. + pub const MaxAssetsIntoHolding: u32 = 64; + pub NativePerSecond: (staging_xcm::v3::AssetId, u128,u128) = (MultiLocation::new(0,Here).into(), TEER * 70, 0u128); + pub NativeAliasPerSecond: (staging_xcm::v3::AssetId, u128,u128) = (MultiLocation::new(0,X1(TEER_GENERAL_KEY)).into(), TEER * 70, 0u128); + pub RelayNativePerSecond: (staging_xcm::v3::AssetId, u128,u128) = (MultiLocation::new(1,Here).into(), TEER * 70, 0u128); + // Weight for one XCM operation. pub UnitWeightCost: Weight = Weight::from_parts(1_000_000u64, DEFAULT_PROOF_SIZE); - - // One TEER buys 1 second of weight. - pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), TEER); + pub const IntegriteeNative: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(MultiLocation::here()) }); + pub AssetHubTrustedTeleporter: (MultiAssetFilter, MultiLocation) = (IntegriteeNative::get(), AssetHubLocation::get()); } -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - TakeWeightCredit, - AllowTopLevelPaidExecutionFrom, - // Expected responses are OK. - AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), ->; +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 { @@ -260,24 +368,19 @@ impl frame_support::traits::Contains for SafeCallFilter { true } } - -parameter_types! { - pub const MaxAssetsIntoHolding: u32 = 64; -} - 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 = MultiNativeAsset>; - type IsTeleporter = (); // No teleport for now. Better be safe than sorry. + type IsReserve = Reserves; + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = UsingComponents, SelfReserve, AccountId, Balances, ()>; + type Trader = Traders; type ResponseHandler = PolkadotXcm; type SubscriptionService = PolkadotXcm; type AssetTrap = PolkadotXcm; @@ -297,8 +400,6 @@ impl staging_xcm_executor::Config for XcmConfig { // Converts a Signed Local Origin into a MultiLocation pub type LocalOriginToLocation = SignedToAccountId32; -// FIXME: We should probably update the configuration here. -// See acala and moonbeam example : https://github.com/integritee-network/parachain/issues/103 impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; // Prohibit sending arbitrary XCMs from users of this chain @@ -306,7 +407,7 @@ impl pallet_xcm::Config for Runtime { 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 = Nothing; // Do not allow teleports + type XcmTeleportFilter = OnlyTeleportNative; type XcmReserveTransferFilter = Everything; // Transfer are allowed type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; @@ -345,11 +446,10 @@ impl cumulus_pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; } -// FIXME: Update to PolkadotXcm. impl cumulus_pallet_xcmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ChannelInfo = ParachainSystem; - type VersionWrapper = (); + type VersionWrapper = PolkadotXcm; // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; type MaxInboundSuspended = sp_core::ConstU32<1_000>; @@ -359,19 +459,6 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type PriceForSiblingDelivery = NoPriceForMessageDelivery; } -parameter_types! { - // This is how we are going to detect whether the asset is a Reserve asset - pub SelfLocation: MultiLocation = MultiLocation::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: MultiLocation = MultiLocation { - parents:1, - interior: Junctions::X1( - Parachain(ParachainInfo::parachain_id().into()) - ) - }; -} - /// Copied from moonbeam: https://github.com/PureStake/moonbeam/blob/095031d171b0c163e5649ee35acbc36eef681a82/primitives/xcm/src/ethereum_xcm.rs#L34 pub const DEFAULT_PROOF_SIZE: u64 = 1024; @@ -393,6 +480,66 @@ parameter_type_with_key! { }; } +// What follows here are specialties only used for xToken reserve-transferring TEER to Karura, Bifrost and Moonriver + +const fn teer_general_key() -> Junction { + const TEER_KEY: [u8; 32] = *b"TEER\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: TEER_KEY } +} +const TEER_GENERAL_KEY: Junction = teer_general_key(); + +/// Converts a CurrencyId into a Multilocation, used by xtoken for XCMP. +pub struct CurrencyIdConvert; +impl Convert> for CurrencyIdConvert { + fn convert(id: CurrencyId) -> Option { + match id { + CurrencyId::TEER => Some(MultiLocation::new( + 1, + X2(Parachain(ParachainInfo::parachain_id().into()), TEER_GENERAL_KEY), + )), + } + } +} +parameter_types! { + pub SelfReserveAlias: MultiLocation = MultiLocation { + parents:0, + interior: Junctions::X1(TEER_GENERAL_KEY) + }; + // This is how we are going to detect whether the asset is a Reserve asset + pub SelfLocation: MultiLocation = MultiLocation::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: MultiLocation = MultiLocation { + parents:1, + interior: Junctions::X1( + Parachain(ParachainInfo::parachain_id().into()) + ) + }; + +} + +/// This struct offers uses RelativeReserveProvider to output relative views of multilocations +/// However, additionally accepts a MultiLocation 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(MultiLocation::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 + AbsoluteMultiLocation: Get, +{ + fn reserve(asset: &MultiAsset) -> Option { + RelativeReserveProvider::reserve(asset).map(|relative_reserve| { + if relative_reserve == AbsoluteMultiLocation::get() { + MultiLocation::here() + } else { + relative_reserve + } + }) + } +} + pub struct AccountIdToMultiLocation; impl Convert for AccountIdToMultiLocation { fn convert(account: AccountId) -> MultiLocation { diff --git a/scripts/dump-essential-balances.sh b/scripts/dump-essential-balances.sh new file mode 100755 index 00000000..c76368da --- /dev/null +++ b/scripts/dump-essential-balances.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# make sure polkadot-js-api is in the path +# run zombienet locally +# +# example +# --------------- +# ./dump-essential-balances.sh > fee1.txt +# DO YOUR THING +# ./dump-essential-balances.sh > fee2.txt +# +# compare balances pre/post YOUR THING +# diff -y -W 80 fee1.txt fee2.txt + +ASSET_HUB="ws://127.0.0.1:9954" +INTEGRITEE="ws://127.0.0.1:9944" +ROCOCO="ws://127.0.0.1:9999" + +# subalfred key --type pallet --show-prefix 'py/trsry' +TREASURY=5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z + +function print_balances() { + echo "*** print balances for $1" + echo "Asset Hub ROC" + polkadot-js-api --ws $ASSET_HUB query.system.account $1 | jq .account.data.free + echo "Asset Hub TEER" + polkadot-js-api --ws $ASSET_HUB query.foreignAssets.account '{ "parents": "1", "interior": { "X1": { "Parachain": "2015" }}}' $1 | jq .account.balance + #integritee-cli -p $ASSET_HUB balance $1 + echo "Rococo ROC" + polkadot-js-api --ws $ROCOCO query.system.account $1 | jq .account.data.free + #integritee-cli -p $ROCOCO balance $1 + echo "Integritee TEER" + polkadot-js-api --ws $INTEGRITEE query.system.account $1 | jq .account.data.free + echo "Integritee ROC" + polkadot-js-api --ws $INTEGRITEE query.assets.account 0 $1 | jq .account.balance + #integritee-cli -p $INTEGRITEE balance $1 +} + +echo "*** total supply of TEER@Integritee" +polkadot-js-api --ws $INTEGRITEE query.balances.totalIssuance | jq .totalIssuance +echo "*** ROC derivative total issuance on Integritee" +polkadot-js-api --ws $INTEGRITEE query.assets.asset 0 | jq .asset.supply +echo "*** TEER Treasury@Integritee balance" +polkadot-js-api --ws $INTEGRITEE query.system.account $TREASURY | jq .account.data.free +echo "*** ROC Treasury@Integritee balance" +polkadot-js-api --ws $INTEGRITEE query.assets.account 0 $TREASURY | jq .account.balance + +echo "*** Alice" +print_balances 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY +echo "*** Parachain 2015" +print_balances 5Ec4AhPXwiUhF3u21i56Uxc5XFUNEkKAq79kutWUAx1jyz47 +echo "*** Parachain 1000" +print_balances 5Ec4AhPZk8STuex8Wsi9TwDtJQxKqzPJRCH7348Xtcs9vZLJ +echo "*** Sibling 2015" +print_balances 5Eg2fntM2SfbNedAZi2Bbbwtmj9fxANGtkoCAr2y3g3JqoH4 +echo "*** Sibling 1000" +print_balances 5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV + + + + + diff --git a/scripts/hrmp-helper.sh b/scripts/hrmp-helper.sh new file mode 100755 index 00000000..96b1f3f7 --- /dev/null +++ b/scripts/hrmp-helper.sh @@ -0,0 +1,79 @@ +# Helper script to open HRMP channels between Trappist, Stout and Asset Hub. +# This script is meant to be run after the relay chain and parachains are spawned. + +# Change for your bin path +POLKADOT_BIN=~/bin/polkadot +POLKADOT_PARACHAIN_BIN=~/bin/polkadot-parachain + +function ensure_binaries() { + echo "*** Checking for required binaries" + if [[ ! -f "$POLKADOT_BIN" ]]; then + echo " Required polkadot binary '$POLKADOT_BIN' does not exist!" + echo " You need to build it and copy to this location!" + exit 1 + fi + if [[ ! -f "$POLKADOT_PARACHAIN_BIN" ]]; then + echo " Required polkadot-parachain binary '$POLKADOT_PARACHAIN_BIN' does not exist!" + echo " You need to build it and copy to this location!" + exit 1 + fi + echo "*** All required binaries are present" +} + +function ensure_polkadot_js_api() { + echo "*** Checking for required polkadot-js-api" + if ! which polkadot-js-api &>/dev/null; then + echo '' + echo 'Required command `polkadot-js-api` not in PATH, please, install, e.g.:' + echo "npm install -g @polkadot/api-cli" + echo " or" + echo "yarn global add @polkadot/api-cli" + echo '' + exit 1 + fi +} + +function open_hrmp_channels() { + local relay_url=$1 + local relay_chain_seed=$2 + local sender_para_id=$3 + local recipient_para_id=$4 + local max_capacity=$5 + local max_message_size=$6 + echo " calling open_hrmp_channels:" + echo " relay_url: ${relay_url}" + echo " relay_chain_seed: ${relay_chain_seed}" + echo " sender_para_id: ${sender_para_id}" + echo " recipient_para_id: ${recipient_para_id}" + echo " max_capacity: ${max_capacity}" + echo " max_message_size: ${max_message_size}" + echo " params:" + echo "--------------------------------------------------" + polkadot-js-api \ + --ws "${relay_url?}" \ + --seed "${relay_chain_seed?}" \ + --sudo \ + tx.hrmp.forceOpenHrmpChannel \ + ${sender_para_id} \ + ${recipient_para_id} \ + ${max_capacity} \ + ${max_message_size} +} + +# Check for binaries +ensure_binaries + +# Check for polkadot-js-api cli +ensure_polkadot_js_api + +# HRMP: Integritee - Asset Hub +open_hrmp_channels \ + "ws://127.0.0.1:9999" \ + "//Alice" \ + 2015 1000 4 524288 + +# HRMP: Asset Hub - Integritee +open_hrmp_channels \ + "ws://127.0.0.1:9999" \ + "//Alice" \ + 1000 2015 4 524288 diff --git a/zombienet/rococo-local-with-integritee-and-asset-hub.toml b/zombienet/rococo-local-with-integritee-and-asset-hub.toml index 5aba7bee..0993b2ac 100644 --- a/zombienet/rococo-local-with-integritee-and-asset-hub.toml +++ b/zombienet/rococo-local-with-integritee-and-asset-hub.toml @@ -3,7 +3,7 @@ timeout = 10000 [relaychain] default_command = "~/bin/polkadot" -default_args = [ "-lparachain=debug" ] +default_args = [ "-lparachain=debug,xcm=trace" ] chain = "rococo-local" [[relaychain.nodes]] @@ -30,39 +30,33 @@ chain = "integritee-rococo-local-dev" [[parachains.collators]] name = "integritee-collator-1" command = "./target/release/integritee-collator" + args = ["-lxcm=trace,runtime=debug"] ws_port = 9944 [[parachains.collators]] name = "integritee-collator-2" command = "./target/release/integritee-collator" + args = ["-lxcm=trace,runtime=debug"] ws_port = 9945 [[parachains]] id = 1000 addToGenesis = true cumulus_based = true -chain = "statemine-local" +chain = "asset-hub-rococo-local" [[parachains.collators]] name = "asset-hub-collator-1" validator = true - command = "~/bin/polkadot-parachain-v0.9.42" + command = "~/bin/polkadot-parachain" + args = ["-lxcm=trace,runtime=debug"] ws_port = 9954 [[parachains.collators]] name = "asset-hub-collator-2" validator = true - command = "~/bin/polkadot-parachain-v0.9.42" + command = "~/bin/polkadot-parachain" + args = ["-lxcm=trace,runtime=debug"] ws_port = 9955 -[[hrmp_channels]] -sender = 2015 -recipient = 1000 -max_capacity = 8 -max_message_size = 512 - -[[hrmp_channels]] -sender = 1000 -recipient = 2015 -max_capacity = 8 -max_message_size = 512 +# don't open HRMP channels here, will stop block production of parachains. use ./scripts/hrmp_helper.sh diff --git a/zombienet/rococo-local-with-integritee.toml b/zombienet/rococo-local-with-integritee.toml index 02f7c990..1b30429d 100644 --- a/zombienet/rococo-local-with-integritee.toml +++ b/zombienet/rococo-local-with-integritee.toml @@ -4,7 +4,7 @@ timeout = 10000 [relaychain] chain = "rococo-local" default_command = "~/bin/polkadot" -default_args = [ "-lparachain=debug" ] +default_args = [ "-lparachain=debug,xcm=trace" ] [[relaychain.nodes]] name = "alice" @@ -31,11 +31,13 @@ chain = "integritee-rococo-local-dev" name = "integritee-collator01" #command = "~/bin/integritee-collator-v1.6.4" command = "./target/release/integritee-collator" +args = ["-lxcm=trace,runtime=debug"] ws_port = 9944 [[parachains.collators]] name = "integritee-collator02" #command = "~/bin/integritee-collator-v1.6.4" command = "./target/release/integritee-collator" +args = ["-lxcm=trace,runtime=debug"] ws_port = 9945