From 21edd29cba465e53dbcd337c7e7fe4a81c7890aa Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 7 Dec 2023 18:33:14 +0200 Subject: [PATCH 01/18] emulated chains compile --- Cargo.lock | 1702 ++++++++++++++++- Cargo.toml | 2 + .../relays/kusama/Cargo.toml | 47 + .../relays/kusama/src/genesis.rs | 101 + .../relays/kusama/src/lib.rs | 48 + .../relays/polkadot/Cargo.toml | 30 + .../relays/polkadot/src/genesis.rs | 105 + .../relays/polkadot/src/lib.rs | 50 + integration-tests/emulated/common/Cargo.toml | 76 + .../emulated/common/src/constants.rs | 768 ++++++++ .../emulated/common/src/impls.rs | 645 +++++++ integration-tests/emulated/common/src/lib.rs | 327 ++++ .../emulated/common/src/macros.rs | 107 ++ .../emulated/common/src/xcm_helpers.rs | 66 + 14 files changed, 3978 insertions(+), 96 deletions(-) create mode 100644 integration-tests/emulated/chains-definitions/relays/kusama/Cargo.toml create mode 100644 integration-tests/emulated/chains-definitions/relays/kusama/src/genesis.rs create mode 100644 integration-tests/emulated/chains-definitions/relays/kusama/src/lib.rs create mode 100644 integration-tests/emulated/chains-definitions/relays/polkadot/Cargo.toml create mode 100644 integration-tests/emulated/chains-definitions/relays/polkadot/src/genesis.rs create mode 100644 integration-tests/emulated/chains-definitions/relays/polkadot/src/lib.rs create mode 100644 integration-tests/emulated/common/Cargo.toml create mode 100644 integration-tests/emulated/common/src/constants.rs create mode 100644 integration-tests/emulated/common/src/impls.rs create mode 100644 integration-tests/emulated/common/src/lib.rs create mode 100644 integration-tests/emulated/common/src/macros.rs create mode 100644 integration-tests/emulated/common/src/xcm_helpers.rs diff --git a/Cargo.lock b/Cargo.lock index 90c6aff873..cfff363585 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -185,6 +185,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "always-assert" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -1900,6 +1906,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "comfy-table" +version = "7.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" +dependencies = [ + "strum 0.25.0", + "strum_macros 0.25.3", + "unicode-width", +] + [[package]] name = "common-path" version = "1.0.0" @@ -2014,6 +2031,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "cpu-time" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "cpufeatures" version = "0.2.9" @@ -3068,6 +3095,49 @@ dependencies = [ "zeroize", ] +[[package]] +name = "emulated-integration-tests-common" +version = "1.0.0" +dependencies = [ + "asset-test-utils", + "bp-messages", + "bridge-runtime-common", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "kusama-runtime-constants", + "pallet-assets", + "pallet-balances", + "pallet-bridge-messages", + "pallet-im-online", + "pallet-message-queue", + "pallet-staking", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "paste", + "penpal-runtime", + "polkadot-core-primitives", + "polkadot-parachain-primitives", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-service", + "serde_json", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core", + "sp-runtime", + "staging-kusama-runtime", + "staging-xcm", + "xcm-emulator", +] + [[package]] name = "encode_unicode" version = "0.3.6" @@ -3449,6 +3519,55 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "frame-benchmarking-cli" +version = "29.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e51c371bff90ba44767a79e72a036d7d648cee621cd2fe9f693e8c1d62941e" +dependencies = [ + "Inflector", + "array-bytes 6.1.0", + "chrono", + "clap", + "comfy-table", + "frame-benchmarking", + "frame-support", + "frame-system", + "gethostname", + "handlebars", + "itertools 0.10.5", + "lazy_static", + "linked-hash-map", + "log", + "parity-scale-codec", + "rand 0.8.5", + "rand_pcg", + "sc-block-builder", + "sc-cli", + "sc-client-api", + "sc-client-db", + "sc-executor", + "sc-service", + "sc-sysinfo", + "serde", + "serde_json", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-database", + "sp-externalities", + "sp-inherents", + "sp-io", + "sp-keystore", + "sp-runtime", + "sp-state-machine", + "sp-storage", + "sp-trie", + "sp-wasm-interface", + "thiserror", + "thousands", +] + [[package]] name = "frame-election-provider-solution-type" version = "12.0.0" @@ -3849,6 +3968,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "getrandom" version = "0.1.16" @@ -4006,6 +4135,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "handlebars" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "hash-db" version = "0.16.0" @@ -4517,6 +4660,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "is_executable" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa9acdc6d67b75e626ad644734e8bc6df893d9cd2a834129065d3dd6158ea9c8" +dependencies = [ + "winapi", +] + [[package]] name = "itertools" version = "0.10.5" @@ -4778,6 +4930,17 @@ dependencies = [ "smallvec", ] +[[package]] +name = "landlock" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1530c5b973eeed4ac216af7e24baf5737645a6272e361f1fb95710678b67d9cc" +dependencies = [ + "enumflags2", + "libc", + "thiserror", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -5674,6 +5837,43 @@ dependencies = [ "zeroize", ] +[[package]] +name = "mmr-gadget" +version = "26.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62eff76fd1de7bad43b0e9e666970ae11ef8c24f49622585362c21ae5470986f" +dependencies = [ + "futures", + "log", + "parity-scale-codec", + "sc-client-api", + "sc-offchain", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-consensus-beefy", + "sp-core", + "sp-mmr-primitives", + "sp-runtime", +] + +[[package]] +name = "mmr-rpc" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a387f061e68601d268aade23387eaaf6542e82b357ebc1f8d6a95a251b996d30" +dependencies = [ + "anyhow", + "jsonrpsee", + "parity-scale-codec", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-mmr-primitives", + "sp-runtime", +] + [[package]] name = "mockall" version = "0.11.4" @@ -5971,6 +6171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", + "num-bigint", "num-integer", "num-traits", ] @@ -6643,7 +6844,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] @@ -7371,6 +7572,23 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-transaction-payment-rpc" +version = "27.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99adb3915b29d04362648a4be9114de3bfe37c431f214b1ef96b71f358950d9d" +dependencies = [ + "jsonrpsee", + "pallet-transaction-payment-rpc-runtime-api", + "parity-scale-codec", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", + "sp-weights", +] + [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "25.0.0" @@ -7797,6 +8015,67 @@ dependencies = [ "base64ct", ] +[[package]] +name = "penpal-runtime" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63d1c2aa2cbc5012e6af2781ff7fb0bf7188ff4d25643a0f36a44f327b779fb4" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "polkadot-parachain-primitives", + "polkadot-primitives", + "polkadot-runtime-common", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-genesis-builder", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-storage", + "sp-transaction-pool", + "sp-version", + "staging-parachain-info", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -7804,96 +8083,660 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] -name = "petgraph" -version = "0.6.4" +name = "pest" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ - "fixedbitset", - "indexmap 2.0.0", + "memchr", + "thiserror", + "ucd-trie", ] [[package]] -name = "pin-project" -version = "1.1.3" +name = "pest_derive" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ - "pin-project-internal", + "pest", + "pest_generator", ] [[package]] -name = "pin-project-internal" -version = "1.1.3" +name = "pest_generator" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ + "pest", + "pest_meta", "proc-macro2", "quote", "syn 2.0.38", ] [[package]] -name = "pin-project-lite" -version = "0.1.12" +name = "pest_meta" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - -[[package]] +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +dependencies = [ + "once_cell", + "pest", + "sha2 0.10.7", +] + +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.0.0", +] + +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + +[[package]] name = "pin-project-lite" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der 0.6.1", + "spki 0.6.0", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.8", + "spki 0.7.2", +] + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "platforms" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" + +[[package]] +name = "polkadot-approval-distribution" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aafcdaca311b3f8ea463548cc2f62289a2689d3198ea8cba2d100fab378fff3c" +dependencies = [ + "futures", + "futures-timer", + "polkadot-node-jaeger", + "polkadot-node-metrics", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "tracing-gum", +] + +[[package]] +name = "polkadot-availability-bitfield-distribution" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "316fa25f773ac3f470578d2dc2ff73cefc2a01c9ea0a9a00767529184701792c" +dependencies = [ + "always-assert", + "futures", + "futures-timer", + "polkadot-node-network-protocol", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "tracing-gum", +] + +[[package]] +name = "polkadot-availability-distribution" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "118ed63ece1ec1ccf240ab44d932a932ae778ece57a6fba34953b7c0b436f6b1" +dependencies = [ + "derive_more", + "fatality", + "futures", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "schnellru", + "sp-core", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-availability-recovery" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13245b9f37a4d409c47cf46f74d2601df82f1bf12678b1a792ad1aa5effebd13" +dependencies = [ + "async-trait", + "fatality", + "futures", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "sc-network", + "schnellru", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-collator-protocol" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f5ed0e739de576e41203ba99b9da1347998174a84fb5ea825f1a8e30e1dff88" +dependencies = [ + "bitvec", + "fatality", + "futures", + "futures-timer", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-core", + "sp-keystore", + "sp-runtime", + "thiserror", + "tokio-util", + "tracing-gum", +] + +[[package]] +name = "polkadot-core-primitives" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b08d1d6ca24e1b13f8069e015cfab794344212dd7436aadd61de8086a82664ef" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "polkadot-dispute-distribution" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffa05fec2897e38a2ec42df5f84110fbb170dbe549d5d1e454f635b141cb2aca" +dependencies = [ + "derive_more", + "fatality", + "futures", + "futures-timer", + "indexmap 1.9.3", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sc-network", + "schnellru", + "sp-application-crypto", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-erasure-coding" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9714c537368095f1bc2e70c45fb8ae3347c19b344f8d5b4722cc781690a74924" +dependencies = [ + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-primitives", + "reed-solomon-novelpoly", + "sp-core", + "sp-trie", + "thiserror", +] + +[[package]] +name = "polkadot-gossip-support" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9acc782f4c0efb0809cc325a49b50c498255a973dfc665e940043af20936d525" +dependencies = [ + "futures", + "futures-timer", + "polkadot-node-network-protocol", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "rand_chacha 0.3.1", + "sc-network", + "sc-network-common", + "sp-application-crypto", + "sp-core", + "sp-keystore", + "tracing-gum", +] + +[[package]] +name = "polkadot-network-bridge" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7355e7f9cac8e5fe4899796e92aea2ea94678854dc44e21890a33d4c6c6ec3" +dependencies = [ + "always-assert", + "async-trait", + "bytes", + "fatality", + "futures", + "parity-scale-codec", + "parking_lot 0.12.1", + "polkadot-node-metrics", + "polkadot-node-network-protocol", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "sc-network", + "sp-consensus", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-collation-generation" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bed91a561c9edfc5bd1d8e432cec8cecde63aaf12131cc19881d67e39be0fce" +dependencies = [ + "futures", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-core", + "sp-maybe-compressed-blob", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-approval-voting" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976e5fcd0c10fbe37d120a9e4702324585e529498c56d03fd7b529f17644fe34" +dependencies = [ + "bitvec", + "derive_more", + "futures", + "futures-timer", + "kvdb", + "merlin", + "parity-scale-codec", + "polkadot-node-jaeger", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-primitives", + "sc-keystore", + "schnellru", + "schnorrkel", + "sp-application-crypto", + "sp-consensus", + "sp-consensus-slots", + "sp-runtime", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-av-store" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9d1018400db515cec0748e4c83d6010601d1784350dfd465386a7ee47699cd3" +dependencies = [ + "bitvec", + "futures", + "futures-timer", + "kvdb", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-jaeger", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-primitives", + "sp-consensus", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-backing" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "051940f4f7214dcc370077ead642052cda2c7316641ea9ff1f05624be2a272d2" +dependencies = [ + "bitvec", + "fatality", + "futures", + "polkadot-erasure-coding", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "polkadot-statement-table", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-bitfield-signing" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77cea47f010914b5e52f2f1eb96c058cb117045c5864c733236e7b24ea103d22" +dependencies = [ + "futures", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-keystore", + "thiserror", + "tracing-gum", + "wasm-timer", +] + +[[package]] +name = "polkadot-node-core-candidate-validation" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbb2306632d1ee08cc2f4d5945b4ec795fd79ce801ae03e79961c18877220ed2" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "parity-scale-codec", + "polkadot-node-core-pvf", + "polkadot-node-metrics", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-parachain-primitives", + "polkadot-primitives", + "sp-maybe-compressed-blob", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-chain-api" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e8787fcec6e036d21421adf3db0295c142a878c482e0aba2e5aefcf050f10" +dependencies = [ + "futures", + "polkadot-node-metrics", + "polkadot-node-subsystem", + "polkadot-primitives", + "sc-client-api", + "sc-consensus-babe", + "sp-blockchain", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-chain-selection" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8028469b10f5f1fa10ea9b08cb09bb53bcb55a25298e4154928d3aaf7d5d066a" +dependencies = [ + "futures", + "futures-timer", + "kvdb", + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-dispute-coordinator" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "662387f0e7b23596326754796fbb6f52e32c3deb0c11f9ff341e23a0a7139608" +dependencies = [ + "fatality", + "futures", + "kvdb", + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sc-keystore", + "schnellru", + "thiserror", + "tracing-gum", +] [[package]] -name = "pin-utils" -version = "0.1.0" +name = "polkadot-node-core-parachains-inherent" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "ec0f57ce13de845fe1441fa3ab3405dcb142d3dc0ea985c4e28efa35b97d07d0" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "sp-blockchain", + "sp-inherents", + "thiserror", + "tracing-gum", +] [[package]] -name = "pkcs8" -version = "0.9.0" +name = "polkadot-node-core-prospective-parachains" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "5a010a14312c5c5eec800397cc60cce10131d4a29cedf563ee639fc7b9b27ba1" dependencies = [ - "der 0.6.1", - "spki 0.6.0", + "bitvec", + "fatality", + "futures", + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "thiserror", + "tracing-gum", ] [[package]] -name = "pkcs8" -version = "0.10.2" +name = "polkadot-node-core-provisioner" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +checksum = "d8a67ac3aa0a0e89ff20d5eb761fca78c124848a2627e35343e824d78cc9fe91" dependencies = [ - "der 0.7.8", - "spki 0.7.2", + "bitvec", + "fatality", + "futures", + "futures-timer", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "thiserror", + "tracing-gum", ] [[package]] -name = "pkg-config" -version = "0.3.27" +name = "polkadot-node-core-pvf" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "6f58224dbfbd773947ff3fccc3318bda11909e8a0f7c36f7f1234c0c1f25a62a" +dependencies = [ + "always-assert", + "cfg-if", + "futures", + "futures-timer", + "is_executable", + "libc", + "parity-scale-codec", + "pin-project", + "polkadot-core-primitives", + "polkadot-node-core-pvf-common", + "polkadot-node-metrics", + "polkadot-node-primitives", + "polkadot-parachain-primitives", + "polkadot-primitives", + "rand 0.8.5", + "slotmap", + "sp-core", + "sp-maybe-compressed-blob", + "sp-wasm-interface", + "tempfile", + "tokio", + "tracing-gum", +] [[package]] -name = "platforms" -version = "3.0.2" +name = "polkadot-node-core-pvf-checker" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" +checksum = "7abe14484e66b365748bd4b2988cc2c68e03146bc399bdf8139f9eb5cf6c6cf0" +dependencies = [ + "futures", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-primitives", + "sp-keystore", + "thiserror", + "tracing-gum", +] [[package]] -name = "polkadot-core-primitives" +name = "polkadot-node-core-pvf-common" version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b08d1d6ca24e1b13f8069e015cfab794344212dd7436aadd61de8086a82664ef" +checksum = "94004d011a260b8efdf6ddf80ac815ba6ede84bb46e32d588161c1d860c5a65d" dependencies = [ + "cfg-if", + "cpu-time", + "futures", + "landlock", + "libc", "parity-scale-codec", - "scale-info", + "polkadot-parachain-primitives", + "polkadot-primitives", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", "sp-core", - "sp-runtime", - "sp-std", + "sp-externalities", + "sp-io", + "sp-tracing", + "tokio", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-runtime-api" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dccc7a95fea3562bd3a47f22c0e4ddcb755114dc0477f3173db8d5ebf0d84f50" +dependencies = [ + "futures", + "polkadot-node-metrics", + "polkadot-node-subsystem", + "polkadot-node-subsystem-types", + "polkadot-primitives", + "schnellru", + "sp-consensus-babe", + "tracing-gum", ] [[package]] @@ -7955,7 +8798,7 @@ dependencies = [ "rand 0.8.5", "sc-authority-discovery", "sc-network", - "strum", + "strum 0.24.1", "thiserror", "tracing-gum", ] @@ -7983,6 +8826,17 @@ dependencies = [ "zstd 0.12.4", ] +[[package]] +name = "polkadot-node-subsystem" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e89d3f964ebd57275c2fff4d3cc755d210698fedeac1a0a238c0eb31534c96d" +dependencies = [ + "polkadot-node-jaeger", + "polkadot-node-subsystem-types", + "polkadot-overseer", +] + [[package]] name = "polkadot-node-subsystem-types" version = "4.0.0" @@ -8009,6 +8863,42 @@ dependencies = [ "thiserror", ] +[[package]] +name = "polkadot-node-subsystem-util" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8134075bfee921305ff229412e9282a3351215bf049c6a403197cc795f919941" +dependencies = [ + "async-trait", + "derive_more", + "fatality", + "futures", + "futures-channel", + "itertools 0.10.5", + "kvdb", + "parity-db", + "parity-scale-codec", + "parking_lot 0.11.2", + "pin-project", + "polkadot-node-jaeger", + "polkadot-node-metrics", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-types", + "polkadot-overseer", + "polkadot-primitives", + "prioritized-metered-channel", + "rand 0.8.5", + "sc-client-api", + "schnellru", + "sp-application-crypto", + "sp-core", + "sp-keystore", + "thiserror", + "tracing-gum", +] + [[package]] name = "polkadot-overseer" version = "4.0.0" @@ -8077,6 +8967,39 @@ dependencies = [ "sp-std", ] +[[package]] +name = "polkadot-rpc" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce0432643ea2e4923db1f0ba6c82305c53725e18c857e911c4d979e4f7aafae5" +dependencies = [ + "jsonrpsee", + "mmr-rpc", + "pallet-transaction-payment-rpc", + "polkadot-primitives", + "sc-chain-spec", + "sc-client-api", + "sc-consensus-babe", + "sc-consensus-babe-rpc", + "sc-consensus-beefy", + "sc-consensus-beefy-rpc", + "sc-consensus-epochs", + "sc-consensus-grandpa", + "sc-consensus-grandpa-rpc", + "sc-rpc", + "sc-sync-state-rpc", + "sc-transaction-pool-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-keystore", + "sp-runtime", + "substrate-frame-rpc-system", + "substrate-state-trie-migration-rpc", +] + [[package]] name = "polkadot-runtime" version = "1.0.0" @@ -8310,11 +9233,151 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", - "sp-tracing", - "staging-xcm", - "staging-xcm-executor", - "static_assertions", + "sp-std", + "sp-tracing", + "staging-xcm", + "staging-xcm-executor", + "static_assertions", +] + +[[package]] +name = "polkadot-service" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc65d44c4dd6a8be74194dcac66552dd4e79ee0bcc287349721925e8238177a" +dependencies = [ + "async-trait", + "frame-benchmarking", + "frame-benchmarking-cli", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "futures", + "hex-literal", + "is_executable", + "kvdb", + "kvdb-rocksdb", + "log", + "mmr-gadget", + "pallet-babe", + "pallet-im-online", + "pallet-staking", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "parity-db", + "parity-scale-codec", + "polkadot-approval-distribution", + "polkadot-availability-bitfield-distribution", + "polkadot-availability-distribution", + "polkadot-availability-recovery", + "polkadot-collator-protocol", + "polkadot-core-primitives", + "polkadot-dispute-distribution", + "polkadot-gossip-support", + "polkadot-network-bridge", + "polkadot-node-collation-generation", + "polkadot-node-core-approval-voting", + "polkadot-node-core-av-store", + "polkadot-node-core-backing", + "polkadot-node-core-bitfield-signing", + "polkadot-node-core-candidate-validation", + "polkadot-node-core-chain-api", + "polkadot-node-core-chain-selection", + "polkadot-node-core-dispute-coordinator", + "polkadot-node-core-parachains-inherent", + "polkadot-node-core-prospective-parachains", + "polkadot-node-core-provisioner", + "polkadot-node-core-pvf", + "polkadot-node-core-pvf-checker", + "polkadot-node-core-runtime-api", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-types", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-parachain-primitives", + "polkadot-primitives", + "polkadot-rpc", + "polkadot-runtime-parachains", + "polkadot-statement-distribution", + "sc-authority-discovery", + "sc-basic-authorship", + "sc-block-builder", + "sc-chain-spec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-beefy", + "sc-consensus-grandpa", + "sc-consensus-slots", + "sc-executor", + "sc-keystore", + "sc-network", + "sc-network-common", + "sc-network-sync", + "sc-offchain", + "sc-service", + "sc-sync-state-rpc", + "sc-sysinfo", + "sc-telemetry", + "sc-transaction-pool", + "sc-transaction-pool-api", + "schnellru", + "serde", + "serde_json", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core", + "sp-inherents", + "sp-io", + "sp-keyring", + "sp-keystore", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-state-machine", + "sp-storage", + "sp-timestamp", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "substrate-prometheus-endpoint", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-statement-distribution" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6992cb6e2ba744752f9f403cb5e0f70ac5431f39f9ea859a3978f22c79799cb" +dependencies = [ + "arrayvec 0.7.4", + "bitvec", + "fatality", + "futures", + "futures-timer", + "indexmap 1.9.3", + "parity-scale-codec", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-types", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-keystore", + "sp-staking", + "thiserror", + "tracing-gum", ] [[package]] @@ -8876,6 +9939,19 @@ dependencies = [ "thiserror", ] +[[package]] +name = "reed-solomon-novelpoly" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58130877ca403ab42c864fbac74bb319a0746c07a634a92a5cfc7f54af272582" +dependencies = [ + "derive_more", + "fs-err", + "itertools 0.11.0", + "static_init", + "thiserror", +] + [[package]] name = "ref-cast" version = "1.0.20" @@ -9332,6 +10408,30 @@ dependencies = [ "thiserror", ] +[[package]] +name = "sc-basic-authorship" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0aa6c85e3e0b5af9cab7078166d8c4575b7b9edac0ade6be1aadee828420104" +dependencies = [ + "futures", + "futures-timer", + "log", + "parity-scale-codec", + "sc-block-builder", + "sc-client-api", + "sc-proposer-metrics", + "sc-telemetry", + "sc-transaction-pool-api", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "substrate-prometheus-endpoint", +] + [[package]] name = "sc-block-builder" version = "0.30.0" @@ -9415,91 +10515,306 @@ dependencies = [ "sp-keystore", "sp-panic-handler", "sp-runtime", - "sp-version", + "sp-version", + "thiserror", + "tiny-bip39", + "tokio", +] + +[[package]] +name = "sc-client-api" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d32101f415f4d7ddbe8b5de1c1387a78d6dce070e26407ec605fe9f3fc9e23" +dependencies = [ + "fnv", + "futures", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-executor", + "sc-transaction-pool-api", + "sc-utils", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-database", + "sp-externalities", + "sp-runtime", + "sp-state-machine", + "sp-statement-store", + "sp-storage", + "sp-trie", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-client-db" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ced79f609a44782874d856cf39d256838957195ef34f4fb8ced90bf4b725d0" +dependencies = [ + "hash-db", + "kvdb", + "kvdb-memorydb", + "kvdb-rocksdb", + "linked-hash-map", + "log", + "parity-db", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-state-db", + "schnellru", + "sp-arithmetic", + "sp-blockchain", + "sp-core", + "sp-database", + "sp-runtime", + "sp-state-machine", + "sp-trie", +] + +[[package]] +name = "sc-consensus" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e4100cc8fb3876708e1ec5a7c63af3baa75febd5051beb9ddd1e4835fdfc27" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "libp2p-identity", + "log", + "mockall", + "parking_lot 0.12.1", + "sc-client-api", + "sc-utils", + "serde", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "sp-state-machine", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-consensus-babe" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a48ef5eaf7bffc647dfdfd42c7c02a929d89410b065beeb80753fd94f5fe70d" +dependencies = [ + "async-trait", + "fork-tree", + "futures", + "log", + "num-bigint", + "num-rational", + "num-traits", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-consensus", + "sc-consensus-epochs", + "sc-consensus-slots", + "sc-telemetry", + "sc-transaction-pool-api", + "sp-api", + "sp-application-crypto", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-slots", + "sp-core", + "sp-inherents", + "sp-keystore", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-consensus-babe-rpc" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a78a543d8d2e8d9a6a8b60f16ac12e6fbeffbc2322ef8fa139f733ce53ccaa8" +dependencies = [ + "futures", + "jsonrpsee", + "sc-consensus-babe", + "sc-consensus-epochs", + "sc-rpc-api", + "serde", + "sp-api", + "sp-application-crypto", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-core", + "sp-keystore", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "sc-consensus-beefy" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3709a96723feaeb7a7ca0d3f7995d084029f8effeeb09d45975a8aa3ba1a63b" +dependencies = [ + "array-bytes 6.1.0", + "async-channel", + "async-trait", + "fnv", + "futures", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-consensus", + "sc-network", + "sc-network-gossip", + "sc-network-sync", + "sc-utils", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-consensus-beefy", + "sp-core", + "sp-keystore", + "sp-mmr-primitives", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", + "wasm-timer", +] + +[[package]] +name = "sc-consensus-beefy-rpc" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1699fe1791dd985a5dd6075c84136027eb3e2ccff46d3e5273fdbd5b246f763" +dependencies = [ + "futures", + "jsonrpsee", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-consensus-beefy", + "sc-rpc", + "serde", + "sp-consensus-beefy", + "sp-core", + "sp-runtime", "thiserror", - "tiny-bip39", - "tokio", ] [[package]] -name = "sc-client-api" -version = "25.0.0" +name = "sc-consensus-epochs" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d32101f415f4d7ddbe8b5de1c1387a78d6dce070e26407ec605fe9f3fc9e23" +checksum = "5eafc0534bb118f614fc50fe066e423dbecfedf816cd9c43e0b492e30c1782c8" dependencies = [ - "fnv", + "fork-tree", + "parity-scale-codec", + "sc-client-api", + "sc-consensus", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +name = "sc-consensus-grandpa" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30cbc5db21ea2c4ba65b23315e73e69e8155630fb47c84b93d40b0e759c9d86d" +dependencies = [ + "ahash 0.8.3", + "array-bytes 6.1.0", + "async-trait", + "dyn-clone", + "finality-grandpa", + "fork-tree", "futures", + "futures-timer", "log", "parity-scale-codec", "parking_lot 0.12.1", - "sc-executor", + "rand 0.8.5", + "sc-block-builder", + "sc-chain-spec", + "sc-client-api", + "sc-consensus", + "sc-network", + "sc-network-common", + "sc-network-gossip", + "sc-telemetry", "sc-transaction-pool-api", "sc-utils", + "serde_json", "sp-api", + "sp-application-crypto", + "sp-arithmetic", "sp-blockchain", "sp-consensus", + "sp-consensus-grandpa", "sp-core", - "sp-database", - "sp-externalities", + "sp-keystore", "sp-runtime", - "sp-state-machine", - "sp-statement-store", - "sp-storage", - "sp-trie", "substrate-prometheus-endpoint", + "thiserror", ] [[package]] -name = "sc-client-db" -version = "0.32.0" +name = "sc-consensus-grandpa-rpc" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4ced79f609a44782874d856cf39d256838957195ef34f4fb8ced90bf4b725d0" +checksum = "a3c545dac29d5dd002170e063ca0725be95ef653be135d251f91dbe053f63173" dependencies = [ - "hash-db", - "kvdb", - "kvdb-memorydb", - "kvdb-rocksdb", - "linked-hash-map", + "finality-grandpa", + "futures", + "jsonrpsee", "log", - "parity-db", "parity-scale-codec", - "parking_lot 0.12.1", "sc-client-api", - "sc-state-db", - "schnellru", - "sp-arithmetic", + "sc-consensus-grandpa", + "sc-rpc", + "serde", "sp-blockchain", "sp-core", - "sp-database", "sp-runtime", - "sp-state-machine", - "sp-trie", + "thiserror", ] [[package]] -name = "sc-consensus" +name = "sc-consensus-slots" version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e4100cc8fb3876708e1ec5a7c63af3baa75febd5051beb9ddd1e4835fdfc27" +checksum = "2059681962e33394682627e7bd7245b5094236594f5c97c4c96988d901bda534" dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p-identity", "log", - "mockall", - "parking_lot 0.12.1", + "parity-scale-codec", "sc-client-api", - "sc-utils", - "serde", - "sp-api", + "sc-consensus", + "sc-telemetry", + "sp-arithmetic", "sp-blockchain", "sp-consensus", + "sp-consensus-slots", "sp-core", + "sp-inherents", "sp-runtime", "sp-state-machine", - "substrate-prometheus-endpoint", - "thiserror", ] [[package]] @@ -9699,6 +11014,25 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "sc-network-gossip" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b884a9f7cd348c4c1899c0bbf95237e39dffba4baec48d4b98c1046f6bb04fa5" +dependencies = [ + "ahash 0.8.3", + "futures", + "futures-timer", + "libp2p", + "log", + "sc-network", + "sc-network-common", + "schnellru", + "sp-runtime", + "substrate-prometheus-endpoint", + "tracing", +] + [[package]] name = "sc-network-light" version = "0.30.0" @@ -9776,6 +11110,51 @@ dependencies = [ "substrate-prometheus-endpoint", ] +[[package]] +name = "sc-offchain" +version = "26.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47950facab8dedf71c39667ccce8834252944e8f091f3a3bcdfc0b4503573da4" +dependencies = [ + "array-bytes 6.1.0", + "bytes", + "fnv", + "futures", + "futures-timer", + "hyper", + "hyper-rustls", + "libp2p", + "log", + "num_cpus", + "once_cell", + "parity-scale-codec", + "parking_lot 0.12.1", + "rand 0.8.5", + "sc-client-api", + "sc-network", + "sc-network-common", + "sc-transaction-pool-api", + "sc-utils", + "sp-api", + "sp-core", + "sp-externalities", + "sp-keystore", + "sp-offchain", + "sp-runtime", + "threadpool", + "tracing", +] + +[[package]] +name = "sc-proposer-metrics" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "221845dce4e7adb57eca5f73318699b377cff29aef92a586e71aa5cef62f879b" +dependencies = [ + "log", + "substrate-prometheus-endpoint", +] + [[package]] name = "sc-rpc" version = "26.0.0" @@ -9952,6 +11331,26 @@ dependencies = [ "sp-core", ] +[[package]] +name = "sc-sync-state-rpc" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe1efc0811813b73b9bb6eccc630ccd43d13b4306255a41ef55b9304d32e64c2" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "sc-chain-spec", + "sc-client-api", + "sc-consensus-babe", + "sc-consensus-epochs", + "sc-consensus-grandpa", + "serde", + "serde_json", + "sp-blockchain", + "sp-runtime", + "thiserror", +] + [[package]] name = "sc-sysinfo" version = "24.0.0" @@ -10511,6 +11910,15 @@ dependencies = [ "sp-std", ] +[[package]] +name = "slotmap" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +dependencies = [ + "version_check", +] + [[package]] name = "smallvec" version = "1.11.0" @@ -10759,7 +12167,7 @@ dependencies = [ "sp-mmr-primitives", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] @@ -10960,7 +12368,7 @@ dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum", + "strum 0.24.1", ] [[package]] @@ -11383,7 +12791,7 @@ checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", "maplit", - "strum", + "strum 0.24.1", ] [[package]] @@ -11665,9 +13073,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", ] +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + [[package]] name = "strum_macros" version = "0.24.3" @@ -11681,6 +13095,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.38", +] + [[package]] name = "stun" version = "0.4.4" @@ -11713,6 +13140,26 @@ dependencies = [ "zeroize", ] +[[package]] +name = "substrate-frame-rpc-system" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c241af714c378075b1185e574202cbb9105e849b8c9ea44ef87880bdb3e9a75" +dependencies = [ + "frame-system-rpc-runtime-api", + "futures", + "jsonrpsee", + "log", + "parity-scale-codec", + "sc-rpc-api", + "sc-transaction-pool-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-core", + "sp-runtime", +] + [[package]] name = "substrate-prometheus-endpoint" version = "0.16.0" @@ -11740,6 +13187,24 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "substrate-state-trie-migration-rpc" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d57888ccce554552c535346893a497d2cfd232f15b6b676d130cdd5bf3f2ccea" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "sc-client-api", + "sc-rpc-api", + "serde", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-trie", + "trie-db", +] + [[package]] name = "substrate-wasm-builder" version = "14.0.0" @@ -11752,7 +13217,7 @@ dependencies = [ "filetime", "parity-wasm", "sp-maybe-compressed-blob", - "strum", + "strum 0.24.1", "tempfile", "toml 0.7.6", "walkdir", @@ -11895,6 +13360,12 @@ dependencies = [ "syn 2.0.38", ] +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + [[package]] name = "thread_local" version = "1.1.7" @@ -12433,6 +13904,12 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + [[package]] name = "uint" version = "0.9.5" @@ -12725,8 +14202,8 @@ checksum = "fc942673e7684671f0c5708fc18993569d184265fd5223bb51fc8e5b9b6cfd52" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", @@ -13585,6 +15062,39 @@ dependencies = [ "time 0.3.27", ] +[[package]] +name = "xcm-emulator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd344ca12e6217fbbc6ee27bedb01113357ea31bea198e74b76f618102b6f06c" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "lazy_static", + "log", + "pallet-balances", + "pallet-message-queue", + "parachains-common", + "parity-scale-codec", + "paste", + "polkadot-parachain-primitives", + "polkadot-primitives", + "polkadot-runtime-parachains", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-tracing", + "staging-xcm", + "staging-xcm-executor", +] + [[package]] name = "xcm-procedural" version = "4.0.0" diff --git a/Cargo.toml b/Cargo.toml index ae60da4073..add69cb684 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,8 @@ members = [ "system-parachains/bridge-hubs/bridge-hub-polkadot", "system-parachains/collectives/collectives-polkadot", "system-parachains/gluttons/glutton-kusama", +# "integration-tests/emulated/chains-definitions/relays/kusama", + "integration-tests/emulated/common", ] [profile.release] diff --git a/integration-tests/emulated/chains-definitions/relays/kusama/Cargo.toml b/integration-tests/emulated/chains-definitions/relays/kusama/Cargo.toml new file mode 100644 index 0000000000..d15358c74c --- /dev/null +++ b/integration-tests/emulated/chains-definitions/relays/kusama/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "kusama-emulated-chain" +version = "0.0.0" +authors.workspace = true +edition.workspace = true +license = "Apache-2.0" +description = "Kusama emulated chain" +publish = false + +[dependencies] +serde_json = "1.0.104" + +# Substrate +sp-core = { default-features = false, version = "25.0.0" } +sp-runtime = { default-features = false, version = "28.0.0" } +sp-authority-discovery = { default-features = false , version = "23.0.0" } +sp-consensus-babe = { default-features = false , version = "0.29.0" } +beefy-primitives = { package = "sp-consensus-beefy", default-features = false , version = "10.0.0" } +grandpa-primitives = { package = "sp-consensus-grandpa", default-features = false , version = "10.0.0" } +pallet-im-online = { default-features = false, version = "24.0.0" } + +# Polkadot +polkadot-primitives = { default-features = false , version = "4.0.0" } +kusama-runtime-constants = { path = "../../../../../relay/kusama/constants", default-features = false } +kusama-runtime = { package = "staging-kusama-runtime", path = "../../../../../relay/kusama", default-features = false } + +# Cumulus +parachains-common = { default-features = false, version = "4.0.0" } +#emulated-integration-tests-common = { default-features = false, version = "1.0.0" } +emulated-integration-tests-common = { path = "../../../common", default-features = false } + +[features] +default = [ "std" ] + +std = [ + "sp-core/std", + "sp-runtime/std", + "sp-authority-discovery/std", + "sp-consensus-babe/std", + "beefy-primitives/std", + "grandpa-primitives/std", + "polkadot-primitives/std", + "kusama-runtime-constants/std", + "kusama-runtime/std", + "parachains-common/std", + "pallet-im-online/std", +] diff --git a/integration-tests/emulated/chains-definitions/relays/kusama/src/genesis.rs b/integration-tests/emulated/chains-definitions/relays/kusama/src/genesis.rs new file mode 100644 index 0000000000..128da59486 --- /dev/null +++ b/integration-tests/emulated/chains-definitions/relays/kusama/src/genesis.rs @@ -0,0 +1,101 @@ +// 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. + +// Substrate +use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; +use grandpa_primitives::AuthorityId as GrandpaId; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_core::{sr25519, storage::Storage}; + +// Polkadot +use polkadot_primitives::{AssignmentId, ValidatorId}; + +// Cumulus +use emulated_integration_tests_common::{ + accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, + validators, +}; +use parachains_common::Balance; +use kusama_runtime_constants::currency::UNITS as KSM; + +pub const ED: Balance = kusama_runtime_constants::currency::EXISTENTIAL_DEPOSIT; +const ENDOWMENT: u128 = 1_000_000 * KSM; + +fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + beefy: BeefyId, +) -> kusama_runtime::SessionKeys { + kusama_runtime::SessionKeys { + babe, + grandpa, + im_online, + para_validator, + para_assignment, + authority_discovery, + beefy, + } +} + +pub fn genesis() -> Storage { + let genesis_config = kusama_runtime::RuntimeGenesisConfig { + system: kusama_runtime::SystemConfig::default(), + balances: kusama_runtime::BalancesConfig { + balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(), + }, + session: kusama_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + x.7.clone(), + get_from_seed::("Alice"), + ), + ) + }) + .collect::>(), + }, + babe: kusama_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(kusama_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() + }, + // sudo: kusama_runtime::SudoConfig { + // key: Some(get_account_id_from_seed::("Alice")), + // }, + configuration: kusama_runtime::ConfigurationConfig { config: get_host_config() }, + // registrar: kusama_runtime::RegistrarConfig { + // next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, + // ..Default::default() + // }, + ..Default::default() + }; + + build_genesis_storage(&genesis_config, kusama_runtime::WASM_BINARY.unwrap()) +} diff --git a/integration-tests/emulated/chains-definitions/relays/kusama/src/lib.rs b/integration-tests/emulated/chains-definitions/relays/kusama/src/lib.rs new file mode 100644 index 0000000000..2ebc10f7db --- /dev/null +++ b/integration-tests/emulated/chains-definitions/relays/kusama/src/lib.rs @@ -0,0 +1,48 @@ +// 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. + +pub mod genesis; + +// Cumulus +use emulated_integration_tests_common::{ + impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, + impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, + xcm_emulator::decl_test_relay_chains, +}; + +// Kusama declaration +decl_test_relay_chains! { + #[api_version(9)] + pub struct Kusama { + genesis = genesis::genesis(), + on_init = (), + runtime = kusama_runtime, + core = { + SovereignAccountOf: kusama_runtime::xcm_config::LocalOriginConverter, + }, + pallets = { + XcmPallet: kusama_runtime::XcmPallet, + // Sudo: kusama_runtime::Sudo, + Balances: kusama_runtime::Balances, + Hrmp: kusama_runtime::Hrmp, + } + }, +} + +// Kusama implementation +impl_accounts_helpers_for_relay_chain!(Kusama); +impl_assert_events_helpers_for_relay_chain!(Kusama); +impl_hrmp_channels_helpers_for_relay_chain!(Kusama); +impl_send_transact_helpers_for_relay_chain!(Kusama); diff --git a/integration-tests/emulated/chains-definitions/relays/polkadot/Cargo.toml b/integration-tests/emulated/chains-definitions/relays/polkadot/Cargo.toml new file mode 100644 index 0000000000..20b9737735 --- /dev/null +++ b/integration-tests/emulated/chains-definitions/relays/polkadot/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "westend-emulated-chain" +version = "0.0.0" +authors.workspace = true +edition.workspace = true +license = "Apache-2.0" +description = "Westend emulated chain" +publish = false + +[dependencies] +serde_json = "1.0.104" + +# Substrate +sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false } +sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false } +sp-authority-discovery = { path = "../../../../../../../substrate/primitives/authority-discovery", default-features = false } +sp-consensus-babe = { path = "../../../../../../../substrate/primitives/consensus/babe", default-features = false } +beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../../../substrate/primitives/consensus/beefy" } +grandpa = { package = "sc-consensus-grandpa", path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false } +pallet-im-online = { path = "../../../../../../../substrate/frame/im-online", default-features = false } +pallet-staking = { path = "../../../../../../../substrate/frame/staking", default-features = false } + +# Polkadot +polkadot-primitives = { path = "../../../../../../../polkadot/primitives", default-features = false } +westend-runtime-constants = { path = "../../../../../../../polkadot/runtime/westend/constants", default-features = false } +westend-runtime = { path = "../../../../../../../polkadot/runtime/westend" } + +# Cumulus +parachains-common = { path = "../../../../../../parachains/common" } +emulated-integration-tests-common = { path = "../../../common", default-features = false } diff --git a/integration-tests/emulated/chains-definitions/relays/polkadot/src/genesis.rs b/integration-tests/emulated/chains-definitions/relays/polkadot/src/genesis.rs new file mode 100644 index 0000000000..e2297100a4 --- /dev/null +++ b/integration-tests/emulated/chains-definitions/relays/polkadot/src/genesis.rs @@ -0,0 +1,105 @@ +// 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. + +// Substrate +use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; +use grandpa::AuthorityId as GrandpaId; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_core::storage::Storage; +use sp_runtime::Perbill; + +// Polkadot +use polkadot_primitives::{AssignmentId, ValidatorId}; + +// Cumulus +use emulated_integration_tests_common::{ + accounts, build_genesis_storage, get_from_seed, get_host_config, validators, +}; +use parachains_common::Balance; +use westend_runtime_constants::currency::UNITS as WND; + +pub const ED: Balance = westend_runtime_constants::currency::EXISTENTIAL_DEPOSIT; +const ENDOWMENT: u128 = 1_000_000 * WND; +const STASH: u128 = 100 * WND; + +fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + beefy: BeefyId, +) -> westend_runtime::SessionKeys { + westend_runtime::SessionKeys { + babe, + grandpa, + para_validator, + para_assignment, + authority_discovery, + beefy, + } +} + +pub fn genesis() -> Storage { + let genesis_config = westend_runtime::RuntimeGenesisConfig { + system: westend_runtime::SystemConfig::default(), + balances: westend_runtime::BalancesConfig { + balances: accounts::init_balances().iter().cloned().map(|k| (k, ENDOWMENT)).collect(), + }, + session: westend_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + get_from_seed::("Alice"), + ), + ) + }) + .collect::>(), + }, + staking: westend_runtime::StakingConfig { + validator_count: validators::initial_authorities().len() as u32, + minimum_validator_count: 1, + stakers: validators::initial_authorities() + .iter() + .map(|x| { + (x.0.clone(), x.1.clone(), STASH, westend_runtime::StakerStatus::Validator) + }) + .collect(), + invulnerables: validators::initial_authorities().iter().map(|x| x.0.clone()).collect(), + force_era: pallet_staking::Forcing::ForceNone, + slash_reward_fraction: Perbill::from_percent(10), + ..Default::default() + }, + babe: westend_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(westend_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() + }, + configuration: westend_runtime::ConfigurationConfig { config: get_host_config() }, + ..Default::default() + }; + + build_genesis_storage(&genesis_config, westend_runtime::WASM_BINARY.unwrap()) +} diff --git a/integration-tests/emulated/chains-definitions/relays/polkadot/src/lib.rs b/integration-tests/emulated/chains-definitions/relays/polkadot/src/lib.rs new file mode 100644 index 0000000000..2ba47250d5 --- /dev/null +++ b/integration-tests/emulated/chains-definitions/relays/polkadot/src/lib.rs @@ -0,0 +1,50 @@ +// 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. + +pub mod genesis; + +// Cumulus +use emulated_integration_tests_common::{ + impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, + impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, + xcm_emulator::decl_test_relay_chains, +}; + +// Westend declaration +decl_test_relay_chains! { + #[api_version(9)] + pub struct Westend { + genesis = genesis::genesis(), + on_init = (), + runtime = westend_runtime, + core = { + SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, + }, + pallets = { + XcmPallet: westend_runtime::XcmPallet, + Sudo: westend_runtime::Sudo, + Balances: westend_runtime::Balances, + Treasury: westend_runtime::Treasury, + AssetRate: westend_runtime::AssetRate, + Hrmp: westend_runtime::Hrmp, + } + }, +} + +// Westend implementation +impl_accounts_helpers_for_relay_chain!(Westend); +impl_assert_events_helpers_for_relay_chain!(Westend); +impl_hrmp_channels_helpers_for_relay_chain!(Westend); +impl_send_transact_helpers_for_relay_chain!(Westend); diff --git a/integration-tests/emulated/common/Cargo.toml b/integration-tests/emulated/common/Cargo.toml new file mode 100644 index 0000000000..f187070f7a --- /dev/null +++ b/integration-tests/emulated/common/Cargo.toml @@ -0,0 +1,76 @@ +[package] +name = "emulated-integration-tests-common" +version = "1.0.0" +authors.workspace = true +edition.workspace = true +license = "Apache-2.0" +description = "Common resources for integration testing with xcm-emulator" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } +paste = "1.0.14" +serde_json = "1.0.108" + +# Substrate +grandpa-primitives = { package = "sp-consensus-grandpa", default-features = false, version = "10.0.0" } +sp-authority-discovery = { default-features = false, version = "23.0.0" } +sp-runtime = { default-features = false, version = "28.0.0" } +frame-support = { default-features = false, version = "25.0.0" } +sp-core = { default-features = false, version = "25.0.0" } +sp-consensus-babe = { default-features = false, version = "0.29.0" } +pallet-assets = { default-features = false, version = "26.0.0" } +pallet-balances = { default-features = false, version = "25.0.0" } +pallet-message-queue = { default-features = false, version = "28.0.0" } +pallet-im-online = { default-features = false, version = "24.0.0" } +pallet-staking = { default-features = false , version = "25.0.0" } +beefy-primitives = { package = "sp-consensus-beefy", default-features = false, version = "10.0.0" } + +# Polkadot +polkadot-service = { default-features = false, features = ["full-node"], version = "4.0.0" } +polkadot-primitives = { default-features = false, version = "4.0.0" } +polkadot-runtime-parachains = { default-features = false, version = "4.0.0" } +xcm = { package = "staging-xcm", default-features = false, version = "4.0.0" } +pallet-xcm = { default-features = false, version = "4.0.0" } +polkadot-core-primitives = { default-features = false, version = "4.0.0" } +polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } + +# Cumulus +parachains-common = { default-features = false, version = "4.0.0" } +cumulus-primitives-core = { default-features = false, version = "0.4.0" } +xcm-emulator = { default-features = false, version = "0.2.0" } +cumulus-pallet-xcmp-queue = { default-features = false, version = "0.4.0" } +cumulus-pallet-parachain-system = { default-features = false, features = ["parameterized-consensus-hook",] , version = "0.4.0" } +asset-test-utils = { version = "4.0.0" } +cumulus-pallet-dmp-queue = { default-features = false , version = "0.4.0" } +penpal-runtime = { default-features = false, version = "0.11.0" } + +# Local runtimes +kusama-runtime = { package = "staging-kusama-runtime", path = "../../../relay/kusama", default-features = false } +kusama-runtime-constants = { path = "../../../relay/kusama/constants", default-features = false } +polkadot-runtime = { path = "../../../relay/polkadot", default-features = false } +polkadot-runtime-constants = { path = "../../../relay/polkadot/constants", default-features = false } +#asset-hub-polkadot-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-polkadot", default-features = false } +#asset-hub-kusama-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-kusama", default-features = false } +#collectives-polkadot-runtime = { path = "../../../system-parachains/collectives/collectives-polkadot", default-features = false } +#bridge-hub-kusama-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-kusama", default-features = false } +#bridge-hub-polkadot-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-polkadot", default-features = false } + +# Bridges +bp-messages = { version = "0.4.0" } +pallet-bridge-messages = { version = "0.4.0" } +bridge-runtime-common = { version = "0.4.0" } + +[features] +default = [ "std" ] + +std = [ + "sp-core/std", + "bp-messages/std", + "pallet-bridge-messages/std", + "bridge-runtime-common/std", + "penpal-runtime/std", + "kusama-runtime/std", + "kusama-runtime-constants/std", + "polkadot-runtime/std", + "polkadot-runtime-constants/std", +] diff --git a/integration-tests/emulated/common/src/constants.rs b/integration-tests/emulated/common/src/constants.rs new file mode 100644 index 0000000000..f8c79a7921 --- /dev/null +++ b/integration-tests/emulated/common/src/constants.rs @@ -0,0 +1,768 @@ +// 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. + +// Substrate +use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; +use grandpa_primitives::AuthorityId as GrandpaId; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_core::{sr25519, storage::Storage, Pair, Public}; +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + BuildStorage, MultiSignature, Perbill, +}; + +// Cumulus +use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; +use polkadot_parachain_primitives::primitives::{HeadData, ValidationCode}; +use polkadot_primitives::{AssignmentId, ValidatorId}; +use polkadot_runtime_parachains::{ + configuration::HostConfiguration, + paras::{ParaGenesisArgs, ParaKind}, +}; +use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy; +use xcm; + +pub const XCM_V2: u32 = 3; +pub const XCM_V3: u32 = 2; +pub const REF_TIME_THRESHOLD: u64 = 33; +pub const PROOF_SIZE_THRESHOLD: u64 = 33; + +type AccountPublic = ::Signer; + +/// Helper function to generate a crypto pair from seed +fn get_from_seed(seed: &str) -> ::Public { + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() +} + +/// Helper function to generate an account ID from seed. +fn get_account_id_from_seed(seed: &str) -> AccountId +where + AccountPublic: From<::Public>, +{ + AccountPublic::from(get_from_seed::(seed)).into_account() +} + +pub mod accounts { + use super::*; + pub const ALICE: &str = "Alice"; + pub const BOB: &str = "Bob"; + pub const CHARLIE: &str = "Charlie"; + pub const DAVE: &str = "Dave"; + pub const EVE: &str = "Eve"; + pub const FERDIE: &str = "Ferdei"; + pub const ALICE_STASH: &str = "Alice//stash"; + pub const BOB_STASH: &str = "Bob//stash"; + pub const CHARLIE_STASH: &str = "Charlie//stash"; + pub const DAVE_STASH: &str = "Dave//stash"; + pub const EVE_STASH: &str = "Eve//stash"; + pub const FERDIE_STASH: &str = "Ferdie//stash"; + pub const FERDIE_BEEFY: &str = "Ferdie//stash"; + + pub fn init_balances() -> Vec { + vec![ + get_account_id_from_seed::(ALICE), + get_account_id_from_seed::(BOB), + get_account_id_from_seed::(CHARLIE), + get_account_id_from_seed::(DAVE), + get_account_id_from_seed::(EVE), + get_account_id_from_seed::(FERDIE), + get_account_id_from_seed::(ALICE_STASH), + get_account_id_from_seed::(BOB_STASH), + get_account_id_from_seed::(CHARLIE_STASH), + get_account_id_from_seed::(DAVE_STASH), + get_account_id_from_seed::(EVE_STASH), + get_account_id_from_seed::(FERDIE_STASH), + ] + } +} + +pub mod collators { + use super::*; + + // pub fn invulnerables_asset_hub_polkadot() -> Vec<(AccountId, AssetHubPolkadotAuraId)> { + // vec![ + // ( + // get_account_id_from_seed::("Alice"), + // get_from_seed::("Alice"), + // ), + // ( + // get_account_id_from_seed::("Bob"), + // get_from_seed::("Bob"), + // ), + // ] + // } + + pub fn invulnerables() -> Vec<(AccountId, AuraId)> { + vec![ + ( + get_account_id_from_seed::("Alice"), + get_from_seed::("Alice"), + ), + (get_account_id_from_seed::("Bob"), get_from_seed::("Bob")), + ] + } +} + +pub mod validators { + use super::*; + + pub fn initial_authorities() -> Vec<( + AccountId, + AccountId, + BabeId, + GrandpaId, + ImOnlineId, + ValidatorId, + AssignmentId, + AuthorityDiscoveryId, + )> { + vec![get_authority_keys_from_seed_no_beefy("Alice")] + } +} + +/// The default XCM version to set in genesis config. +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; + +// Polkadot +pub mod polkadot { + use super::*; + pub const ED: Balance = polkadot_runtime_constants::currency::EXISTENTIAL_DEPOSIT; + const STASH: u128 = 100 * polkadot_runtime_constants::currency::UNITS; + + pub fn get_host_config() -> HostConfiguration { + HostConfiguration { + max_upward_queue_count: 10, + max_upward_queue_size: 51200, + max_upward_message_size: 51200, + max_upward_message_num_per_candidate: 10, + max_downward_message_size: 51200, + hrmp_sender_deposit: 100_000_000_000, + hrmp_recipient_deposit: 100_000_000_000, + hrmp_channel_max_capacity: 1000, + hrmp_channel_max_message_size: 102400, + hrmp_channel_max_total_size: 102400, + hrmp_max_parachain_outbound_channels: 30, + hrmp_max_parachain_inbound_channels: 30, + ..Default::default() + } + } + + fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + ) -> polkadot_runtime::SessionKeys { + polkadot_runtime::SessionKeys { + babe, + grandpa, + im_online, + para_validator, + para_assignment, + authority_discovery, + } + } + + pub fn genesis() -> Storage { + let genesis_config = polkadot_runtime::RuntimeGenesisConfig { + system: polkadot_runtime::SystemConfig { + code: polkadot_runtime::WASM_BINARY.unwrap().to_vec(), + ..Default::default() + }, + balances: polkadot_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + session: polkadot_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + polkadot::session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + x.7.clone(), + ), + ) + }) + .collect::>(), + }, + staking: polkadot_runtime::StakingConfig { + validator_count: validators::initial_authorities().len() as u32, + minimum_validator_count: 1, + stakers: validators::initial_authorities() + .iter() + .map(|x| { + (x.0.clone(), x.1.clone(), STASH, polkadot_runtime::StakerStatus::Validator) + }) + .collect(), + invulnerables: validators::initial_authorities() + .iter() + .map(|x| x.0.clone()) + .collect(), + force_era: pallet_staking::Forcing::ForceNone, + slash_reward_fraction: Perbill::from_percent(10), + ..Default::default() + }, + babe: polkadot_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(polkadot_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() + }, + configuration: polkadot_runtime::ConfigurationConfig { config: get_host_config() }, + paras: polkadot_runtime::ParasConfig { + paras: vec![ + // ( + // asset_hub_polkadot::PARA_ID.into(), + // ParaGenesisArgs { + // genesis_head: HeadData::default(), + // validation_code: ValidationCode( + // asset_hub_polkadot_runtime::WASM_BINARY.unwrap().to_vec(), + // ), + // para_kind: ParaKind::Parachain, + // }, + // ), + ( + penpal::PARA_ID_A.into(), + ParaGenesisArgs { + genesis_head: HeadData::default(), + validation_code: ValidationCode( + penpal_runtime::WASM_BINARY.unwrap().to_vec(), + ), + para_kind: ParaKind::Parachain, + }, + ), + ( + penpal::PARA_ID_B.into(), + ParaGenesisArgs { + genesis_head: HeadData::default(), + validation_code: ValidationCode( + penpal_runtime::WASM_BINARY.unwrap().to_vec(), + ), + para_kind: ParaKind::Parachain, + }, + ), + ], + ..Default::default() + }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} + +// Kusama +pub mod kusama { + use super::*; + pub const ED: Balance = kusama_runtime_constants::currency::EXISTENTIAL_DEPOSIT; + use kusama_runtime_constants::currency::UNITS as KSM; + const ENDOWMENT: u128 = 1_000_000 * KSM; + const STASH: u128 = 100 * KSM; + + pub fn get_host_config() -> HostConfiguration { + HostConfiguration { + max_upward_queue_count: 10, + max_upward_queue_size: 51200, + max_upward_message_size: 51200, + max_upward_message_num_per_candidate: 10, + max_downward_message_size: 51200, + hrmp_sender_deposit: 5_000_000_000_000, + hrmp_recipient_deposit: 5_000_000_000_000, + hrmp_channel_max_capacity: 1000, + hrmp_channel_max_message_size: 102400, + hrmp_channel_max_total_size: 102400, + hrmp_max_parachain_outbound_channels: 30, + hrmp_max_parachain_inbound_channels: 30, + ..Default::default() + } + } + + fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + beefy: BeefyId, + ) -> kusama_runtime::SessionKeys { + kusama_runtime::SessionKeys { + babe, + grandpa, + im_online, + para_validator, + para_assignment, + authority_discovery, + beefy, + } + } + + pub fn genesis() -> Storage { + let genesis_config = kusama_runtime::RuntimeGenesisConfig { + system: kusama_runtime::SystemConfig { + code: kusama_runtime::WASM_BINARY.unwrap().to_vec(), + ..Default::default() + }, + balances: kusama_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .map(|k: &AccountId| (k.clone(), ENDOWMENT)) + .collect(), + }, + session: kusama_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + kusama::session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + x.7.clone(), + get_from_seed::("Alice"), + ), + ) + }) + .collect::>(), + }, + staking: kusama_runtime::StakingConfig { + validator_count: validators::initial_authorities().len() as u32, + minimum_validator_count: 1, + stakers: validators::initial_authorities() + .iter() + .map(|x| { + (x.0.clone(), x.1.clone(), STASH, kusama_runtime::StakerStatus::Validator) + }) + .collect(), + invulnerables: validators::initial_authorities() + .iter() + .map(|x| x.0.clone()) + .collect(), + force_era: pallet_staking::Forcing::NotForcing, + slash_reward_fraction: Perbill::from_percent(10), + ..Default::default() + }, + babe: kusama_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(kusama_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() + }, + configuration: kusama_runtime::ConfigurationConfig { config: get_host_config() }, + paras: kusama_runtime::ParasConfig { + paras: vec![ + // ( + // asset_hub_kusama::PARA_ID.into(), + // ParaGenesisArgs { + // genesis_head: HeadData::default(), + // validation_code: ValidationCode( + // asset_hub_kusama_runtime::WASM_BINARY.unwrap().to_vec(), + // ), + // para_kind: ParaKind::Parachain, + // }, + // ), + ( + penpal::PARA_ID_A.into(), + ParaGenesisArgs { + genesis_head: HeadData::default(), + validation_code: ValidationCode( + penpal_runtime::WASM_BINARY.unwrap().to_vec(), + ), + para_kind: ParaKind::Parachain, + }, + ), + ( + penpal::PARA_ID_B.into(), + ParaGenesisArgs { + genesis_head: HeadData::default(), + validation_code: ValidationCode( + penpal_runtime::WASM_BINARY.unwrap().to_vec(), + ), + para_kind: ParaKind::Parachain, + }, + ), + ], + ..Default::default() + }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} + +// Asset Hub Polkadot +// pub mod asset_hub_polkadot { +// use super::*; +// pub const PARA_ID: u32 = 1000; +// pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; +// +// pub fn genesis() -> Storage { +// let genesis_config = asset_hub_polkadot_runtime::RuntimeGenesisConfig { +// system: asset_hub_polkadot_runtime::SystemConfig { +// code: asset_hub_polkadot_runtime::WASM_BINARY +// .expect("WASM binary was not build, please build it!") +// .to_vec(), +// ..Default::default() +// }, +// balances: asset_hub_polkadot_runtime::BalancesConfig { +// balances: accounts::init_balances() +// .iter() +// .cloned() +// .map(|k| (k, ED * 4096)) +// .collect(), +// }, +// parachain_info: asset_hub_polkadot_runtime::ParachainInfoConfig { +// parachain_id: PARA_ID.into(), +// ..Default::default() +// }, +// collator_selection: asset_hub_polkadot_runtime::CollatorSelectionConfig { +// invulnerables: collators::invulnerables_asset_hub_polkadot() +// .iter() +// .cloned() +// .map(|(acc, _)| acc) +// .collect(), +// candidacy_bond: ED * 16, +// ..Default::default() +// }, +// session: asset_hub_polkadot_runtime::SessionConfig { +// keys: collators::invulnerables_asset_hub_polkadot() +// .into_iter() +// .map(|(acc, aura)| { +// ( +// acc.clone(), // account id +// acc, // validator id +// asset_hub_polkadot_runtime::SessionKeys { aura }, // session keys +// ) +// }) +// .collect(), +// }, +// polkadot_xcm: asset_hub_polkadot_runtime::PolkadotXcmConfig { +// safe_xcm_version: Some(SAFE_XCM_VERSION), +// ..Default::default() +// }, +// ..Default::default() +// }; +// +// genesis_config.build_storage().unwrap() +// } +// } + +// Asset Hub Kusama +// pub mod asset_hub_kusama { +// use super::*; +// pub const PARA_ID: u32 = 1000; +// pub const ED: Balance = parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT; +// +// pub fn genesis() -> Storage { +// let genesis_config = asset_hub_kusama_runtime::RuntimeGenesisConfig { +// system: asset_hub_kusama_runtime::SystemConfig { +// code: asset_hub_kusama_runtime::WASM_BINARY +// .expect("WASM binary was not build, please build it!") +// .to_vec(), +// ..Default::default() +// }, +// balances: asset_hub_kusama_runtime::BalancesConfig { +// balances: accounts::init_balances() +// .iter() +// .cloned() +// .map(|k| (k, ED * 4096)) +// .collect(), +// }, +// parachain_info: asset_hub_kusama_runtime::ParachainInfoConfig { +// parachain_id: PARA_ID.into(), +// ..Default::default() +// }, +// collator_selection: asset_hub_kusama_runtime::CollatorSelectionConfig { +// invulnerables: collators::invulnerables() +// .iter() +// .cloned() +// .map(|(acc, _)| acc) +// .collect(), +// candidacy_bond: ED * 16, +// ..Default::default() +// }, +// session: asset_hub_kusama_runtime::SessionConfig { +// keys: collators::invulnerables() +// .into_iter() +// .map(|(acc, aura)| { +// ( +// acc.clone(), // account id +// acc, // validator id +// asset_hub_kusama_runtime::SessionKeys { aura }, // session keys +// ) +// }) +// .collect(), +// }, +// polkadot_xcm: asset_hub_kusama_runtime::PolkadotXcmConfig { +// safe_xcm_version: Some(SAFE_XCM_VERSION), +// ..Default::default() +// }, +// ..Default::default() +// }; +// +// genesis_config.build_storage().unwrap() +// } +// } +// +// // Bridge Hub Polkadot +// pub mod bridge_hub_polkadot { +// use super::*; +// pub const PARA_ID: u32 = 1002; +// pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; +// +// pub fn genesis() -> Storage { +// let genesis_config = bridge_hub_polkadot_runtime::RuntimeGenesisConfig { +// system: bridge_hub_polkadot_runtime::SystemConfig { +// code: bridge_hub_polkadot_runtime::WASM_BINARY +// .expect("WASM binary was not build, please build it!") +// .to_vec(), +// ..Default::default() +// }, +// balances: bridge_hub_polkadot_runtime::BalancesConfig { +// balances: accounts::init_balances() +// .iter() +// .cloned() +// .map(|k| (k, ED * 4096)) +// .collect(), +// }, +// parachain_info: bridge_hub_polkadot_runtime::ParachainInfoConfig { +// parachain_id: PARA_ID.into(), +// ..Default::default() +// }, +// collator_selection: bridge_hub_polkadot_runtime::CollatorSelectionConfig { +// invulnerables: collators::invulnerables() +// .iter() +// .cloned() +// .map(|(acc, _)| acc) +// .collect(), +// candidacy_bond: ED * 16, +// ..Default::default() +// }, +// session: bridge_hub_polkadot_runtime::SessionConfig { +// keys: collators::invulnerables() +// .into_iter() +// .map(|(acc, aura)| { +// ( +// acc.clone(), // account id +// acc, // validator id +// bridge_hub_polkadot_runtime::SessionKeys { aura }, // session keys +// ) +// }) +// .collect(), +// }, +// polkadot_xcm: bridge_hub_polkadot_runtime::PolkadotXcmConfig { +// safe_xcm_version: Some(SAFE_XCM_VERSION), +// ..Default::default() +// }, +// ..Default::default() +// }; +// +// genesis_config.build_storage().unwrap() +// } +// } +// +// // Bridge Hub Kusama +// pub mod bridge_hub_kusama { +// use super::*; +// pub const PARA_ID: u32 = 1002; +// pub const ED: Balance = parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT; +// +// pub fn genesis() -> Storage { +// let genesis_config = bridge_hub_kusama_runtime::RuntimeGenesisConfig { +// system: bridge_hub_kusama_runtime::SystemConfig { +// code: bridge_hub_kusama_runtime::WASM_BINARY +// .expect("WASM binary was not build, please build it!") +// .to_vec(), +// ..Default::default() +// }, +// balances: bridge_hub_kusama_runtime::BalancesConfig { +// balances: accounts::init_balances() +// .iter() +// .cloned() +// .map(|k| (k, ED * 4096)) +// .collect(), +// }, +// parachain_info: bridge_hub_kusama_runtime::ParachainInfoConfig { +// parachain_id: PARA_ID.into(), +// ..Default::default() +// }, +// collator_selection: bridge_hub_kusama_runtime::CollatorSelectionConfig { +// invulnerables: collators::invulnerables() +// .iter() +// .cloned() +// .map(|(acc, _)| acc) +// .collect(), +// candidacy_bond: ED * 16, +// ..Default::default() +// }, +// session: bridge_hub_kusama_runtime::SessionConfig { +// keys: collators::invulnerables() +// .into_iter() +// .map(|(acc, aura)| { +// ( +// acc.clone(), // account id +// acc, // validator id +// bridge_hub_kusama_runtime::SessionKeys { aura }, // session keys +// ) +// }) +// .collect(), +// }, +// polkadot_xcm: bridge_hub_kusama_runtime::PolkadotXcmConfig { +// safe_xcm_version: Some(SAFE_XCM_VERSION), +// ..Default::default() +// }, +// ..Default::default() +// }; +// +// genesis_config.build_storage().unwrap() +// } +// } + +// Collectives +// pub mod collectives { +// use super::*; +// pub const PARA_ID: u32 = 1001; +// pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; +// +// pub fn genesis() -> Storage { +// let genesis_config = collectives_polkadot_runtime::RuntimeGenesisConfig { +// system: collectives_polkadot_runtime::SystemConfig { +// code: collectives_polkadot_runtime::WASM_BINARY +// .expect("WASM binary was not build, please build it!") +// .to_vec(), +// ..Default::default() +// }, +// balances: collectives_polkadot_runtime::BalancesConfig { +// balances: accounts::init_balances() +// .iter() +// .cloned() +// .map(|k| (k, ED * 4096)) +// .collect(), +// }, +// parachain_info: collectives_polkadot_runtime::ParachainInfoConfig { +// parachain_id: PARA_ID.into(), +// ..Default::default() +// }, +// collator_selection: collectives_polkadot_runtime::CollatorSelectionConfig { +// invulnerables: collators::invulnerables() +// .iter() +// .cloned() +// .map(|(acc, _)| acc) +// .collect(), +// candidacy_bond: ED * 16, +// ..Default::default() +// }, +// session: collectives_polkadot_runtime::SessionConfig { +// keys: collators::invulnerables() +// .into_iter() +// .map(|(acc, aura)| { +// ( +// acc.clone(), // account id +// acc, // validator id +// collectives_polkadot_runtime::SessionKeys { aura }, // session keys +// ) +// }) +// .collect(), +// }, +// polkadot_xcm: collectives_polkadot_runtime::PolkadotXcmConfig { +// safe_xcm_version: Some(SAFE_XCM_VERSION), +// ..Default::default() +// }, +// ..Default::default() +// }; +// +// genesis_config.build_storage().unwrap() +// } +// } + +// Penpal +pub mod penpal { + use super::*; + pub const PARA_ID_A: u32 = 2000; + pub const PARA_ID_B: u32 = 2001; + pub const ED: Balance = penpal_runtime::EXISTENTIAL_DEPOSIT; + + pub fn genesis(para_id: u32) -> Storage { + let genesis_config = penpal_runtime::RuntimeGenesisConfig { + system: penpal_runtime::SystemConfig { + code: penpal_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + ..Default::default() + }, + balances: penpal_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: penpal_runtime::ParachainInfoConfig { + parachain_id: para_id.into(), + ..Default::default() + }, + collator_selection: penpal_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: penpal_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + penpal_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: penpal_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + sudo: penpal_runtime::SudoConfig { + key: Some(get_account_id_from_seed::("Alice")), + }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} diff --git a/integration-tests/emulated/common/src/impls.rs b/integration-tests/emulated/common/src/impls.rs new file mode 100644 index 0000000000..0a8acb8e7c --- /dev/null +++ b/integration-tests/emulated/common/src/impls.rs @@ -0,0 +1,645 @@ +// 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. + +pub use codec::{Decode, Encode}; +pub use paste; + +pub use crate::{ + constants::{PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD}, + xcm_helpers::xcm_transact_unpaid_execution, +}; + +// Substrate +pub use frame_support::{assert_ok, traits::fungibles::Inspect}; +pub use pallet_assets; +pub use pallet_message_queue; +use sp_core::Get; + +// Cumulus +use bp_messages::{ + target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, + LaneId, MessageKey, OutboundLaneData, +}; +use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; +pub use cumulus_pallet_dmp_queue; +pub use cumulus_pallet_parachain_system; +pub use cumulus_pallet_xcmp_queue; +pub use cumulus_primitives_core::{ + relay_chain::HrmpChannelId, DmpMessageHandler, ParaId, XcmpMessageHandler, +}; +use pallet_bridge_messages::{Config, Instance1, OutboundLanes, Pallet}; +pub use parachains_common::{AccountId, Balance}; +pub use xcm_emulator::{ + assert_expected_events, bx, helpers::weight_within_threshold, BridgeMessage, + BridgeMessageDispatchError, BridgeMessageHandler, Chain, Parachain, RelayChain, TestExt, +}; + +// Polkadot +pub use pallet_xcm; +pub use polkadot_runtime_parachains::{ + dmp, hrmp, + inclusion::{AggregateMessageOrigin, UmpQueueId}, +}; +pub use xcm::{ + prelude::{OriginKind, Outcome, VersionedXcm, Weight}, + v3::Error, + DoubleEncoded, +}; + +pub struct BridgeHubMessageHandler { + _marker: std::marker::PhantomData<(S, T, I)>, +} + +struct LaneIdWrapper(LaneId); + +impl From for u32 { + fn from(lane_id: LaneIdWrapper) -> u32 { + u32::from_be_bytes(lane_id.0 .0) + } +} + +impl From for LaneIdWrapper { + fn from(id: u32) -> LaneIdWrapper { + LaneIdWrapper(LaneId(id.to_be_bytes())) + } +} + +// TODO: uncomment when https://github.com/polkadot-fellows/runtimes/pull/108 is merged +// type BridgeHubPolkadotRuntime = ::Runtime; +// type BridgeHubKusamaRuntime = ::Runtime; + +// TODO: uncomment when https://github.com/polkadot-fellows/runtimes/pull/108 is merged +// pub type PolkadotKusamaMessageHandler +// = BridgeHubMessageHandler; +// pub type KusamaPolkadotMessageHandler +// = BridgeHubMessageHandler; + +impl BridgeMessageHandler for BridgeHubMessageHandler +where + S: Config, + T: Config, + I: 'static, + >::InboundPayload: From>, + >::MessageDispatch: + MessageDispatch, +{ + fn get_source_outbound_messages() -> Vec { + // get the source active outbound lanes + let active_lanes = S::ActiveOutboundLanes::get(); + + let mut messages: Vec = Default::default(); + + // collect messages from `OutboundMessages` for each active outbound lane in the source + for lane in active_lanes { + let latest_generated_nonce = + OutboundLanes::::get(lane).latest_generated_nonce; + let latest_received_nonce = + OutboundLanes::::get(lane).latest_received_nonce; + + (latest_received_nonce + 1..=latest_generated_nonce).for_each(|nonce| { + let encoded_payload: Vec = + Pallet::::outbound_message_data(*lane, nonce) + .expect("Bridge message does not exist") + .into(); + let payload = Vec::::decode(&mut &encoded_payload[..]) + .expect("Decodign XCM message failed"); + let id: u32 = LaneIdWrapper(*lane).into(); + let message = BridgeMessage { id, nonce, payload }; + + messages.push(message); + }); + } + messages + } + + fn dispatch_target_inbound_message( + message: BridgeMessage, + ) -> Result<(), BridgeMessageDispatchError> { + type TargetMessageDispatch = >::MessageDispatch; + type InboundPayload = >::InboundPayload; + + let lane_id = LaneIdWrapper::from(message.id).0; + let nonce = message.nonce; + let payload = Ok(From::from(message.payload)); + + // Directly dispatch outbound messages assuming everything is correct + // and bypassing the `Relayers` and `InboundLane` logic + let dispatch_result = TargetMessageDispatch::::dispatch(DispatchMessage { + key: MessageKey { lane_id, nonce }, + data: DispatchMessageData::> { payload }, + }); + + let result = match dispatch_result.dispatch_level_result { + XcmBlobMessageDispatchResult::Dispatched => Ok(()), + XcmBlobMessageDispatchResult::InvalidPayload => Err(BridgeMessageDispatchError( + Box::new(XcmBlobMessageDispatchResult::InvalidPayload), + )), + XcmBlobMessageDispatchResult::NotDispatched(e) => Err(BridgeMessageDispatchError( + Box::new(XcmBlobMessageDispatchResult::NotDispatched(e)), + )), + }; + result + } + + fn notify_source_message_delivery(lane_id: u32) { + let data = OutboundLanes::::get(LaneIdWrapper::from(lane_id).0); + let new_data = OutboundLaneData { + oldest_unpruned_nonce: data.oldest_unpruned_nonce + 1, + latest_received_nonce: data.latest_received_nonce + 1, + ..data + }; + + OutboundLanes::::insert(LaneIdWrapper::from(lane_id).0, new_data); + } +} + +#[macro_export] +macro_rules! impl_accounts_helpers_for_relay_chain { + ( $chain:ident ) => { + $crate::impls::paste::paste! { + impl $chain { + /// Fund a set of accounts with a balance + pub fn fund_accounts(accounts: Vec<($crate::impls::AccountId, $crate::impls::Balance)>) { + ::execute_with(|| { + for account in accounts { + $crate::impls::assert_ok!(]>::Balances::force_set_balance( + ::RuntimeOrigin::root(), + account.0.into(), + account.1, + )); + } + }); + } + /// Fund a sovereign account based on its Parachain Id + pub fn fund_para_sovereign(amount: $crate::impls::Balance, para_id: $crate::impls::ParaId) -> sp_runtime::AccountId32 { + let sovereign_account = ::sovereign_account_id_of_child_para(para_id); + Self::fund_accounts(vec![(sovereign_account.clone(), amount)]); + sovereign_account + } + } + } + }; +} + +#[macro_export] +macro_rules! impl_assert_events_helpers_for_relay_chain { + ( $chain:ident ) => { + $crate::impls::paste::paste! { + type [<$chain RuntimeEvent>] = <$chain as $crate::impls::Chain>::RuntimeEvent; + + impl $chain { + /// Asserts a dispatchable is completely executed and XCM sent + pub fn assert_xcm_pallet_attempted_complete(expected_weight: Option<$crate::impls::Weight>) { + $crate::impls::assert_expected_events!( + Self, + vec![ + [<$chain RuntimeEvent>]::XcmPallet( + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } + ) => { + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), + expected_weight.unwrap_or(*weight), + *weight + ), + }, + ] + ); + } + + /// Asserts a dispatchable is incompletely executed and XCM sent + pub fn assert_xcm_pallet_attempted_incomplete( + expected_weight: Option<$crate::impls::Weight>, + expected_error: Option<$crate::impls::Error>, + ) { + $crate::impls::assert_expected_events!( + Self, + vec![ + // Dispatchable is properly executed and XCM message sent + [<$chain RuntimeEvent>]::XcmPallet( + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } + ) => { + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), + expected_weight.unwrap_or(*weight), + *weight + ), + error: *error == expected_error.unwrap_or(*error), + }, + ] + ); + } + + /// Asserts a XCM message is sent + pub fn assert_xcm_pallet_sent() { + $crate::impls::assert_expected_events!( + Self, + vec![ + [<$chain RuntimeEvent>]::XcmPallet($crate::impls::pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + } + + /// Asserts a XCM from System Parachain is succesfully received and proccessed + pub fn assert_ump_queue_processed( + expected_success: bool, + expected_id: Option<$crate::impls::ParaId>, + expected_weight: Option<$crate::impls::Weight>, + ) { + $crate::impls::assert_expected_events!( + Self, + vec![ + // XCM is succesfully received and proccessed + [<$chain RuntimeEvent>]::MessageQueue($crate::impls::pallet_message_queue::Event::Processed { + origin: $crate::impls::AggregateMessageOrigin::Ump($crate::impls::UmpQueueId::Para(id)), + weight_used, + success, + .. + }) => { + id: *id == expected_id.unwrap_or(*id), + weight_used: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), + expected_weight.unwrap_or(*weight_used), + *weight_used + ), + success: *success == expected_success, + }, + ] + ); + } + } + } + }; +} + +#[macro_export] +macro_rules! impl_hrmp_channels_helpers_for_relay_chain { + ( $chain:ident ) => { + $crate::impls::paste::paste! { + impl $chain { + /// Init open channel request with another Parachain + pub fn init_open_channel_call( + recipient_para_id: $crate::impls::ParaId, + max_capacity: u32, + max_message_size: u32, + ) -> $crate::impls::DoubleEncoded<()> { + use $crate::impls::Encode; + + ::RuntimeCall::Hrmp($crate::impls::hrmp::Call::< + ::Runtime, + >::hrmp_init_open_channel { + recipient: recipient_para_id, + proposed_max_capacity: max_capacity, + proposed_max_message_size: max_message_size, + }) + .encode() + .into() + } + /// Recipient Parachain accept the open request from another Parachain + pub fn accept_open_channel_call(sender_para_id: $crate::impls::ParaId) -> $crate::impls::DoubleEncoded<()> { + use $crate::impls::Encode; + + ::RuntimeCall::Hrmp($crate::impls::hrmp::Call::< + ::Runtime, + >::hrmp_accept_open_channel { + sender: sender_para_id, + }) + .encode() + .into() + } + + /// A root origin force to open a channel between two Parachains + pub fn force_process_hrmp_open(sender: $crate::impls::ParaId, recipient: $crate::impls::ParaId) { + use $crate::impls::Chain; + + ::execute_with(|| { + let relay_root_origin = ::RuntimeOrigin::root(); + + // Force process HRMP open channel requests without waiting for the next session + $crate::impls::assert_ok!(]>::Hrmp::force_process_hrmp_open( + relay_root_origin, + 0 + )); + + let channel_id = $crate::impls::HrmpChannelId { sender, recipient }; + + let hrmp_channel_exist = $crate::impls::hrmp::HrmpChannels::< + ::Runtime, + >::contains_key(&channel_id); + + // Check the HRMP channel has been successfully registrered + assert!(hrmp_channel_exist) + }); + } + } + } + }; +} + +#[macro_export] +macro_rules! impl_accounts_helpers_for_parachain { + ( $chain:ident ) => { + $crate::impls::paste::paste! { + impl $chain { + /// Fund a set of accounts with a balance + pub fn fund_accounts(accounts: Vec<($crate::impls::AccountId, $crate::impls::Balance)>) { + ::execute_with(|| { + for account in accounts { + $crate::impls::assert_ok!(]>::Balances::force_set_balance( + ::RuntimeOrigin::root(), + account.0.into(), + account.1, + )); + } + }); + } + } + } + }; +} + +#[macro_export] +macro_rules! impl_assert_events_helpers_for_parachain { + ( $chain:ident ) => { + $crate::impls::paste::paste! { + type [<$chain RuntimeEvent>] = <$chain as $crate::impls::Chain>::RuntimeEvent; + + impl $chain { + /// Asserts a dispatchable is completely executed and XCM sent + pub fn assert_xcm_pallet_attempted_complete(expected_weight: Option<$crate::impls::Weight>) { + $crate::impls::assert_expected_events!( + Self, + vec![ + [<$chain RuntimeEvent>]::PolkadotXcm( + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } + ) => { + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), + expected_weight.unwrap_or(*weight), + *weight + ), + }, + ] + ); + } + + /// Asserts a dispatchable is incompletely executed and XCM sent + pub fn assert_xcm_pallet_attempted_incomplete( + expected_weight: Option<$crate::impls::Weight>, + expected_error: Option<$crate::impls::Error>, + ) { + $crate::impls::assert_expected_events!( + Self, + vec![ + // Dispatchable is properly executed and XCM message sent + [<$chain RuntimeEvent>]::PolkadotXcm( + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } + ) => { + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), + expected_weight.unwrap_or(*weight), + *weight + ), + error: *error == expected_error.unwrap_or(*error), + }, + ] + ); + } + + /// Asserts a dispatchable throws and error when trying to be sent + pub fn assert_xcm_pallet_attempted_error(expected_error: Option<$crate::impls::Error>) { + $crate::impls::assert_expected_events!( + Self, + vec![ + // Execution fails in the origin with `Barrier` + [<$chain RuntimeEvent>]::PolkadotXcm( + $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Error(error) } + ) => { + error: *error == expected_error.unwrap_or(*error), + }, + ] + ); + } + + /// Asserts a XCM message is sent + pub fn assert_xcm_pallet_sent() { + $crate::impls::assert_expected_events!( + Self, + vec![ + [<$chain RuntimeEvent>]::PolkadotXcm($crate::impls::pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + } + + /// Asserts a XCM message is sent to Relay Chain + pub fn assert_parachain_system_ump_sent() { + $crate::impls::assert_expected_events!( + Self, + vec![ + [<$chain RuntimeEvent>]::ParachainSystem( + $crate::impls::cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. } + ) => {}, + ] + ); + } + + /// Asserts a XCM from Relay Chain is completely executed + pub fn assert_dmp_queue_complete(expected_weight: Option<$crate::impls::Weight>) { + $crate::impls::assert_expected_events!( + Self, + vec![ + [<$chain RuntimeEvent>]::DmpQueue($crate::impls::cumulus_pallet_dmp_queue::Event::ExecutedDownward { + outcome: $crate::impls::Outcome::Complete(weight), .. + }) => { + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), + expected_weight.unwrap_or(*weight), + *weight + ), + }, + ] + ); + } + + /// Asserts a XCM from Relay Chain is incompletely executed + pub fn assert_dmp_queue_incomplete( + expected_weight: Option<$crate::impls::Weight>, + expected_error: Option<$crate::impls::Error>, + ) { + $crate::impls::assert_expected_events!( + Self, + vec![ + [<$chain RuntimeEvent>]::DmpQueue($crate::impls::cumulus_pallet_dmp_queue::Event::ExecutedDownward { + outcome: $crate::impls::Outcome::Incomplete(weight, error), .. + }) => { + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), + expected_weight.unwrap_or(*weight), + *weight + ), + error: *error == expected_error.unwrap_or(*error), + }, + ] + ); + } + + /// Asserts a XCM from another Parachain is completely executed + pub fn assert_xcmp_queue_success(expected_weight: Option<$crate::impls::Weight>) { + $crate::impls::assert_expected_events!( + Self, + vec![ + [<$chain RuntimeEvent>]::XcmpQueue( + $crate::impls::cumulus_pallet_xcmp_queue::Event::Success { weight, .. } + ) => { + weight: $crate::impls::weight_within_threshold( + ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), + expected_weight.unwrap_or(*weight), + *weight + ), + }, + ] + ); + } + } + } + }; +} + +#[macro_export] +macro_rules! impl_assets_helpers_for_parachain { + ( $chain:ident, $relay_chain:ident ) => { + $crate::impls::paste::paste! { + impl $chain { + /// Returns the encoded call for `force_create` from the assets pallet + pub fn force_create_asset_call( + asset_id: u32, + owner: $crate::impls::AccountId, + is_sufficient: bool, + min_balance: $crate::impls::Balance, + ) -> $crate::impls::DoubleEncoded<()> { + use $crate::impls::{Chain, Encode}; + + ::RuntimeCall::Assets($crate::impls::pallet_assets::Call::< + ::Runtime, + $crate::impls::pallet_assets::Instance1, + >::force_create { + id: asset_id.into(), + owner: owner.into(), + is_sufficient, + min_balance, + }) + .encode() + .into() + } + + /// Returns a `VersionedXcm` for `force_create` from the assets pallet + pub fn force_create_asset_xcm( + origin_kind: $crate::impls::OriginKind, + asset_id: u32, + owner: $crate::impls::AccountId, + is_sufficient: bool, + min_balance: $crate::impls::Balance, + ) -> $crate::impls::VersionedXcm<()> { + let call = Self::force_create_asset_call(asset_id, owner, is_sufficient, min_balance); + $crate::impls::xcm_transact_unpaid_execution(call, origin_kind) + } + + /// Mint assets making use of the assets pallet + pub fn mint_asset( + signed_origin: ::RuntimeOrigin, + id: u32, + beneficiary: $crate::impls::AccountId, + amount_to_mint: u128, + ) { + ::execute_with(|| { + $crate::impls::assert_ok!(]>::Assets::mint( + signed_origin, + id.into(), + beneficiary.clone().into(), + amount_to_mint + )); + + type RuntimeEvent = <$chain as $crate::impls::Chain>::RuntimeEvent; + + $crate::impls::assert_expected_events!( + Self, + vec![ + RuntimeEvent::Assets($crate::impls::pallet_assets::Event::Issued { asset_id, owner, amount }) => { + asset_id: *asset_id == id, + owner: *owner == beneficiary.clone().into(), + amount: *amount == amount_to_mint, + }, + ] + ); + }); + } + + /// Force create and mint assets making use of the assets pallet + pub fn force_create_and_mint_asset( + id: u32, + min_balance: u128, + is_sufficient: bool, + asset_owner: $crate::impls::AccountId, + amount_to_mint: u128, + ) { + use $crate::impls::{bx, Chain, RelayChain, Parachain, Inspect, TestExt}; + // Init values for Relay Chain + let root_origin = <$relay_chain as Chain>::RuntimeOrigin::root(); + let destination = <$relay_chain>::child_location_of(<$chain>::para_id()); + let xcm = Self::force_create_asset_xcm( + $crate::impls::OriginKind::Superuser, + id, + asset_owner.clone(), + is_sufficient, + min_balance, + ); + + <$relay_chain>::execute_with(|| { + $crate::impls::assert_ok!(<$relay_chain as [<$relay_chain Pallet>]>::XcmPallet::send( + root_origin, + bx!(destination.into()), + bx!(xcm), + )); + + <$relay_chain>::assert_xcm_pallet_sent(); + }); + + Self::execute_with(|| { + Self::assert_dmp_queue_complete(Some($crate::impls::Weight::from_parts(1_019_445_000, 200_000))); + + type RuntimeEvent = <$chain as $crate::impls::Chain>::RuntimeEvent; + + $crate::impls::assert_expected_events!( + Self, + vec![ + // Asset has been created + RuntimeEvent::Assets($crate::impls::pallet_assets::Event::ForceCreated { asset_id, owner }) => { + asset_id: *asset_id == id, + owner: *owner == asset_owner.clone(), + }, + ] + ); + + assert!(]>::Assets::asset_exists(id.into())); + }); + + let signed_origin = ::RuntimeOrigin::signed(asset_owner.clone()); + + // Mint asset for System Parachain's sender + Self::mint_asset(signed_origin, id, asset_owner, amount_to_mint); + } + } + } + }; +} diff --git a/integration-tests/emulated/common/src/lib.rs b/integration-tests/emulated/common/src/lib.rs new file mode 100644 index 0000000000..c7bb121d34 --- /dev/null +++ b/integration-tests/emulated/common/src/lib.rs @@ -0,0 +1,327 @@ +// 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. + +pub mod constants; +pub mod impls; +pub mod xcm_helpers; + +use constants::{ + accounts::{ALICE, BOB}, + // asset_hub_kusama, asset_hub_polkadot, bridge_hub_kusama, bridge_hub_polkadot, collectives, + kusama, penpal, polkadot, +}; + +// Substrate +use frame_support::traits::OnInitialize; + +// Cumulus +use xcm_emulator::{ + // decl_test_bridges, + decl_test_networks, decl_test_parachains, decl_test_relay_chains, + decl_test_sender_receiver_accounts_parameter_types, DefaultMessageProcessor, +}; + +use polkadot_primitives::runtime_api::runtime_decl_for_parachain_host::ParachainHostV7; + +decl_test_relay_chains! { + #[api_version(5)] + pub struct Polkadot { + genesis = polkadot::genesis(), + on_init = (), + runtime = polkadot_runtime, + core = { + MessageProcessor: DefaultMessageProcessor, + SovereignAccountOf: polkadot_runtime::xcm_config::SovereignAccountOf, + }, + pallets = { + XcmPallet: polkadot_runtime::XcmPallet, + Balances: polkadot_runtime::Balances, + Hrmp: polkadot_runtime::Hrmp, + } + }, + #[api_version(5)] + pub struct Kusama { + genesis = kusama::genesis(), + on_init = (), + runtime = kusama_runtime, + core = { + MessageProcessor: DefaultMessageProcessor, + SovereignAccountOf: kusama_runtime::xcm_config::SovereignAccountOf, + }, + pallets = { + XcmPallet: kusama_runtime::XcmPallet, + Balances: kusama_runtime::Balances, + Hrmp: kusama_runtime::Hrmp, + } + }, +} + +decl_test_parachains! { + // Polkadot Parachains + // pub struct AssetHubPolkadot { + // genesis = asset_hub_polkadot::genesis(), + // on_init = { + // asset_hub_polkadot_runtime::AuraExt::on_initialize(1); + // }, + // runtime = asset_hub_polkadot_runtime, + // core = { + // XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue, + // DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue, + // LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId, + // ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo, + // }, + // pallets = { + // PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm, + // Assets: asset_hub_polkadot_runtime::Assets, + // Balances: asset_hub_polkadot_runtime::Balances, + // } + // }, + // pub struct Collectives { + // genesis = collectives::genesis(), + // on_init = { + // collectives_polkadot_runtime::AuraExt::on_initialize(1); + // }, + // runtime = collectives_polkadot_runtime, + // core = { + // XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue, + // DmpMessageHandler: collectives_polkadot_runtime::DmpQueue, + // LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId, + // ParachainInfo: collectives_polkadot_runtime::ParachainInfo, + // }, + // pallets = { + // PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm, + // Balances: collectives_polkadot_runtime::Balances, + // } + // }, + // pub struct BridgeHubPolkadot { + // genesis = bridge_hub_polkadot::genesis(), + // on_init = { + // bridge_hub_polkadot_runtime::AuraExt::on_initialize(1); + // }, + // runtime = bridge_hub_polkadot_runtime, + // core = { + // XcmpMessageHandler: bridge_hub_polkadot_runtime::XcmpQueue, + // DmpMessageHandler: bridge_hub_polkadot_runtime::DmpQueue, + // LocationToAccountId: bridge_hub_polkadot_runtime::xcm_config::LocationToAccountId, + // ParachainInfo: bridge_hub_polkadot_runtime::ParachainInfo, + // }, + // pallets = { + // PolkadotXcm: bridge_hub_polkadot_runtime::PolkadotXcm, + // } + // }, + pub struct PenpalPolkadotA { + genesis = penpal::genesis(penpal::PARA_ID_A), + on_init = { + penpal_runtime::AuraExt::on_initialize(1); + }, + runtime = penpal_runtime, + core = { + XcmpMessageHandler: penpal_runtime::XcmpQueue, + DmpMessageHandler: penpal_runtime::DmpQueue, + LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, + ParachainInfo: penpal_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, + pub struct PenpalPolkadotB { + genesis = penpal::genesis(penpal::PARA_ID_B), + on_init = { + penpal_runtime::AuraExt::on_initialize(1); + }, + runtime = penpal_runtime, + core = { + XcmpMessageHandler: penpal_runtime::XcmpQueue, + DmpMessageHandler: penpal_runtime::DmpQueue, + LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, + ParachainInfo: penpal_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, + // Kusama Parachains + // pub struct AssetHubKusama { + // genesis = asset_hub_kusama::genesis(), + // on_init = { + // asset_hub_kusama_runtime::AuraExt::on_initialize(1); + // }, + // runtime = asset_hub_kusama_runtime, + // core = { + // XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue, + // DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue, + // LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId, + // ParachainInfo: asset_hub_kusama_runtime::ParachainInfo, + // }, + // pallets = { + // PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm, + // Assets: asset_hub_kusama_runtime::Assets, + // ForeignAssets: asset_hub_kusama_runtime::ForeignAssets, + // PoolAssets: asset_hub_kusama_runtime::PoolAssets, + // AssetConversion: asset_hub_kusama_runtime::AssetConversion, + // Balances: asset_hub_kusama_runtime::Balances, + // } + // }, + // pub struct BridgeHubKusama { + // genesis = bridge_hub_kusama::genesis(), + // on_init = { + // bridge_hub_kusama_runtime::AuraExt::on_initialize(1); + // }, + // runtime = bridge_hub_kusama_runtime, + // core = { + // XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue, + // DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue, + // LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId, + // ParachainInfo: bridge_hub_kusama_runtime::ParachainInfo, + // }, + // pallets = { + // PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm, + // } + // }, + pub struct PenpalKusamaA { + genesis = penpal::genesis(penpal::PARA_ID_A), + on_init = { + penpal_runtime::AuraExt::on_initialize(1); + }, + runtime = penpal_runtime, + core = { + XcmpMessageHandler: penpal_runtime::XcmpQueue, + DmpMessageHandler: penpal_runtime::DmpQueue, + LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, + ParachainInfo: penpal_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, + pub struct PenpalKusamaB { + genesis = penpal::genesis(penpal::PARA_ID_B), + on_init = { + penpal_runtime::AuraExt::on_initialize(1); + }, + runtime = penpal_runtime, + core = { + XcmpMessageHandler: penpal_runtime::XcmpQueue, + DmpMessageHandler: penpal_runtime::DmpQueue, + LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, + ParachainInfo: penpal_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, +} + +decl_test_networks! { + pub struct PolkadotMockNet { + relay_chain = Polkadot, + parachains = vec![ + // AssetHubPolkadot, + // Collectives, + // BridgeHubPolkadot, + PenpalPolkadotA, + PenpalPolkadotB, + ], + // TODO: uncomment when https://github.com/polkadot-fellows/runtimes/pull/108 is merged + // bridge = PolkadotKusamaMockBridge + bridge = () + }, + pub struct KusamaMockNet { + relay_chain = Kusama, + parachains = vec![ + // AssetHubKusama, + // BridgeHubKusama, + PenpalKusamaA, + PenpalKusamaB, + ], + // TODO: uncomment when https://github.com/polkadot-fellows/runtimes/pull/108 is merged + // bridge = KusamaPolkadotMockBridge + bridge = () + }, +} + +// TODO: uncomment when https://github.com/polkadot-fellows/runtimes/pull/108 is merged +// decl_test_bridges! { +// pub struct PolkadotKusamaMockBridge { +// source = BridgeHubPolkadot, +// target = BridgeHubKusama, +// handler = PolkadotKusamaMessageHandler +// }, +// pub struct KusamaPolkadotMockBridge { +// source = BridgeHubKusama, +// target = BridgeHubPolkadot, +// handler = KusamaPolkadotMessageHandler +// } +// } + +// Polkadot implementation +impl_accounts_helpers_for_relay_chain!(Polkadot); +impl_assert_events_helpers_for_relay_chain!(Polkadot); +impl_hrmp_channels_helpers_for_relay_chain!(Polkadot); + +// Kusama implementation +impl_accounts_helpers_for_relay_chain!(Kusama); +impl_assert_events_helpers_for_relay_chain!(Kusama); +impl_hrmp_channels_helpers_for_relay_chain!(Kusama); + +// // AssetHubPolkadot implementation +// impl_accounts_helpers_for_parachain!(AssetHubPolkadot); +// impl_assets_helpers_for_parachain!(AssetHubPolkadot, Polkadot); +// impl_assert_events_helpers_for_parachain!(AssetHubPolkadot); +// +// // AssetHubKusama implementation +// impl_accounts_helpers_for_parachain!(AssetHubKusama); +// impl_assets_helpers_for_parachain!(AssetHubKusama, Kusama); +// impl_assert_events_helpers_for_parachain!(AssetHubKusama); +// +// // PenpalPolkadot implementations +// impl_assert_events_helpers_for_parachain!(PenpalPolkadotA); +// impl_assert_events_helpers_for_parachain!(PenpalPolkadotB); +// +// // PenpalKusama implementations +// impl_assert_events_helpers_for_parachain!(PenpalKusamaA); +// impl_assert_events_helpers_for_parachain!(PenpalKusamaB); +// +// // Collectives implementation +// impl_accounts_helpers_for_parachain!(Collectives); +// impl_assert_events_helpers_for_parachain!(Collectives); + +decl_test_sender_receiver_accounts_parameter_types! { + // Relays + Polkadot { sender: ALICE, receiver: BOB }, + Kusama { sender: ALICE, receiver: BOB }, + // // Asset Hubs + // AssetHubPolkadot { sender: ALICE, receiver: BOB }, + // AssetHubKusama { sender: ALICE, receiver: BOB }, + // // Collectives + // Collectives { sender: ALICE, receiver: BOB }, + // // Bridged Hubs + // BridgeHubPolkadot { sender: ALICE, receiver: BOB }, + // BridgeHubKusama { sender: ALICE, receiver: BOB }, + // Penpals + PenpalPolkadotA { sender: ALICE, receiver: BOB }, + PenpalPolkadotB { sender: ALICE, receiver: BOB }, + PenpalKusamaA { sender: ALICE, receiver: BOB }, + PenpalKusamaB { sender: ALICE, receiver: BOB } +} + +// decl_test_sender_receiver_accounts_parameter_types! { +// Kusama { sender: ALICE, receiver: BOB } +// } diff --git a/integration-tests/emulated/common/src/macros.rs b/integration-tests/emulated/common/src/macros.rs new file mode 100644 index 0000000000..a65b2057af --- /dev/null +++ b/integration-tests/emulated/common/src/macros.rs @@ -0,0 +1,107 @@ +// 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. + +#[macro_export] +macro_rules! test_parachain_is_trusted_teleporter { + ( $sender_para:ty, $sender_xcm_config:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr) ) => { + $crate::paste::paste! { + // init Origin variables + let sender = [<$sender_para Sender>]::get(); + let mut para_sender_balance_before = + <$sender_para as $crate::Chain>::account_data_of(sender.clone()).free; + let origin = <$sender_para as $crate::Chain>::RuntimeOrigin::signed(sender.clone()); + let fee_asset_item = 0; + let weight_limit = $crate::WeightLimit::Unlimited; + + $( + { + // init Destination variables + let receiver = [<$receiver_para Receiver>]::get(); + let para_receiver_balance_before = + <$receiver_para as $crate::Chain>::account_data_of(receiver.clone()).free; + let para_destination = + <$sender_para>::sibling_location_of(<$receiver_para>::para_id()); + let beneficiary: MultiLocation = + $crate::AccountId32 { network: None, id: receiver.clone().into() }.into(); + + // Send XCM message from Origin Parachain + // We are only testing the limited teleport version, which should be ok since success will + // depend only on a proper `XcmConfig` at destination. + <$sender_para>::execute_with(|| { + assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::limited_teleport_assets( + origin.clone(), + bx!(para_destination.into()), + bx!(beneficiary.into()), + bx!($assets.clone().into()), + fee_asset_item, + weight_limit.clone(), + )); + + type RuntimeEvent = <$sender_para as $crate::Chain>::RuntimeEvent; + + assert_expected_events!( + $sender_para, + vec![ + RuntimeEvent::PolkadotXcm( + $crate::pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } } + ) => {}, + RuntimeEvent::XcmpQueue( + $crate::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. } + ) => {}, + RuntimeEvent::Balances( + $crate::pallet_balances::Event::Withdraw { who: sender, amount } + ) => {}, + ] + ); + }); + + // Receive XCM message in Destination Parachain + <$receiver_para>::execute_with(|| { + type RuntimeEvent = <$receiver_para as $crate::Chain>::RuntimeEvent; + + assert_expected_events!( + $receiver_para, + vec![ + RuntimeEvent::Balances( + $crate::pallet_balances::Event::Deposit { who: receiver, .. } + ) => {}, + RuntimeEvent::XcmpQueue( + $crate::cumulus_pallet_xcmp_queue::Event::Success { .. } + ) => {}, + ] + ); + }); + + // Check if balances are updated accordingly in Origin and Destination Parachains + let para_sender_balance_after = + <$sender_para as $crate::Chain>::account_data_of(sender.clone()).free; + let para_receiver_balance_after = + <$receiver_para as $crate::Chain>::account_data_of(receiver.clone()).free; + let delivery_fees = <$sender_para>::execute_with(|| { + asset_test_utils::xcm_helpers::transfer_assets_delivery_fees::< + <$sender_xcm_config as xcm_executor::Config>::XcmSender, + >($assets.clone(), fee_asset_item, weight_limit.clone(), beneficiary, para_destination) + }); + + assert_eq!(para_sender_balance_before - $amount - delivery_fees, para_sender_balance_after); + assert!(para_receiver_balance_after > para_receiver_balance_before); + + // Update sender balance + para_sender_balance_before = <$sender_para as $crate::Chain>::account_data_of(sender.clone()).free; + } + )+ + } + }; +} diff --git a/integration-tests/emulated/common/src/xcm_helpers.rs b/integration-tests/emulated/common/src/xcm_helpers.rs new file mode 100644 index 0000000000..4096cdbba0 --- /dev/null +++ b/integration-tests/emulated/common/src/xcm_helpers.rs @@ -0,0 +1,66 @@ +// 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 . + +use parachains_common::AccountId; +use xcm::{ + prelude::{ + AccountId32, All, BuyExecution, DepositAsset, MultiAsset, MultiAssets, MultiLocation, + OriginKind, RefundSurplus, Transact, UnpaidExecution, VersionedXcm, Weight, WeightLimit, + WithdrawAsset, Xcm, X1, + }, + DoubleEncoded, +}; + +/// Helper method to build a XCM with a `Transact` instruction and paying for its execution +pub fn xcm_transact_paid_execution( + call: DoubleEncoded<()>, + origin_kind: OriginKind, + native_asset: MultiAsset, + beneficiary: AccountId, +) -> VersionedXcm<()> { + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1000000000, 200000); + let native_assets: MultiAssets = native_asset.clone().into(); + + VersionedXcm::from(Xcm(vec![ + WithdrawAsset(native_assets), + BuyExecution { fees: native_asset, weight_limit }, + Transact { require_weight_at_most, origin_kind, call }, + RefundSurplus, + DepositAsset { + assets: All.into(), + beneficiary: MultiLocation { + parents: 0, + interior: X1(AccountId32 { network: None, id: beneficiary.into() }), + }, + }, + ])) +} + +/// Helper method to build a XCM with a `Transact` instruction without paying for its execution +pub fn xcm_transact_unpaid_execution( + call: DoubleEncoded<()>, + origin_kind: OriginKind, +) -> VersionedXcm<()> { + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1000000000, 200000); + let check_origin = None; + + VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit, check_origin }, + Transact { require_weight_at_most, origin_kind, call }, + ])) +} From 6ff498607c5da0791248e6508fa584c22df51ebb Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 8 Dec 2023 11:20:50 +0200 Subject: [PATCH 02/18] compiles with parachains --- Cargo.lock | 5 + integration-tests/emulated/common/Cargo.toml | 19 +- .../emulated/common/src/constants.rs | 582 +++++++++--------- integration-tests/emulated/common/src/lib.rs | 250 ++++---- 4 files changed, 431 insertions(+), 425 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cfff363585..ed937025f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3099,9 +3099,14 @@ dependencies = [ name = "emulated-integration-tests-common" version = "1.0.0" dependencies = [ + "asset-hub-kusama-runtime", + "asset-hub-polkadot-runtime", "asset-test-utils", "bp-messages", + "bridge-hub-kusama-runtime", + "bridge-hub-polkadot-runtime", "bridge-runtime-common", + "collectives-polkadot-runtime", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", diff --git a/integration-tests/emulated/common/Cargo.toml b/integration-tests/emulated/common/Cargo.toml index f187070f7a..f01331bfd1 100644 --- a/integration-tests/emulated/common/Cargo.toml +++ b/integration-tests/emulated/common/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "emulated-integration-tests-common" +name = "integration-tests-common" version = "1.0.0" authors.workspace = true edition.workspace = true @@ -37,7 +37,7 @@ polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } # Cumulus parachains-common = { default-features = false, version = "4.0.0" } cumulus-primitives-core = { default-features = false, version = "0.4.0" } -xcm-emulator = { default-features = false, version = "0.2.0" } +xcm-emulator = { version = "0.2.0" } cumulus-pallet-xcmp-queue = { default-features = false, version = "0.4.0" } cumulus-pallet-parachain-system = { default-features = false, features = ["parameterized-consensus-hook",] , version = "0.4.0" } asset-test-utils = { version = "4.0.0" } @@ -49,11 +49,11 @@ kusama-runtime = { package = "staging-kusama-runtime", path = "../../../relay/ku kusama-runtime-constants = { path = "../../../relay/kusama/constants", default-features = false } polkadot-runtime = { path = "../../../relay/polkadot", default-features = false } polkadot-runtime-constants = { path = "../../../relay/polkadot/constants", default-features = false } -#asset-hub-polkadot-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-polkadot", default-features = false } -#asset-hub-kusama-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-kusama", default-features = false } -#collectives-polkadot-runtime = { path = "../../../system-parachains/collectives/collectives-polkadot", default-features = false } -#bridge-hub-kusama-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-kusama", default-features = false } -#bridge-hub-polkadot-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-polkadot", default-features = false } +asset-hub-polkadot-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-polkadot", default-features = false } +asset-hub-kusama-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-kusama", default-features = false } +collectives-polkadot-runtime = { path = "../../../system-parachains/collectives/collectives-polkadot", default-features = false } +bridge-hub-polkadot-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-polkadot", default-features = false } +bridge-hub-kusama-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-kusama", default-features = false } # Bridges bp-messages = { version = "0.4.0" } @@ -73,4 +73,9 @@ std = [ "kusama-runtime-constants/std", "polkadot-runtime/std", "polkadot-runtime-constants/std", + "asset-hub-polkadot-runtime/std", + "asset-hub-kusama-runtime/std", + "collectives-polkadot-runtime/std", + "bridge-hub-polkadot-runtime/std", + "bridge-hub-kusama-runtime/std", ] diff --git a/integration-tests/emulated/common/src/constants.rs b/integration-tests/emulated/common/src/constants.rs index f8c79a7921..f5be05511b 100644 --- a/integration-tests/emulated/common/src/constants.rs +++ b/integration-tests/emulated/common/src/constants.rs @@ -95,18 +95,18 @@ pub mod accounts { pub mod collators { use super::*; - // pub fn invulnerables_asset_hub_polkadot() -> Vec<(AccountId, AssetHubPolkadotAuraId)> { - // vec![ - // ( - // get_account_id_from_seed::("Alice"), - // get_from_seed::("Alice"), - // ), - // ( - // get_account_id_from_seed::("Bob"), - // get_from_seed::("Bob"), - // ), - // ] - // } + pub fn invulnerables_asset_hub_polkadot() -> Vec<(AccountId, AssetHubPolkadotAuraId)> { + vec![ + ( + get_account_id_from_seed::("Alice"), + get_from_seed::("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_from_seed::("Bob"), + ), + ] + } pub fn invulnerables() -> Vec<(AccountId, AuraId)> { vec![ @@ -422,289 +422,289 @@ pub mod kusama { } // Asset Hub Polkadot -// pub mod asset_hub_polkadot { -// use super::*; -// pub const PARA_ID: u32 = 1000; -// pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; -// -// pub fn genesis() -> Storage { -// let genesis_config = asset_hub_polkadot_runtime::RuntimeGenesisConfig { -// system: asset_hub_polkadot_runtime::SystemConfig { -// code: asset_hub_polkadot_runtime::WASM_BINARY -// .expect("WASM binary was not build, please build it!") -// .to_vec(), -// ..Default::default() -// }, -// balances: asset_hub_polkadot_runtime::BalancesConfig { -// balances: accounts::init_balances() -// .iter() -// .cloned() -// .map(|k| (k, ED * 4096)) -// .collect(), -// }, -// parachain_info: asset_hub_polkadot_runtime::ParachainInfoConfig { -// parachain_id: PARA_ID.into(), -// ..Default::default() -// }, -// collator_selection: asset_hub_polkadot_runtime::CollatorSelectionConfig { -// invulnerables: collators::invulnerables_asset_hub_polkadot() -// .iter() -// .cloned() -// .map(|(acc, _)| acc) -// .collect(), -// candidacy_bond: ED * 16, -// ..Default::default() -// }, -// session: asset_hub_polkadot_runtime::SessionConfig { -// keys: collators::invulnerables_asset_hub_polkadot() -// .into_iter() -// .map(|(acc, aura)| { -// ( -// acc.clone(), // account id -// acc, // validator id -// asset_hub_polkadot_runtime::SessionKeys { aura }, // session keys -// ) -// }) -// .collect(), -// }, -// polkadot_xcm: asset_hub_polkadot_runtime::PolkadotXcmConfig { -// safe_xcm_version: Some(SAFE_XCM_VERSION), -// ..Default::default() -// }, -// ..Default::default() -// }; -// -// genesis_config.build_storage().unwrap() -// } -// } +pub mod asset_hub_polkadot { + use super::*; + pub const PARA_ID: u32 = 1000; + pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = asset_hub_polkadot_runtime::RuntimeGenesisConfig { + system: asset_hub_polkadot_runtime::SystemConfig { + code: asset_hub_polkadot_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + ..Default::default() + }, + balances: asset_hub_polkadot_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: asset_hub_polkadot_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: asset_hub_polkadot_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables_asset_hub_polkadot() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_polkadot_runtime::SessionConfig { + keys: collators::invulnerables_asset_hub_polkadot() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_polkadot_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: asset_hub_polkadot_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} // Asset Hub Kusama -// pub mod asset_hub_kusama { -// use super::*; -// pub const PARA_ID: u32 = 1000; -// pub const ED: Balance = parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT; -// -// pub fn genesis() -> Storage { -// let genesis_config = asset_hub_kusama_runtime::RuntimeGenesisConfig { -// system: asset_hub_kusama_runtime::SystemConfig { -// code: asset_hub_kusama_runtime::WASM_BINARY -// .expect("WASM binary was not build, please build it!") -// .to_vec(), -// ..Default::default() -// }, -// balances: asset_hub_kusama_runtime::BalancesConfig { -// balances: accounts::init_balances() -// .iter() -// .cloned() -// .map(|k| (k, ED * 4096)) -// .collect(), -// }, -// parachain_info: asset_hub_kusama_runtime::ParachainInfoConfig { -// parachain_id: PARA_ID.into(), -// ..Default::default() -// }, -// collator_selection: asset_hub_kusama_runtime::CollatorSelectionConfig { -// invulnerables: collators::invulnerables() -// .iter() -// .cloned() -// .map(|(acc, _)| acc) -// .collect(), -// candidacy_bond: ED * 16, -// ..Default::default() -// }, -// session: asset_hub_kusama_runtime::SessionConfig { -// keys: collators::invulnerables() -// .into_iter() -// .map(|(acc, aura)| { -// ( -// acc.clone(), // account id -// acc, // validator id -// asset_hub_kusama_runtime::SessionKeys { aura }, // session keys -// ) -// }) -// .collect(), -// }, -// polkadot_xcm: asset_hub_kusama_runtime::PolkadotXcmConfig { -// safe_xcm_version: Some(SAFE_XCM_VERSION), -// ..Default::default() -// }, -// ..Default::default() -// }; -// -// genesis_config.build_storage().unwrap() -// } -// } -// -// // Bridge Hub Polkadot -// pub mod bridge_hub_polkadot { -// use super::*; -// pub const PARA_ID: u32 = 1002; -// pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; -// -// pub fn genesis() -> Storage { -// let genesis_config = bridge_hub_polkadot_runtime::RuntimeGenesisConfig { -// system: bridge_hub_polkadot_runtime::SystemConfig { -// code: bridge_hub_polkadot_runtime::WASM_BINARY -// .expect("WASM binary was not build, please build it!") -// .to_vec(), -// ..Default::default() -// }, -// balances: bridge_hub_polkadot_runtime::BalancesConfig { -// balances: accounts::init_balances() -// .iter() -// .cloned() -// .map(|k| (k, ED * 4096)) -// .collect(), -// }, -// parachain_info: bridge_hub_polkadot_runtime::ParachainInfoConfig { -// parachain_id: PARA_ID.into(), -// ..Default::default() -// }, -// collator_selection: bridge_hub_polkadot_runtime::CollatorSelectionConfig { -// invulnerables: collators::invulnerables() -// .iter() -// .cloned() -// .map(|(acc, _)| acc) -// .collect(), -// candidacy_bond: ED * 16, -// ..Default::default() -// }, -// session: bridge_hub_polkadot_runtime::SessionConfig { -// keys: collators::invulnerables() -// .into_iter() -// .map(|(acc, aura)| { -// ( -// acc.clone(), // account id -// acc, // validator id -// bridge_hub_polkadot_runtime::SessionKeys { aura }, // session keys -// ) -// }) -// .collect(), -// }, -// polkadot_xcm: bridge_hub_polkadot_runtime::PolkadotXcmConfig { -// safe_xcm_version: Some(SAFE_XCM_VERSION), -// ..Default::default() -// }, -// ..Default::default() -// }; -// -// genesis_config.build_storage().unwrap() -// } -// } -// -// // Bridge Hub Kusama -// pub mod bridge_hub_kusama { -// use super::*; -// pub const PARA_ID: u32 = 1002; -// pub const ED: Balance = parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT; -// -// pub fn genesis() -> Storage { -// let genesis_config = bridge_hub_kusama_runtime::RuntimeGenesisConfig { -// system: bridge_hub_kusama_runtime::SystemConfig { -// code: bridge_hub_kusama_runtime::WASM_BINARY -// .expect("WASM binary was not build, please build it!") -// .to_vec(), -// ..Default::default() -// }, -// balances: bridge_hub_kusama_runtime::BalancesConfig { -// balances: accounts::init_balances() -// .iter() -// .cloned() -// .map(|k| (k, ED * 4096)) -// .collect(), -// }, -// parachain_info: bridge_hub_kusama_runtime::ParachainInfoConfig { -// parachain_id: PARA_ID.into(), -// ..Default::default() -// }, -// collator_selection: bridge_hub_kusama_runtime::CollatorSelectionConfig { -// invulnerables: collators::invulnerables() -// .iter() -// .cloned() -// .map(|(acc, _)| acc) -// .collect(), -// candidacy_bond: ED * 16, -// ..Default::default() -// }, -// session: bridge_hub_kusama_runtime::SessionConfig { -// keys: collators::invulnerables() -// .into_iter() -// .map(|(acc, aura)| { -// ( -// acc.clone(), // account id -// acc, // validator id -// bridge_hub_kusama_runtime::SessionKeys { aura }, // session keys -// ) -// }) -// .collect(), -// }, -// polkadot_xcm: bridge_hub_kusama_runtime::PolkadotXcmConfig { -// safe_xcm_version: Some(SAFE_XCM_VERSION), -// ..Default::default() -// }, -// ..Default::default() -// }; -// -// genesis_config.build_storage().unwrap() -// } -// } +pub mod asset_hub_kusama { + use super::*; + pub const PARA_ID: u32 = 1000; + pub const ED: Balance = parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = asset_hub_kusama_runtime::RuntimeGenesisConfig { + system: asset_hub_kusama_runtime::SystemConfig { + code: asset_hub_kusama_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + ..Default::default() + }, + balances: asset_hub_kusama_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: asset_hub_kusama_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: asset_hub_kusama_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_kusama_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_kusama_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: asset_hub_kusama_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} + +// Bridge Hub Polkadot +pub mod bridge_hub_polkadot { + use super::*; + pub const PARA_ID: u32 = 1002; + pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = bridge_hub_polkadot_runtime::RuntimeGenesisConfig { + system: bridge_hub_polkadot_runtime::SystemConfig { + code: bridge_hub_polkadot_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + ..Default::default() + }, + balances: bridge_hub_polkadot_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: bridge_hub_polkadot_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: bridge_hub_polkadot_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: bridge_hub_polkadot_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + bridge_hub_polkadot_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: bridge_hub_polkadot_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} + +// Bridge Hub Kusama +pub mod bridge_hub_kusama { + use super::*; + pub const PARA_ID: u32 = 1002; + pub const ED: Balance = parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = bridge_hub_kusama_runtime::RuntimeGenesisConfig { + system: bridge_hub_kusama_runtime::SystemConfig { + code: bridge_hub_kusama_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + ..Default::default() + }, + balances: bridge_hub_kusama_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: bridge_hub_kusama_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: bridge_hub_kusama_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: bridge_hub_kusama_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + bridge_hub_kusama_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: bridge_hub_kusama_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} // Collectives -// pub mod collectives { -// use super::*; -// pub const PARA_ID: u32 = 1001; -// pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; -// -// pub fn genesis() -> Storage { -// let genesis_config = collectives_polkadot_runtime::RuntimeGenesisConfig { -// system: collectives_polkadot_runtime::SystemConfig { -// code: collectives_polkadot_runtime::WASM_BINARY -// .expect("WASM binary was not build, please build it!") -// .to_vec(), -// ..Default::default() -// }, -// balances: collectives_polkadot_runtime::BalancesConfig { -// balances: accounts::init_balances() -// .iter() -// .cloned() -// .map(|k| (k, ED * 4096)) -// .collect(), -// }, -// parachain_info: collectives_polkadot_runtime::ParachainInfoConfig { -// parachain_id: PARA_ID.into(), -// ..Default::default() -// }, -// collator_selection: collectives_polkadot_runtime::CollatorSelectionConfig { -// invulnerables: collators::invulnerables() -// .iter() -// .cloned() -// .map(|(acc, _)| acc) -// .collect(), -// candidacy_bond: ED * 16, -// ..Default::default() -// }, -// session: collectives_polkadot_runtime::SessionConfig { -// keys: collators::invulnerables() -// .into_iter() -// .map(|(acc, aura)| { -// ( -// acc.clone(), // account id -// acc, // validator id -// collectives_polkadot_runtime::SessionKeys { aura }, // session keys -// ) -// }) -// .collect(), -// }, -// polkadot_xcm: collectives_polkadot_runtime::PolkadotXcmConfig { -// safe_xcm_version: Some(SAFE_XCM_VERSION), -// ..Default::default() -// }, -// ..Default::default() -// }; -// -// genesis_config.build_storage().unwrap() -// } -// } +pub mod collectives { + use super::*; + pub const PARA_ID: u32 = 1001; + pub const ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = collectives_polkadot_runtime::RuntimeGenesisConfig { + system: collectives_polkadot_runtime::SystemConfig { + code: collectives_polkadot_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + ..Default::default() + }, + balances: collectives_polkadot_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: collectives_polkadot_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + collator_selection: collectives_polkadot_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: collectives_polkadot_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + collectives_polkadot_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + polkadot_xcm: collectives_polkadot_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} // Penpal pub mod penpal { diff --git a/integration-tests/emulated/common/src/lib.rs b/integration-tests/emulated/common/src/lib.rs index c7bb121d34..d5e3305da9 100644 --- a/integration-tests/emulated/common/src/lib.rs +++ b/integration-tests/emulated/common/src/lib.rs @@ -19,7 +19,7 @@ pub mod xcm_helpers; use constants::{ accounts::{ALICE, BOB}, - // asset_hub_kusama, asset_hub_polkadot, bridge_hub_kusama, bridge_hub_polkadot, collectives, + asset_hub_kusama, asset_hub_polkadot, bridge_hub_kusama, bridge_hub_polkadot, collectives, kusama, penpal, polkadot, }; @@ -70,57 +70,57 @@ decl_test_relay_chains! { decl_test_parachains! { // Polkadot Parachains - // pub struct AssetHubPolkadot { - // genesis = asset_hub_polkadot::genesis(), - // on_init = { - // asset_hub_polkadot_runtime::AuraExt::on_initialize(1); - // }, - // runtime = asset_hub_polkadot_runtime, - // core = { - // XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue, - // DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue, - // LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId, - // ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo, - // }, - // pallets = { - // PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm, - // Assets: asset_hub_polkadot_runtime::Assets, - // Balances: asset_hub_polkadot_runtime::Balances, - // } - // }, - // pub struct Collectives { - // genesis = collectives::genesis(), - // on_init = { - // collectives_polkadot_runtime::AuraExt::on_initialize(1); - // }, - // runtime = collectives_polkadot_runtime, - // core = { - // XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue, - // DmpMessageHandler: collectives_polkadot_runtime::DmpQueue, - // LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId, - // ParachainInfo: collectives_polkadot_runtime::ParachainInfo, - // }, - // pallets = { - // PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm, - // Balances: collectives_polkadot_runtime::Balances, - // } - // }, - // pub struct BridgeHubPolkadot { - // genesis = bridge_hub_polkadot::genesis(), - // on_init = { - // bridge_hub_polkadot_runtime::AuraExt::on_initialize(1); - // }, - // runtime = bridge_hub_polkadot_runtime, - // core = { - // XcmpMessageHandler: bridge_hub_polkadot_runtime::XcmpQueue, - // DmpMessageHandler: bridge_hub_polkadot_runtime::DmpQueue, - // LocationToAccountId: bridge_hub_polkadot_runtime::xcm_config::LocationToAccountId, - // ParachainInfo: bridge_hub_polkadot_runtime::ParachainInfo, - // }, - // pallets = { - // PolkadotXcm: bridge_hub_polkadot_runtime::PolkadotXcm, - // } - // }, + pub struct AssetHubPolkadot { + genesis = asset_hub_polkadot::genesis(), + on_init = { + asset_hub_polkadot_runtime::AuraExt::on_initialize(1); + }, + runtime = asset_hub_polkadot_runtime, + core = { + XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue, + DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue, + LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId, + ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm, + Assets: asset_hub_polkadot_runtime::Assets, + Balances: asset_hub_polkadot_runtime::Balances, + } + }, + pub struct Collectives { + genesis = collectives::genesis(), + on_init = { + collectives_polkadot_runtime::AuraExt::on_initialize(1); + }, + runtime = collectives_polkadot_runtime, + core = { + XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue, + DmpMessageHandler: collectives_polkadot_runtime::DmpQueue, + LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId, + ParachainInfo: collectives_polkadot_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm, + Balances: collectives_polkadot_runtime::Balances, + } + }, + pub struct BridgeHubPolkadot { + genesis = bridge_hub_polkadot::genesis(), + on_init = { + bridge_hub_polkadot_runtime::AuraExt::on_initialize(1); + }, + runtime = bridge_hub_polkadot_runtime, + core = { + XcmpMessageHandler: bridge_hub_polkadot_runtime::XcmpQueue, + DmpMessageHandler: bridge_hub_polkadot_runtime::DmpQueue, + LocationToAccountId: bridge_hub_polkadot_runtime::xcm_config::LocationToAccountId, + ParachainInfo: bridge_hub_polkadot_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: bridge_hub_polkadot_runtime::PolkadotXcm, + } + }, pub struct PenpalPolkadotA { genesis = penpal::genesis(penpal::PARA_ID_A), on_init = { @@ -156,43 +156,43 @@ decl_test_parachains! { } }, // Kusama Parachains - // pub struct AssetHubKusama { - // genesis = asset_hub_kusama::genesis(), - // on_init = { - // asset_hub_kusama_runtime::AuraExt::on_initialize(1); - // }, - // runtime = asset_hub_kusama_runtime, - // core = { - // XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue, - // DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue, - // LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId, - // ParachainInfo: asset_hub_kusama_runtime::ParachainInfo, - // }, - // pallets = { - // PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm, - // Assets: asset_hub_kusama_runtime::Assets, - // ForeignAssets: asset_hub_kusama_runtime::ForeignAssets, - // PoolAssets: asset_hub_kusama_runtime::PoolAssets, - // AssetConversion: asset_hub_kusama_runtime::AssetConversion, - // Balances: asset_hub_kusama_runtime::Balances, - // } - // }, - // pub struct BridgeHubKusama { - // genesis = bridge_hub_kusama::genesis(), - // on_init = { - // bridge_hub_kusama_runtime::AuraExt::on_initialize(1); - // }, - // runtime = bridge_hub_kusama_runtime, - // core = { - // XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue, - // DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue, - // LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId, - // ParachainInfo: bridge_hub_kusama_runtime::ParachainInfo, - // }, - // pallets = { - // PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm, - // } - // }, + pub struct AssetHubKusama { + genesis = asset_hub_kusama::genesis(), + on_init = { + asset_hub_kusama_runtime::AuraExt::on_initialize(1); + }, + runtime = asset_hub_kusama_runtime, + core = { + XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue, + DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue, + LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId, + ParachainInfo: asset_hub_kusama_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm, + Assets: asset_hub_kusama_runtime::Assets, + ForeignAssets: asset_hub_kusama_runtime::ForeignAssets, + PoolAssets: asset_hub_kusama_runtime::PoolAssets, + AssetConversion: asset_hub_kusama_runtime::AssetConversion, + Balances: asset_hub_kusama_runtime::Balances, + } + }, + pub struct BridgeHubKusama { + genesis = bridge_hub_kusama::genesis(), + on_init = { + bridge_hub_kusama_runtime::AuraExt::on_initialize(1); + }, + runtime = bridge_hub_kusama_runtime, + core = { + XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue, + DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue, + LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId, + ParachainInfo: bridge_hub_kusama_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm, + } + }, pub struct PenpalKusamaA { genesis = penpal::genesis(penpal::PARA_ID_A), on_init = { @@ -233,9 +233,9 @@ decl_test_networks! { pub struct PolkadotMockNet { relay_chain = Polkadot, parachains = vec![ - // AssetHubPolkadot, - // Collectives, - // BridgeHubPolkadot, + AssetHubPolkadot, + Collectives, + BridgeHubPolkadot, PenpalPolkadotA, PenpalPolkadotB, ], @@ -246,8 +246,8 @@ decl_test_networks! { pub struct KusamaMockNet { relay_chain = Kusama, parachains = vec![ - // AssetHubKusama, - // BridgeHubKusama, + AssetHubKusama, + BridgeHubKusama, PenpalKusamaA, PenpalKusamaB, ], @@ -281,47 +281,43 @@ impl_accounts_helpers_for_relay_chain!(Kusama); impl_assert_events_helpers_for_relay_chain!(Kusama); impl_hrmp_channels_helpers_for_relay_chain!(Kusama); -// // AssetHubPolkadot implementation -// impl_accounts_helpers_for_parachain!(AssetHubPolkadot); -// impl_assets_helpers_for_parachain!(AssetHubPolkadot, Polkadot); -// impl_assert_events_helpers_for_parachain!(AssetHubPolkadot); -// -// // AssetHubKusama implementation -// impl_accounts_helpers_for_parachain!(AssetHubKusama); -// impl_assets_helpers_for_parachain!(AssetHubKusama, Kusama); -// impl_assert_events_helpers_for_parachain!(AssetHubKusama); -// -// // PenpalPolkadot implementations -// impl_assert_events_helpers_for_parachain!(PenpalPolkadotA); -// impl_assert_events_helpers_for_parachain!(PenpalPolkadotB); -// -// // PenpalKusama implementations -// impl_assert_events_helpers_for_parachain!(PenpalKusamaA); -// impl_assert_events_helpers_for_parachain!(PenpalKusamaB); -// -// // Collectives implementation -// impl_accounts_helpers_for_parachain!(Collectives); -// impl_assert_events_helpers_for_parachain!(Collectives); +// AssetHubPolkadot implementation +impl_accounts_helpers_for_parachain!(AssetHubPolkadot); +impl_assets_helpers_for_parachain!(AssetHubPolkadot, Polkadot); +impl_assert_events_helpers_for_parachain!(AssetHubPolkadot); + +// AssetHubKusama implementation +impl_accounts_helpers_for_parachain!(AssetHubKusama); +impl_assets_helpers_for_parachain!(AssetHubKusama, Kusama); +impl_assert_events_helpers_for_parachain!(AssetHubKusama); + +// PenpalPolkadot implementations +impl_assert_events_helpers_for_parachain!(PenpalPolkadotA); +impl_assert_events_helpers_for_parachain!(PenpalPolkadotB); + +// PenpalKusama implementations +impl_assert_events_helpers_for_parachain!(PenpalKusamaA); +impl_assert_events_helpers_for_parachain!(PenpalKusamaB); + +// Collectives implementation +impl_accounts_helpers_for_parachain!(Collectives); +impl_assert_events_helpers_for_parachain!(Collectives); decl_test_sender_receiver_accounts_parameter_types! { // Relays Polkadot { sender: ALICE, receiver: BOB }, Kusama { sender: ALICE, receiver: BOB }, - // // Asset Hubs - // AssetHubPolkadot { sender: ALICE, receiver: BOB }, - // AssetHubKusama { sender: ALICE, receiver: BOB }, - // // Collectives - // Collectives { sender: ALICE, receiver: BOB }, - // // Bridged Hubs - // BridgeHubPolkadot { sender: ALICE, receiver: BOB }, - // BridgeHubKusama { sender: ALICE, receiver: BOB }, + // Asset Hubs + AssetHubPolkadot { sender: ALICE, receiver: BOB }, + AssetHubKusama { sender: ALICE, receiver: BOB }, + // Collectives + Collectives { sender: ALICE, receiver: BOB }, + // Bridged Hubs + BridgeHubPolkadot { sender: ALICE, receiver: BOB }, + BridgeHubKusama { sender: ALICE, receiver: BOB }, // Penpals PenpalPolkadotA { sender: ALICE, receiver: BOB }, PenpalPolkadotB { sender: ALICE, receiver: BOB }, PenpalKusamaA { sender: ALICE, receiver: BOB }, PenpalKusamaB { sender: ALICE, receiver: BOB } } - -// decl_test_sender_receiver_accounts_parameter_types! { -// Kusama { sender: ALICE, receiver: BOB } -// } From 42f9272f21ed38ee3e7dd203ee968068b315218b Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 8 Dec 2023 13:30:47 +0200 Subject: [PATCH 03/18] asset-hub-kusama tests compile --- Cargo.lock | 119 +++-- Cargo.toml | 3 +- .../assets/asset-hub-kusama/Cargo.toml | 56 +++ .../assets/asset-hub-kusama/src/lib.rs | 90 ++++ .../src/tests/hrmp_channels.rs | 196 +++++++++ .../assets/asset-hub-kusama/src/tests/mod.rs | 21 + .../src/tests/reserve_transfer.rs | 414 ++++++++++++++++++ .../assets/asset-hub-kusama/src/tests/send.rs | 195 +++++++++ .../src/tests/set_xcm_versions.rs | 93 ++++ .../assets/asset-hub-kusama/src/tests/swap.rs | 364 +++++++++++++++ .../asset-hub-kusama/src/tests/teleport.rs | 363 +++++++++++++++ .../assets/asset-hub-polkadot/Cargo.toml | 35 ++ .../assets/asset-hub-polkadot/src/lib.rs | 90 ++++ .../src/tests/hrmp_channels.rs | 192 ++++++++ .../asset-hub-polkadot/src/tests/mod.rs | 20 + .../src/tests/reserve_transfer.rs | 414 ++++++++++++++++++ .../asset-hub-polkadot/src/tests/send.rs | 201 +++++++++ .../src/tests/set_xcm_versions.rs | 96 ++++ .../asset-hub-polkadot/src/tests/teleport.rs | 363 +++++++++++++++ .../assets/asset-hub-westend/Cargo.toml | 53 +++ .../assets/asset-hub-westend/src/lib.rs | 92 ++++ .../assets/asset-hub-westend/src/tests/mod.rs | 20 + .../src/tests/reserve_transfer.rs | 414 ++++++++++++++++++ .../asset-hub-westend/src/tests/send.rs | 140 ++++++ .../src/tests/set_xcm_versions.rs | 96 ++++ .../asset-hub-westend/src/tests/swap.rs | 350 +++++++++++++++ .../asset-hub-westend/src/tests/teleport.rs | 363 +++++++++++++++ 27 files changed, 4804 insertions(+), 49 deletions(-) create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/src/tests/set_xcm_versions.rs create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/src/tests/swap.rs create mode 100644 integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs create mode 100644 integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml create mode 100644 integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs create mode 100644 integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs create mode 100644 integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs create mode 100644 integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs create mode 100644 integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs create mode 100644 integration-tests/emulated/assets/asset-hub-polkadot/src/tests/set_xcm_versions.rs create mode 100644 integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs create mode 100644 integration-tests/emulated/assets/asset-hub-westend/Cargo.toml create mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/lib.rs create mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs create mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs create mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs create mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/set_xcm_versions.rs create mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/swap.rs create mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs diff --git a/Cargo.lock b/Cargo.lock index ed937025f6..874857f293 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -530,6 +530,29 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "asset-hub-kusama-integration-tests" +version = "1.0.0" +dependencies = [ + "assert_matches", + "asset-hub-kusama-runtime", + "frame-support", + "frame-system", + "integration-tests-common", + "pallet-asset-conversion", + "pallet-assets", + "pallet-balances", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain-primitives", + "polkadot-runtime-parachains", + "sp-runtime", + "staging-xcm", + "xcm-emulator", +] + [[package]] name = "asset-hub-kusama-runtime" version = "1.0.0" @@ -3095,54 +3118,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "emulated-integration-tests-common" -version = "1.0.0" -dependencies = [ - "asset-hub-kusama-runtime", - "asset-hub-polkadot-runtime", - "asset-test-utils", - "bp-messages", - "bridge-hub-kusama-runtime", - "bridge-hub-polkadot-runtime", - "bridge-runtime-common", - "collectives-polkadot-runtime", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "frame-support", - "kusama-runtime-constants", - "pallet-assets", - "pallet-balances", - "pallet-bridge-messages", - "pallet-im-online", - "pallet-message-queue", - "pallet-staking", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "paste", - "penpal-runtime", - "polkadot-core-primitives", - "polkadot-parachain-primitives", - "polkadot-primitives", - "polkadot-runtime", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "polkadot-service", - "serde_json", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-consensus-grandpa", - "sp-core", - "sp-runtime", - "staging-kusama-runtime", - "staging-xcm", - "xcm-emulator", -] - [[package]] name = "encode_unicode" version = "0.3.6" @@ -4600,6 +4575,54 @@ dependencies = [ "num-traits", ] +[[package]] +name = "integration-tests-common" +version = "1.0.0" +dependencies = [ + "asset-hub-kusama-runtime", + "asset-hub-polkadot-runtime", + "asset-test-utils", + "bp-messages", + "bridge-hub-kusama-runtime", + "bridge-hub-polkadot-runtime", + "bridge-runtime-common", + "collectives-polkadot-runtime", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "kusama-runtime-constants", + "pallet-assets", + "pallet-balances", + "pallet-bridge-messages", + "pallet-im-online", + "pallet-message-queue", + "pallet-staking", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "paste", + "penpal-runtime", + "polkadot-core-primitives", + "polkadot-parachain-primitives", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-service", + "serde_json", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core", + "sp-runtime", + "staging-kusama-runtime", + "staging-xcm", + "xcm-emulator", +] + [[package]] name = "interceptor" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index add69cb684..1873c213a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,9 @@ members = [ "system-parachains/bridge-hubs/bridge-hub-polkadot", "system-parachains/collectives/collectives-polkadot", "system-parachains/gluttons/glutton-kusama", -# "integration-tests/emulated/chains-definitions/relays/kusama", "integration-tests/emulated/common", + "integration-tests/emulated/assets/asset-hub-kusama", +# "integration-tests/emulated/assets/asset-hub-polkadot", ] [profile.release] diff --git a/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml b/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml new file mode 100644 index 0000000000..d0f050c1e4 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml @@ -0,0 +1,56 @@ +[package] +name = "asset-hub-kusama-integration-tests" +version = "1.0.0" +authors.workspace = true +edition.workspace = true +license = "Apache-2.0" +description = "Asset Hub Kusama runtime integration tests with xcm-emulator" +publish = false + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } +assert_matches = "1.5.0" + +# Substrate +sp-runtime = { default-features = false, version = "28.0.0" } +frame-support = { default-features = false, version = "25.0.0" } +frame-system = { default-features = false, version = "25.0.0" } +pallet-assets = { default-features = false, version = "26.0.0" } +pallet-balances = { default-features = false, version = "25.0.0" } +pallet-asset-conversion = { default-features = false, version = "7.0.0" } + +# Polkadot +polkadot-core-primitives = { default-features = false, version = "4.0.0" } +polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } +polkadot-runtime-parachains = { default-features = false, version = "4.0.0" } +xcm = { package = "staging-xcm", default-features = false, version = "4.0.0" } +pallet-xcm = { default-features = false, version = "4.0.0" } +#staging-kusama-runtime = { path = "../../../../relay/kusama", default-features = false } + +# Cumulus +parachains-common = { default-features = false, version = "4.0.0" } +xcm-emulator = { version = "0.2.0" } +asset-hub-kusama-runtime = { path = "../../../../system-parachains/asset-hubs/asset-hub-kusama", default-features = false } + +# Local +integration-tests-common = { path = "../../common", default-features = false} + +[features] +default = [ "std" ] + +std = [ + "sp-runtime/std", + "frame-support/std", + "frame-system/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-asset-conversion/std", + "polkadot-core-primitives/std", + "polkadot-parachain-primitives/std", + "polkadot-runtime-parachains/std", + "xcm/std", + "pallet-xcm/std", + "parachains-common/std", + "asset-hub-kusama-runtime/std", + "integration-tests-common/std", +] diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs new file mode 100644 index 0000000000..ad74aa2301 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -0,0 +1,90 @@ +// 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. + +pub use codec::Encode; +pub use frame_support::{ + assert_err, assert_ok, + pallet_prelude::Weight, + sp_runtime::{AccountId32, DispatchError, DispatchResult}, + traits::fungibles::Inspect, +}; +pub use integration_tests_common::{ + constants::{ + asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, + REF_TIME_THRESHOLD, XCM_V3, + }, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, Kusama, + KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusamaA, PenpalKusamaAPallet, + PenpalKusamaAReceiver, PenpalKusamaASender, PenpalKusamaB, PenpalKusamaBPallet, +}; +pub use parachains_common::{AccountId, Balance}; +pub use xcm::{ + prelude::{AccountId32 as AccountId32Junction, *}, + v3::{Error, NetworkId::Kusama as KusamaId}, +}; +pub use xcm_emulator::{ + assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, +}; + +pub const ASSET_ID: u32 = 1; +pub const ASSET_MIN_BALANCE: u128 = 1000; +// `Assets` pallet index +pub const ASSETS_PALLET_ID: u8 = 50; + +pub type RelayToSystemParaTest = Test; +pub type SystemParaToRelayTest = Test; +pub type SystemParaToParaTest = Test; + +/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests +pub fn relay_test_args(amount: Balance) -> TestArgs { + TestArgs { + dest: Kusama::child_location_of(AssetHubKusama::para_id()), + beneficiary: AccountId32Junction { + network: None, + id: AssetHubKusamaReceiver::get().into(), + } + .into(), + amount, + assets: (Here, amount).into(), + asset_id: None, + fee_asset_item: 0, + weight_limit: WeightLimit::Unlimited, + } +} + +/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests +pub fn system_para_test_args( + dest: MultiLocation, + beneficiary_id: AccountId32, + amount: Balance, + assets: MultiAssets, + asset_id: Option, +) -> TestArgs { + TestArgs { + dest, + beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(), + amount, + assets, + asset_id, + fee_asset_item: 0, + weight_limit: WeightLimit::Unlimited, + } +} + +#[cfg(test)] +#[cfg(not(feature = "runtime-benchmarks"))] +mod tests; diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs new file mode 100644 index 0000000000..3c3342d9ca --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs @@ -0,0 +1,196 @@ +// 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. + +use crate::*; + +const MAX_CAPACITY: u32 = 8; +const MAX_MESSAGE_SIZE: u32 = 8192; + +/// Opening HRMP channels between Parachains should work +#[test] +fn open_hrmp_channel_between_paras_works() { + // Parchain A init values + let para_a_id = PenpalKusamaA::para_id(); + let para_a_root_origin = ::RuntimeOrigin::root(); + + // Parachain B init values + let para_b_id = PenpalKusamaB::para_id(); + let para_b_root_origin = ::RuntimeOrigin::root(); + + let fee_amount = KUSAMA_ED * 1000; + let fund_amount = KUSAMA_ED * 1000_000_000; + + // Fund Parachain's Sovereign accounts to be able to reserve the deposit + let para_a_sovereign_account = Kusama::fund_para_sovereign(fund_amount, para_a_id); + let para_b_sovereign_account = Kusama::fund_para_sovereign(fund_amount, para_b_id); + + let relay_destination: VersionedMultiLocation = PenpalKusamaA::parent_location().into(); + + // ---- Init Open channel from Parachain to System Parachain + let mut call = Kusama::init_open_channel_call(para_b_id, MAX_CAPACITY, MAX_MESSAGE_SIZE); + let origin_kind = OriginKind::Native; + let native_asset: MultiAsset = (Here, fee_amount).into(); + let beneficiary = Kusama::sovereign_account_id_of_child_para(para_a_id); + + let mut xcm = xcm_transact_paid_execution(call, origin_kind, native_asset.clone(), beneficiary); + + PenpalKusamaA::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + para_a_root_origin, + bx!(relay_destination.clone()), + bx!(xcm), + )); + + PenpalKusamaA::assert_xcm_pallet_sent(); + }); + + Kusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + Kusama::assert_ump_queue_processed( + true, + Some(para_a_id), + Some(Weight::from_parts(1_312_558_000, 200000)), + ); + + assert_expected_events!( + Kusama, + vec![ + // Parachain's Sovereign account balance is withdrawn to pay XCM fees + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == para_a_sovereign_account.clone(), + amount: *amount == fee_amount, + }, + // Sender deposit is reserved for Parachain's Sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Reserved { who, .. }) =>{ + who: *who == para_a_sovereign_account, + }, + // Open channel requested from Para A to Para B + RuntimeEvent::Hrmp( + polkadot_runtime_parachains::hrmp::Event::OpenChannelRequested { + sender, + recipient, + proposed_max_capacity: max_capacity, + proposed_max_message_size: max_message_size + } + ) => { + sender: *sender == para_a_id.into(), + recipient: *recipient == para_b_id.into(), + max_capacity: *max_capacity == MAX_CAPACITY, + max_message_size: *max_message_size == MAX_MESSAGE_SIZE, + }, + ] + ); + }); + + // ---- Accept Open channel from Parachain to System Parachain + call = Kusama::accept_open_channel_call(para_a_id); + let beneficiary = Kusama::sovereign_account_id_of_child_para(para_b_id); + + xcm = xcm_transact_paid_execution(call, origin_kind, native_asset, beneficiary); + + PenpalKusamaB::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + para_b_root_origin, + bx!(relay_destination), + bx!(xcm), + )); + + PenpalKusamaB::assert_xcm_pallet_sent(); + }); + + PenpalKusamaB::execute_with(|| {}); + + Kusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + Kusama::assert_ump_queue_processed( + true, + Some(para_b_id), + Some(Weight::from_parts(1_312_558_000, 200_000)), + ); + + assert_expected_events!( + Kusama, + vec![ + // Parachain's Sovereign account balance is withdrawn to pay XCM fees + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == para_b_sovereign_account.clone(), + amount: *amount == fee_amount, + }, + // Sender deposit is reserved for Parachain's Sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Reserved { who, .. }) =>{ + who: *who == para_b_sovereign_account, + }, + // Open channel accepted for Para A to Para B + RuntimeEvent::Hrmp( + polkadot_runtime_parachains::hrmp::Event::OpenChannelAccepted { + sender, recipient + } + ) => { + sender: *sender == para_a_id.into(), + recipient: *recipient == para_b_id.into(), + }, + ] + ); + }); + + Kusama::force_process_hrmp_open(para_a_id, para_b_id); +} + +/// Opening HRMP channels between System Parachains and Parachains should work +#[test] +fn force_open_hrmp_channel_for_system_para_works() { + // Relay Chain init values + let relay_root_origin = ::RuntimeOrigin::root(); + + // System Para init values + let system_para_id = AssetHubKusama::para_id(); + + // Parachain A init values + let para_a_id = PenpalKusamaA::para_id(); + + Kusama::execute_with(|| { + assert_ok!(::Hrmp::force_open_hrmp_channel( + relay_root_origin, + system_para_id, + para_a_id, + MAX_CAPACITY, + MAX_MESSAGE_SIZE + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Kusama, + vec![ + // HRMP channel forced opened + RuntimeEvent::Hrmp( + polkadot_runtime_parachains::hrmp::Event::HrmpChannelForceOpened { + sender, + recipient, + proposed_max_capacity: max_capacity, + proposed_max_message_size: max_message_size + } + ) => { + sender: *sender == system_para_id.into(), + recipient: *recipient == para_a_id.into(), + max_capacity: *max_capacity == MAX_CAPACITY, + max_message_size: *max_message_size == MAX_MESSAGE_SIZE, + }, + ] + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs new file mode 100644 index 0000000000..b3089a3b38 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs @@ -0,0 +1,21 @@ +// 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. + +mod hrmp_channels; +mod reserve_transfer; +mod send; +mod set_xcm_versions; +mod swap; +mod teleport; diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs new file mode 100644 index 0000000000..645dca5035 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs @@ -0,0 +1,414 @@ +// 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. + +use crate::*; + +fn relay_origin_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + Kusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(630_092_000, 6_196))); + + assert_expected_events!( + Kusama, + vec![ + // Amount to reserve transfer is transferred to System Parachain's Sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount }) => { + from: *from == t.sender.account_id, + to: *to == Kusama::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) { + AssetHubKusama::assert_dmp_queue_incomplete( + Some(Weight::from_parts(1_000_000_000, 0)), + Some(Error::UntrustedReserveLocation), + ); +} + +fn system_para_to_relay_assertions(_t: SystemParaToRelayTest) { + AssetHubKusama::assert_xcm_pallet_attempted_error(Some(XcmError::Barrier)) +} + +fn system_para_to_para_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubKusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 630_092_000, + 6_196, + ))); + + assert_expected_events!( + AssetHubKusama, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereing account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == AssetHubKusama::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubKusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 676_119_000, + 6196, + ))); + + assert_expected_events!( + AssetHubKusama, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereing account + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount } + ) => { + asset_id: *asset_id == ASSET_ID, + from: *from == t.sender.account_id, + to: *to == AssetHubKusama::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn relay_limited_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn relay_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_limited_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn system_para_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +/// Limited Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't +/// work +#[test] +fn limited_reserve_transfer_native_asset_from_relay_to_system_para_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = KUSAMA_ED * 1000; + let test_args = TestContext { + sender: KusamaSender::get(), + receiver: AssetHubKusamaReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(system_para_dest_assertions_incomplete); + test.set_dispatchable::(relay_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Limited Reserve Transfers of native asset from System Parachain to Relay Chain shoudln't work +#[test] +fn limited_reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let destination = AssetHubKusama::parent_location(); + let beneficiary_id = KusamaReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: KusamaReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_relay_assertions); + test.set_dispatchable::(system_para_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work +#[test] +fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = KUSAMA_ED * 1000; + let test_args = TestContext { + sender: KusamaSender::get(), + receiver: AssetHubKusamaReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(system_para_dest_assertions_incomplete); + test.set_dispatchable::(relay_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work +#[test] +fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let destination = AssetHubKusama::parent_location(); + let beneficiary_id = KusamaReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: KusamaReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_relay_assertions); + test.set_dispatchable::(system_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Limited Reserve Transfers of native asset from System Parachain to Parachain should work +#[test] +fn limited_reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubKusama::sibling_location_of(PenpalKusamaA::para_id()); + let beneficiary_id = PenpalKusamaAReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: PenpalKusamaAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + + test.set_assertion::(system_para_to_para_assertions); + // TODO: Add assertion for Penpal runtime. Right now message is failing with + // `UntrustedReserveLocation` + test.set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve + // transfers +} + +/// Reserve Transfers of native asset from System Parachain to Parachain should work +#[test] +fn reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubKusama::sibling_location_of(PenpalKusamaA::para_id()); + let beneficiary_id = PenpalKusamaAReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: PenpalKusamaAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + + test.set_assertion::(system_para_to_para_assertions); + // TODO: Add assertion for Penpal runtime. Right now message is failing with + // `UntrustedReserveLocation` + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve + // transfers +} + +/// Limited Reserve Transfers of a local asset from System Parachain to Parachain should work +#[test] +fn limited_reserve_transfer_asset_from_system_para_to_para() { + // Force create asset from Relay Chain and mint assets for System Parachain's sender account + AssetHubKusama::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + AssetHubKusamaSender::get(), + ASSET_MIN_BALANCE * 1000000, + ); + + // Init values for System Parachain + let destination = AssetHubKusama::sibling_location_of(PenpalKusamaA::para_id()); + let beneficiary_id = PenpalKusamaAReceiver::get(); + let amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) + .into(); + + let system_para_test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: PenpalKusamaAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); + + system_para_test.set_assertion::(system_para_to_para_assets_assertions); + // TODO: Add assertions when Penpal is able to manage assets + system_para_test + .set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); + system_para_test.assert(); +} + +/// Reserve Transfers of a local asset from System Parachain to Parachain should work +#[test] +fn reserve_transfer_asset_from_system_para_to_para() { + // Force create asset from Relay Chain and mint assets for System Parachain's sender account + AssetHubKusama::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + AssetHubKusamaSender::get(), + ASSET_MIN_BALANCE * 1000000, + ); + + // Init values for System Parachain + let destination = AssetHubKusama::sibling_location_of(PenpalKusamaA::para_id()); + let beneficiary_id = PenpalKusamaAReceiver::get(); + let amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) + .into(); + + let system_para_test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: PenpalKusamaAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); + + system_para_test.set_assertion::(system_para_to_para_assets_assertions); + // TODO: Add assertions when Penpal is able to manage assets + system_para_test + .set_dispatchable::(system_para_to_para_reserve_transfer_assets); + system_para_test.assert(); +} diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs new file mode 100644 index 0000000000..5891b694c8 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs @@ -0,0 +1,195 @@ +// 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. + +use crate::*; + +/// Relay Chain should be able to execute `Transact` instructions in System Parachain +/// when `OriginKind::Superuser` and signer is `sudo` +#[test] +fn send_transact_sudo_from_relay_to_system_para_works() { + // Init tests variables + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = Kusama::child_location_of(AssetHubKusama::para_id()).into(); + let asset_owner: AccountId = AssetHubKusamaSender::get().into(); + let xcm = AssetHubKusama::force_create_asset_xcm( + OriginKind::Superuser, + ASSET_ID, + asset_owner.clone(), + true, + 1000, + ); + // Send XCM message from Relay Chain + Kusama::execute_with(|| { + assert_ok!(::XcmPallet::send( + root_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + Kusama::assert_xcm_pallet_sent(); + }); + + // Receive XCM message in Assets Parachain + AssetHubKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(1_019_445_000, 200_000))); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::Assets(pallet_assets::Event::ForceCreated { asset_id, owner }) => { + asset_id: *asset_id == ASSET_ID, + owner: *owner == asset_owner, + }, + ] + ); + + assert!(::Assets::asset_exists(ASSET_ID)); + }); +} + +/// Relay Chain shouldn't be able to execute `Transact` instructions in System Parachain +/// when `OriginKind::Native` +#[test] +fn send_transact_native_from_relay_to_system_para_fails() { + // Init tests variables + let signed_origin = ::RuntimeOrigin::signed(KusamaSender::get().into()); + let system_para_destination = Kusama::child_location_of(AssetHubKusama::para_id()).into(); + let asset_owner = AssetHubKusamaSender::get().into(); + let xcm = AssetHubKusama::force_create_asset_xcm( + OriginKind::Native, + ASSET_ID, + asset_owner, + true, + 1000, + ); + + // Send XCM message from Relay Chain + Kusama::execute_with(|| { + assert_err!( + ::XcmPallet::send( + signed_origin, + bx!(system_para_destination), + bx!(xcm) + ), + DispatchError::BadOrigin + ); + }); +} + +/// System Parachain shouldn't be able to execute `Transact` instructions in Relay Chain +/// when `OriginKind::Native` +#[test] +fn send_transact_native_from_system_para_to_relay_fails() { + // Init tests variables + let signed_origin = + ::RuntimeOrigin::signed(AssetHubKusamaSender::get().into()); + let relay_destination = AssetHubKusama::parent_location().into(); + let call = ::RuntimeCall::System(frame_system::Call::< + ::Runtime, + >::remark_with_event { + remark: vec![0, 1, 2, 3], + }) + .encode() + .into(); + let origin_kind = OriginKind::Native; + + let xcm = xcm_transact_unpaid_execution(call, origin_kind); + + // Send XCM message from Relay Chain + AssetHubKusama::execute_with(|| { + assert_err!( + ::PolkadotXcm::send( + signed_origin, + bx!(relay_destination), + bx!(xcm) + ), + DispatchError::BadOrigin + ); + }); +} + +/// Parachain should be able to send XCM paying its fee with sufficient asset +/// in the System Parachain +#[test] +fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() { + let para_sovereign_account = AssetHubKusama::sovereign_account_id_of( + AssetHubKusama::sibling_location_of(PenpalKusamaA::para_id()), + ); + + // Force create and mint assets for Parachain's sovereign account + AssetHubKusama::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + para_sovereign_account.clone(), + ASSET_MIN_BALANCE * 1000000000, + ); + + // We just need a call that can pass the `SafeCallFilter` + // Call values are not relevant + let call = AssetHubKusama::force_create_asset_call( + ASSET_ID, + para_sovereign_account.clone(), + true, + ASSET_MIN_BALANCE, + ); + + let origin_kind = OriginKind::SovereignAccount; + let fee_amount = ASSET_MIN_BALANCE * 1000000; + let native_asset = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount).into(); + + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = + PenpalKusamaA::sibling_location_of(AssetHubKusama::para_id()).into(); + let xcm = xcm_transact_paid_execution( + call, + origin_kind, + native_asset, + para_sovereign_account.clone(), + ); + + PenpalKusamaA::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + root_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + PenpalKusamaA::assert_xcm_pallet_sent(); + }); + + AssetHubKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubKusama::assert_xcmp_queue_success(Some(Weight::from_parts(2_176_414_000, 203_593))); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance }) => { + asset_id: *asset_id == ASSET_ID, + owner: *owner == para_sovereign_account, + balance: *balance == fee_amount, + }, + RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, .. }) => { + asset_id: *asset_id == ASSET_ID, + }, + ] + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/set_xcm_versions.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/set_xcm_versions.rs new file mode 100644 index 0000000000..a7af96096c --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/set_xcm_versions.rs @@ -0,0 +1,93 @@ +// 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. + +use crate::*; + +#[test] +fn relay_sets_system_para_xcm_supported_version() { + // Init tests variables + let sudo_origin = ::RuntimeOrigin::root(); + let system_para_destination: MultiLocation = + Kusama::child_location_of(AssetHubKusama::para_id()); + + // Relay Chain sets supported version for Asset Parachain + Kusama::execute_with(|| { + assert_ok!(::XcmPallet::force_xcm_version( + sudo_origin, + bx!(system_para_destination), + XCM_V3 + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Kusama, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3 + }) => { location: *location == system_para_destination, }, + ] + ); + }); +} + +#[test] +fn system_para_sets_relay_xcm_supported_version() { + // Init test variables + let sudo_origin = ::RuntimeOrigin::root(); + let parent_location = AssetHubKusama::parent_location(); + let system_para_destination: VersionedMultiLocation = + Kusama::child_location_of(AssetHubKusama::para_id()).into(); + let call = ::RuntimeCall::PolkadotXcm(pallet_xcm::Call::< + ::Runtime, + >::force_xcm_version { + location: bx!(parent_location), + version: XCM_V3, + }) + .encode() + .into(); + let origin_kind = OriginKind::Superuser; + + let xcm = xcm_transact_unpaid_execution(call, origin_kind); + + // System Parachain sets supported version for Relay Chain throught it + Kusama::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + Kusama::assert_xcm_pallet_sent(); + }); + + // System Parachain receive the XCM message + AssetHubKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(1_019_210_000, 200_000))); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3 + }) => { location: *location == parent_location, }, + ] + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/swap.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/swap.rs new file mode 100644 index 0000000000..3a67b54358 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/swap.rs @@ -0,0 +1,364 @@ +// 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. + +use crate::*; +use frame_support::{instances::Instance2, BoundedVec}; +use parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT; +use sp_runtime::{DispatchError, ModuleError}; + +#[test] +fn swap_locally_on_chain_using_local_assets() { + let asset_native = Box::new(asset_hub_kusama_runtime::xcm_config::KsmLocation::get()); + let asset_one = Box::new(MultiLocation { + parents: 0, + interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), + }); + + AssetHubKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_ok!(::Assets::create( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + ASSET_ID.into(), + AssetHubKusamaSender::get().into(), + 1000, + )); + assert!(::Assets::asset_exists(ASSET_ID)); + + assert_ok!(::Assets::mint( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + ASSET_ID.into(), + AssetHubKusamaSender::get().into(), + 100_000_000_000_000, + )); + + assert_ok!(::Balances::force_set_balance( + ::RuntimeOrigin::root(), + AssetHubKusamaSender::get().into(), + 100_000_000_000_000, + )); + + assert_ok!(::AssetConversion::create_pool( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + asset_native.clone(), + asset_one.clone(), + )); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {}, + ] + ); + + assert_ok!(::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + asset_native.clone(), + asset_one.clone(), + 1_000_000_000_000, + 2_000_000_000_000, + 0, + 0, + AssetHubKusamaSender::get().into() + )); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {lp_token_minted, .. }) => { lp_token_minted: *lp_token_minted == 1414213562273, }, + ] + ); + + let path = BoundedVec::<_, _>::truncate_from(vec![asset_native.clone(), asset_one.clone()]); + + assert_ok!( + ::AssetConversion::swap_exact_tokens_for_tokens( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + path, + 100, + 1, + AssetHubKusamaSender::get().into(), + true + ) + ); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. }) => { + amount_in: *amount_in == 100, + amount_out: *amount_out == 199, + }, + ] + ); + + assert_ok!(::AssetConversion::remove_liquidity( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + asset_native, + asset_one, + 1414213562273 - EXISTENTIAL_DEPOSIT * 2, // all but the 2 EDs can't be retrieved. + 0, + 0, + AssetHubKusamaSender::get().into(), + )); + }); +} + +#[test] +fn swap_locally_on_chain_using_foreign_assets() { + use frame_support::weights::WeightToFee; + + let asset_native = Box::new(asset_hub_kusama_runtime::xcm_config::KsmLocation::get()); + + let foreign_asset1_at_asset_hub_kusama = Box::new(MultiLocation { + parents: 1, + interior: X3( + Parachain(PenpalKusamaA::para_id().into()), + PalletInstance(ASSETS_PALLET_ID), + GeneralIndex(ASSET_ID.into()), + ), + }); + + let assets_para_destination: VersionedMultiLocation = + MultiLocation { parents: 1, interior: X1(Parachain(AssetHubKusama::para_id().into())) } + .into(); + + let penpal_location = + MultiLocation { parents: 1, interior: X1(Parachain(PenpalKusamaA::para_id().into())) }; + + // 1. Create asset on penpal: + PenpalKusamaA::execute_with(|| { + assert_ok!(::Assets::create( + ::RuntimeOrigin::signed(PenpalKusamaASender::get()), + ASSET_ID.into(), + PenpalKusamaASender::get().into(), + 1000, + )); + + assert!(::Assets::asset_exists(ASSET_ID)); + }); + + // 2. Create foreign asset on asset_hub_kusama: + + let require_weight_at_most = Weight::from_parts(1_100_000_000_000, 30_000); + let origin_kind = OriginKind::Xcm; + let sov_penpal_on_asset_hub_kusama = AssetHubKusama::sovereign_account_id_of(penpal_location); + + AssetHubKusama::fund_accounts(vec![ + (AssetHubKusamaSender::get().into(), 5_000_000 * KUSAMA_ED), /* An account to swap dot + * for something else. */ + (sov_penpal_on_asset_hub_kusama.clone().into(), 1000_000_000_000_000_000 * KUSAMA_ED), + ]); + + let sov_penpal_on_asset_hub_kusama_as_location: MultiLocation = MultiLocation { + parents: 0, + interior: X1(AccountId32Junction { + network: None, + id: sov_penpal_on_asset_hub_kusama.clone().into(), + }), + }; + + let call_foreign_assets_create = + ::RuntimeCall::ForeignAssets(pallet_assets::Call::< + ::Runtime, + Instance2, + >::create { + id: *foreign_asset1_at_asset_hub_kusama, + min_balance: 1000, + admin: sov_penpal_on_asset_hub_kusama.clone().into(), + }) + .encode() + .into(); + + let buy_execution_fee_amount = parachains_common::kusama::fee::WeightToFee::weight_to_fee( + &Weight::from_parts(10_100_000_000_000, 300_000), + ); + let buy_execution_fee = MultiAsset { + id: Concrete(MultiLocation { parents: 1, interior: Here }), + fun: Fungible(buy_execution_fee_amount), + }; + + let xcm = VersionedXcm::from(Xcm(vec![ + WithdrawAsset { 0: vec![buy_execution_fee.clone()].into() }, + BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited }, + Transact { require_weight_at_most, origin_kind, call: call_foreign_assets_create }, + RefundSurplus, + DepositAsset { + assets: All.into(), + beneficiary: sov_penpal_on_asset_hub_kusama_as_location, + }, + ])); + + // Send XCM message from penpal => asset_hub_kusama + let sudo_penpal_origin = ::RuntimeOrigin::root(); + PenpalKusamaA::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_penpal_origin.clone(), + bx!(assets_para_destination.clone()), + bx!(xcm), + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PenpalKusamaA, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubKusama::execute_with(|| { + assert!(::ForeignAssets::asset_exists( + *foreign_asset1_at_asset_hub_kusama + )); + + // 3: Mint foreign asset on asset_hub_kusama: + // + // (While it might be nice to use batch, + // currently that's disabled due to safe call filters.) + + type RuntimeEvent = ::RuntimeEvent; + // 3. Mint foreign asset (in reality this should be a teleport or some such) + assert_ok!(::ForeignAssets::mint( + ::RuntimeOrigin::signed( + sov_penpal_on_asset_hub_kusama.clone().into() + ), + *foreign_asset1_at_asset_hub_kusama, + sov_penpal_on_asset_hub_kusama.clone().into(), + 3_000_000_000_000, + )); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, + ] + ); + + // 4. Create pool: + assert_ok!(::AssetConversion::create_pool( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + asset_native.clone(), + foreign_asset1_at_asset_hub_kusama.clone(), + )); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {}, + ] + ); + + // 5. Add liquidity: + assert_ok!(::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed( + sov_penpal_on_asset_hub_kusama.clone() + ), + asset_native.clone(), + foreign_asset1_at_asset_hub_kusama.clone(), + 1_000_000_000_000, + 2_000_000_000_000, + 0, + 0, + sov_penpal_on_asset_hub_kusama.clone().into() + )); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {lp_token_minted, .. }) => { + lp_token_minted: *lp_token_minted == 1414213562273, + }, + ] + ); + + // 6. Swap! + let path = BoundedVec::<_, _>::truncate_from(vec![ + asset_native.clone(), + foreign_asset1_at_asset_hub_kusama.clone(), + ]); + + assert_ok!( + ::AssetConversion::swap_exact_tokens_for_tokens( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + path, + 100000, + 1000, + AssetHubKusamaSender::get().into(), + true + ) + ); + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. },) => { + amount_in: *amount_in == 100000, + amount_out: *amount_out == 199399, + }, + ] + ); + + // 7. Remove liquidity + assert_ok!(::AssetConversion::remove_liquidity( + ::RuntimeOrigin::signed( + sov_penpal_on_asset_hub_kusama.clone() + ), + asset_native, + foreign_asset1_at_asset_hub_kusama, + 1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved. + 0, + 0, + sov_penpal_on_asset_hub_kusama.clone().into(), + )); + }); +} + +#[test] +fn cannot_create_pool_from_pool_assets() { + let asset_native = Box::new(asset_hub_kusama_runtime::xcm_config::KsmLocation::get()); + let mut asset_one = asset_hub_kusama_runtime::xcm_config::PoolAssetsPalletLocation::get(); + asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); + + AssetHubKusama::execute_with(|| { + let pool_owner_account_id = asset_hub_kusama_runtime::AssetConversionOrigin::get(); + + assert_ok!(::PoolAssets::create( + ::RuntimeOrigin::signed(pool_owner_account_id.clone()), + ASSET_ID.into(), + pool_owner_account_id.clone().into(), + 1000, + )); + assert!(::PoolAssets::asset_exists(ASSET_ID)); + + assert_ok!(::PoolAssets::mint( + ::RuntimeOrigin::signed(pool_owner_account_id), + ASSET_ID.into(), + AssetHubKusamaSender::get().into(), + 3_000_000_000_000, + )); + + assert_matches::assert_matches!( + ::AssetConversion::create_pool( + ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), + asset_native.clone(), + Box::new(asset_one), + ), + Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("UnsupportedAsset")) + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs new file mode 100644 index 0000000000..f69878f354 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -0,0 +1,363 @@ +// 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. + +#![allow(dead_code)] // + +use crate::*; + +fn relay_origin_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + Kusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(631_531_000, 7_186))); + + assert_expected_events!( + Kusama, + vec![ + // Amount to teleport is withdrawn from Sender + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + // Amount to teleport is deposited in Relay's `CheckAccount` + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, amount }) => { + who: *who == ::XcmPallet::check_account(), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn relay_dest_assertions(t: SystemParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + + Kusama::assert_ump_queue_processed( + true, + Some(AssetHubKusama::para_id()), + Some(Weight::from_parts(307_225_000, 7_186)), + ); + + assert_expected_events!( + Kusama, + vec![ + // Amount is witdrawn from Relay Chain's `CheckAccount` + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == ::XcmPallet::check_account(), + amount: *amount == t.args.amount, + }, + // Amount minus fees are deposited in Receiver's account + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == t.receiver.account_id, + }, + ] + ); +} + +fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { + Kusama::assert_ump_queue_processed( + false, + Some(AssetHubKusama::para_id()), + Some(Weight::from_parts(148_433_000, 3_593)), + ); +} + +fn para_origin_assertions(t: SystemParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubKusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 534_872_000, + 7_133, + ))); + + AssetHubKusama::assert_parachain_system_ump_sent(); + + assert_expected_events!( + AssetHubKusama, + vec![ + // Amount is withdrawn from Sender's account + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn para_dest_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(165_592_000, 0))); + + assert_expected_events!( + AssetHubKusama, + vec![ + // Amount minus fees are deposited in Receiver's account + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == t.receiver.account_id, + }, + ] + ); +} + +fn relay_limited_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::limited_teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn relay_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged +// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { +// ::PolkadotXcm::teleport_assets( +// t.signed_origin, +// bx!(t.args.dest), +// bx!(t.args.beneficiary), +// bx!(t.args.assets), +// t.args.fee_asset_item, +// ) +// } + +/// Limited Teleport of native asset from Relay Chain to the System Parachain should work +#[test] +fn limited_teleport_native_assets_from_relay_to_system_para_works() { + // Init values for Relay Chain + let amount_to_send: Balance = KUSAMA_ED * 1000; + let test_args = TestContext { + sender: KusamaSender::get(), + receiver: AssetHubKusamaReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(para_dest_assertions); + test.set_dispatchable::(relay_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +/// Limited Teleport of native asset from System Parachain to Relay Chain +/// should work when there is enough balance in Relay Chain's `CheckAccount` +#[test] +fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { + // Dependency - Relay Chain's `CheckAccount` should have enough balance + limited_teleport_native_assets_from_relay_to_system_para_works(); + + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; + let destination = AssetHubKusama::parent_location(); + let beneficiary_id = KusamaReceiver::get(); + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: KusamaReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions); + test.set_dispatchable::(system_para_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +/// Limited Teleport of native asset from System Parachain to Relay Chain +/// should't work when there is not enough balance in Relay Chain's `CheckAccount` +#[test] +fn limited_teleport_native_assets_from_system_para_to_relay_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; + let destination = AssetHubKusama::parent_location().into(); + let beneficiary_id = KusamaReceiver::get().into(); + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: KusamaReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions_fail); + test.set_dispatchable::(system_para_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance does not change + assert_eq!(receiver_balance_after, receiver_balance_before); +} + +/// Teleport of native asset from Relay Chain to the System Parachain should work +#[test] +fn teleport_native_assets_from_relay_to_system_para_works() { + // Init values for Relay Chain + let amount_to_send: Balance = KUSAMA_ED * 1000; + let test_args = TestContext { + sender: KusamaSender::get(), + receiver: AssetHubKusamaReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(para_dest_assertions); + test.set_dispatchable::(relay_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged + +// Right now it is failing in the Relay Chain with a +// `messageQueue.ProcessingFailed` event `error: Unsupported`. +// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight` +// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier + +// /// Teleport of native asset from System Parachains to the Relay Chain +// /// should work when there is enough balance in Relay Chain's `CheckAccount` +// #[test] +// fn teleport_native_assets_back_from_system_para_to_relay_works() { +// // Dependency - Relay Chain's `CheckAccount` should have enough balance +// teleport_native_assets_from_relay_to_system_para_works(); + +// // Init values for Relay Chain +// let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; +// let test_args = TestContext { +// sender: AssetHubKusamaSender::get(), +// receiver: KusamaReceiver::get(), +// args: get_para_dispatch_args(amount_to_send), +// }; + +// let mut test = SystemParaToRelayTest::new(test_args); + +// let sender_balance_before = test.sender.balance; +// let receiver_balance_before = test.receiver.balance; + +// test.set_assertion::(para_origin_assertions); +// test.set_assertion::(relay_dest_assertions); +// test.set_dispatchable::(system_para_teleport_assets); +// test.assert(); + +// let sender_balance_after = test.sender.balance; +// let receiver_balance_after = test.receiver.balance; + +// // Sender's balance is reduced +// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); +// // Receiver's balance is increased +// assert!(receiver_balance_after > receiver_balance_before); +// } + +// /// Teleport of native asset from System Parachain to Relay Chain +// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` +// #[test] +// fn teleport_native_assets_from_system_para_to_relay_fails() { +// // Init values for Relay Chain +// let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; +// let assets = (Parent, amount_to_send).into(); +// +// let test_args = TestContext { +// sender: AssetHubKusamaSender::get(), +// receiver: KusamaReceiver::get(), +// args: system_para_test_args(amount_to_send), +// assets, +// None +// }; + +// let mut test = SystemParaToRelayTest::new(test_args); + +// let sender_balance_before = test.sender.balance; +// let receiver_balance_before = test.receiver.balance; + +// test.set_assertion::(para_origin_assertions); +// test.set_assertion::(relay_dest_assertions); +// test.set_dispatchable::(system_para_teleport_assets); +// test.assert(); + +// let sender_balance_after = test.sender.balance; +// let receiver_balance_after = test.receiver.balance; + +// // Sender's balance is reduced +// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); +// // Receiver's balance does not change +// assert_eq!(receiver_balance_after, receiver_balance_before); +// } diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml b/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml new file mode 100644 index 0000000000..bddf620556 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "asset-hub-polkadot-integration-tests" +version = "1.0.0" +authors.workspace = true +edition.workspace = true +license = "Apache-2.0" +description = "Asset Hub Polkadot runtime integration tests with xcm-emulator" +publish = false + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +sp-runtime = { default-features = false, version = "28.0.0" } +frame-support = { default-features = false, version = "25.0.0" } +frame-system = { default-features = false, version = "25.0.0" } +pallet-assets = { default-features = false, version = "26.0.0" } +pallet-balances = { default-features = false, version = "25.0.0" } +pallet-asset-conversion = { default-features = false, version = "7.0.0" } + +# Polkadot +polkadot-core-primitives = { default-features = false, version = "4.0.0" } +polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } +polkadot-runtime-parachains = { default-features = false, version = "4.0.0" } +xcm = { package = "staging-xcm", default-features = false, version = "4.0.0" } +pallet-xcm = { default-features = false, version = "4.0.0" } +#polkadot-runtime = { path = "../../../../relay/polkadot", default-features = false } + +# Cumulus +parachains-common = { default-features = false, version = "4.0.0" } +xcm-emulator = { default-features = false, version = "0.2.0" } +asset-hub-polkadot-runtime = { path = "../../../../system-parachains/asset-hubs/asset-hub-polkadot", default-features = false } + +# Local +integration-tests-common = { path = "../../common", default-features = false} diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs new file mode 100644 index 0000000000..e8ba8e44f2 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -0,0 +1,90 @@ +// 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. + +pub use codec::Encode; +pub use frame_support::{ + assert_err, assert_ok, + pallet_prelude::Weight, + sp_runtime::{AccountId32, DispatchError, DispatchResult}, + traits::fungibles::Inspect, +}; +pub use integration_tests_common::{ + constants::{ + asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, polkadot::ED as POLKADOT_ED, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + }, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, + PenpalPolkadotA, PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotB, + PenpalPolkadotBPallet, Polkadot, PolkadotPallet, PolkadotReceiver, PolkadotSender, +}; +pub use parachains_common::{AccountId, Balance}; +pub use xcm::{ + prelude::{AccountId32 as AccountId32Junction, *}, + v3::{Error, NetworkId::Polkadot as PolkadotId}, +}; +pub use xcm_emulator::{ + assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, +}; + +pub const ASSET_ID: u32 = 1; +pub const ASSET_MIN_BALANCE: u128 = 1000; +// `Assets` pallet index +pub const ASSETS_PALLET_ID: u8 = 50; + +pub type RelayToSystemParaTest = Test; +pub type SystemParaToRelayTest = Test; +pub type SystemParaToParaTest = Test; + +/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests +pub fn relay_test_args(amount: Balance) -> TestArgs { + TestArgs { + dest: Polkadot::child_location_of(AssetHubPolkadot::para_id()), + beneficiary: AccountId32Junction { + network: None, + id: AssetHubPolkadotReceiver::get().into(), + } + .into(), + amount, + assets: (Here, amount).into(), + asset_id: None, + fee_asset_item: 0, + weight_limit: WeightLimit::Unlimited, + } +} + +/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests +pub fn system_para_test_args( + dest: MultiLocation, + beneficiary_id: AccountId32, + amount: Balance, + assets: MultiAssets, + asset_id: Option, +) -> TestArgs { + TestArgs { + dest, + beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(), + amount, + assets, + asset_id, + fee_asset_item: 0, + weight_limit: WeightLimit::Unlimited, + } +} + +#[cfg(test)] +#[cfg(not(feature = "runtime-benchmarks"))] +mod tests; diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs new file mode 100644 index 0000000000..e5bce267b9 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs @@ -0,0 +1,192 @@ +// 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. + +use crate::*; + +const MAX_CAPACITY: u32 = 8; +const MAX_MESSAGE_SIZE: u32 = 8192; + +/// Opening HRMP channels between Parachains should work +#[test] +fn open_hrmp_channel_between_paras_works() { + // Parchain A init values + let para_a_id = PenpalPolkadotA::para_id(); + let para_a_root_origin = ::RuntimeOrigin::root(); + + // Parachain B init values + let para_b_id = PenpalPolkadotB::para_id(); + let para_b_root_origin = ::RuntimeOrigin::root(); + + let fee_amount = POLKADOT_ED * 1000; + let fund_amount = POLKADOT_ED * 1000_000_000; + + // Fund Parachain's Sovereign accounts to be able to reserve the deposit + let para_a_sovereign_account = Polkadot::fund_para_sovereign(fund_amount, para_a_id); + let para_b_sovereign_account = Polkadot::fund_para_sovereign(fund_amount, para_b_id); + + let relay_destination: VersionedMultiLocation = PenpalPolkadotA::parent_location().into(); + + // ---- Init Open channel from Parachain to System Parachain + let mut call = Polkadot::init_open_channel_call(para_b_id, MAX_CAPACITY, MAX_MESSAGE_SIZE); + let origin_kind = OriginKind::Native; + let native_asset: MultiAsset = (Here, fee_amount).into(); + let beneficiary = Polkadot::sovereign_account_id_of_child_para(para_a_id); + + let mut xcm = xcm_transact_paid_execution(call, origin_kind, native_asset.clone(), beneficiary); + + PenpalPolkadotA::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + para_a_root_origin, + bx!(relay_destination.clone()), + bx!(xcm), + )); + + PenpalPolkadotA::assert_xcm_pallet_sent(); + }); + + Polkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + Polkadot::assert_ump_queue_processed( + true, + Some(para_a_id), + Some(Weight::from_parts(1_282_426_000, 207_186)), + ); + + assert_expected_events!( + Polkadot, + vec![ + // Parachain's Sovereign account balance is withdrawn to pay XCM fees + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == para_a_sovereign_account.clone(), + amount: *amount == fee_amount, + }, + // Sender deposit is reserved for Parachain's Sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Reserved { who, .. }) =>{ + who: *who == para_a_sovereign_account, + }, + // Open channel requested from Para A to Para B + RuntimeEvent::Hrmp( + polkadot_runtime_parachains::hrmp::Event::OpenChannelRequested { + sender, recipient, proposed_max_capacity: max_capacity, proposed_max_message_size: max_message_size + } + ) => { + sender: *sender == para_a_id.into(), + recipient: *recipient == para_b_id.into(), + max_capacity: *max_capacity == MAX_CAPACITY, + max_message_size: *max_message_size == MAX_MESSAGE_SIZE, + }, + ] + ); + }); + + // ---- Accept Open channel from Parachain to System Parachain + call = Polkadot::accept_open_channel_call(para_a_id); + let beneficiary = Polkadot::sovereign_account_id_of_child_para(para_b_id); + + xcm = xcm_transact_paid_execution(call, origin_kind, native_asset, beneficiary); + + PenpalPolkadotB::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + para_b_root_origin, + bx!(relay_destination), + bx!(xcm), + )); + + PenpalPolkadotB::assert_xcm_pallet_sent(); + }); + + PenpalPolkadotB::execute_with(|| {}); + + Polkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + Polkadot::assert_ump_queue_processed( + true, + Some(para_b_id), + Some(Weight::from_parts(1_282_426_000, 207_186)), + ); + + assert_expected_events!( + Polkadot, + vec![ + // Parachain's Sovereign account balance is withdrawn to pay XCM fees + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == para_b_sovereign_account.clone(), + amount: *amount == fee_amount, + }, + // Sender deposit is reserved for Parachain's Sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Reserved { who, .. }) =>{ + who: *who == para_b_sovereign_account, + }, + // Open channel accepted for Para A to Para B + RuntimeEvent::Hrmp( + polkadot_runtime_parachains::hrmp::Event::OpenChannelAccepted { + sender, recipient + } + ) => { + sender: *sender == para_a_id.into(), + recipient: *recipient == para_b_id.into(), + }, + ] + ); + }); + + Polkadot::force_process_hrmp_open(para_a_id, para_b_id); +} + +/// Opening HRMP channels between System Parachains and Parachains should work +#[test] +fn force_open_hrmp_channel_for_system_para_works() { + // Relay Chain init values + let relay_root_origin = ::RuntimeOrigin::root(); + + // System Para init values + let system_para_id = AssetHubPolkadot::para_id(); + + // Parachain A init values + let para_a_id = PenpalPolkadotA::para_id(); + + Polkadot::execute_with(|| { + assert_ok!(::Hrmp::force_open_hrmp_channel( + relay_root_origin, + system_para_id, + para_a_id, + MAX_CAPACITY, + MAX_MESSAGE_SIZE + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Polkadot, + vec![ + // HRMP channel forced opened + RuntimeEvent::Hrmp( + polkadot_runtime_parachains::hrmp::Event::HrmpChannelForceOpened{ + sender, recipient, proposed_max_capacity: max_capacity, proposed_max_message_size: max_message_size + } + ) => { + sender: *sender == system_para_id.into(), + recipient: *recipient == para_a_id.into(), + max_capacity: *max_capacity == MAX_CAPACITY, + max_message_size: *max_message_size == MAX_MESSAGE_SIZE, + }, + ] + ); + }); + + Polkadot::force_process_hrmp_open(system_para_id, para_a_id); +} diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs new file mode 100644 index 0000000000..c22de4f1c3 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs @@ -0,0 +1,20 @@ +// 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. + +mod hrmp_channels; +mod reserve_transfer; +mod send; +mod set_xcm_versions; +mod teleport; diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs new file mode 100644 index 0000000000..e53693d85d --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs @@ -0,0 +1,414 @@ +// 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. + +use crate::*; + +fn relay_origin_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + Polkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(629_384_000, 6_196))); + + assert_expected_events!( + Polkadot, + vec![ + // Amount to reserve transfer is transferred to System Parachain's Sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount }) => { + from: *from == t.sender.account_id, + to: *to == Polkadot::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) { + AssetHubPolkadot::assert_dmp_queue_incomplete( + Some(Weight::from_parts(1_000_000_000, 0)), + Some(Error::UntrustedReserveLocation), + ); +} + +fn system_para_to_relay_assertions(_t: SystemParaToRelayTest) { + AssetHubPolkadot::assert_xcm_pallet_attempted_error(Some(XcmError::Barrier)) +} + +fn system_para_to_para_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubPolkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 676_119_000, + 6196, + ))); + + assert_expected_events!( + AssetHubPolkadot, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereing account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == AssetHubPolkadot::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubPolkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 676_119_000, + 6196, + ))); + + assert_expected_events!( + AssetHubPolkadot, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereing account + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount } + ) => { + asset_id: *asset_id == ASSET_ID, + from: *from == t.sender.account_id, + to: *to == AssetHubPolkadot::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn relay_limited_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn relay_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_limited_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn system_para_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +/// Limited Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't +/// work +#[test] +fn limited_reserve_transfer_native_asset_from_relay_to_system_para_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = POLKADOT_ED * 1000; + let test_args = TestContext { + sender: PolkadotSender::get(), + receiver: AssetHubPolkadotReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(system_para_dest_assertions_incomplete); + test.set_dispatchable::(relay_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Limited Reserve Transfers of native asset from System Parachain to Relay Chain shoudln't work +#[test] +fn limited_reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let destination = AssetHubPolkadot::parent_location(); + let beneficiary_id = PolkadotReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PolkadotReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_relay_assertions); + test.set_dispatchable::(system_para_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work +#[test] +fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = POLKADOT_ED * 1000; + let test_args = TestContext { + sender: PolkadotSender::get(), + receiver: AssetHubPolkadotReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(system_para_dest_assertions_incomplete); + test.set_dispatchable::(relay_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work +#[test] +fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let destination = AssetHubPolkadot::parent_location(); + let beneficiary_id = PolkadotReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PolkadotReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_relay_assertions); + test.set_dispatchable::(system_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Limited Reserve Transfers of native asset from System Parachain to Parachain should work +#[test] +fn limited_reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubPolkadot::sibling_location_of(PenpalPolkadotA::para_id()); + let beneficiary_id = PenpalPolkadotAReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PenpalPolkadotAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + + test.set_assertion::(system_para_to_para_assertions); + // TODO: Add assertion for Penpal runtime. Right now message is failing with + // `UntrustedReserveLocation` + test.set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve + // transfers +} + +/// Reserve Transfers of native asset from System Parachain to Parachain should work +#[test] +fn reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubPolkadot::sibling_location_of(PenpalPolkadotA::para_id()); + let beneficiary_id = PenpalPolkadotAReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PenpalPolkadotAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + + test.set_assertion::(system_para_to_para_assertions); + // TODO: Add assertion for Penpal runtime. Right now message is failing with + // `UntrustedReserveLocation` + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve + // transfers +} + +/// Limited Reserve Transfers of a local asset from System Parachain to Parachain should work +#[test] +fn limited_reserve_transfer_asset_from_system_para_to_para() { + // Force create asset from Relay Chain and mint assets for System Parachain's sender account + AssetHubPolkadot::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + AssetHubPolkadotSender::get(), + ASSET_MIN_BALANCE * 1000000, + ); + + // Init values for System Parachain + let destination = AssetHubPolkadot::sibling_location_of(PenpalPolkadotA::para_id()); + let beneficiary_id = PenpalPolkadotAReceiver::get(); + let amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) + .into(); + + let system_para_test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PenpalPolkadotAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); + + system_para_test.set_assertion::(system_para_to_para_assets_assertions); + // TODO: Add assertions when Penpal is able to manage assets + system_para_test + .set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); + system_para_test.assert(); +} + +/// Reserve Transfers of a local asset from System Parachain to Parachain should work +#[test] +fn reserve_transfer_asset_from_system_para_to_para() { + // Force create asset from Relay Chain and mint assets for System Parachain's sender account + AssetHubPolkadot::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + AssetHubPolkadotSender::get(), + ASSET_MIN_BALANCE * 1000000, + ); + + // Init values for System Parachain + let destination = AssetHubPolkadot::sibling_location_of(PenpalPolkadotA::para_id()); + let beneficiary_id = PenpalPolkadotAReceiver::get(); + let amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) + .into(); + + let system_para_test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PenpalPolkadotAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); + + system_para_test.set_assertion::(system_para_to_para_assets_assertions); + // TODO: Add assertions when Penpal is able to manage assets + system_para_test + .set_dispatchable::(system_para_to_para_reserve_transfer_assets); + system_para_test.assert(); +} diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs new file mode 100644 index 0000000000..244b428a75 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs @@ -0,0 +1,201 @@ +// 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. + +use crate::*; + +/// Relay Chain should be able to execute `Transact` instructions in System Parachain +/// when `OriginKind::Superuser` and signer is `sudo` +#[test] +fn send_transact_sudo_from_relay_to_system_para_works() { + // Init tests variables + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = Polkadot::child_location_of(AssetHubPolkadot::para_id()).into(); + let asset_owner: AccountId = AssetHubPolkadotSender::get().into(); + let xcm = AssetHubPolkadot::force_create_asset_xcm( + OriginKind::Superuser, + ASSET_ID, + asset_owner.clone(), + true, + 1000, + ); + // Send XCM message from Relay Chain + Polkadot::execute_with(|| { + assert_ok!(::XcmPallet::send( + root_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + Polkadot::assert_xcm_pallet_sent(); + }); + + // Receive XCM message in Assets Parachain + AssetHubPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubPolkadot::assert_dmp_queue_complete(Some(Weight::from_parts( + 1_019_445_000, + 200_000, + ))); + + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::Assets(pallet_assets::Event::ForceCreated { asset_id, owner }) => { + asset_id: *asset_id == ASSET_ID, + owner: *owner == asset_owner, + }, + ] + ); + + assert!(::Assets::asset_exists(ASSET_ID)); + }); +} + +/// Relay Chain shouldn't be able to execute `Transact` instructions in System Parachain +/// when `OriginKind::Native` +#[test] +fn send_transact_native_from_relay_to_system_para_fails() { + // Init tests variables + let signed_origin = ::RuntimeOrigin::signed(PolkadotSender::get().into()); + let system_para_destination = Polkadot::child_location_of(AssetHubPolkadot::para_id()).into(); + let asset_owner = AssetHubPolkadotSender::get().into(); + let xcm = AssetHubPolkadot::force_create_asset_xcm( + OriginKind::Native, + ASSET_ID, + asset_owner, + true, + 1000, + ); + + // Send XCM message from Relay Chain + Polkadot::execute_with(|| { + assert_err!( + ::XcmPallet::send( + signed_origin, + bx!(system_para_destination), + bx!(xcm) + ), + DispatchError::BadOrigin + ); + }); +} + +/// System Parachain shouldn't be able to execute `Transact` instructions in Relay Chain +/// when `OriginKind::Native` +#[test] +fn send_transact_native_from_system_para_to_relay_fails() { + // Init tests variables + let signed_origin = + ::RuntimeOrigin::signed(AssetHubPolkadotSender::get().into()); + let relay_destination = AssetHubPolkadot::parent_location().into(); + let call = ::RuntimeCall::System(frame_system::Call::< + ::Runtime, + >::remark_with_event { + remark: vec![0, 1, 2, 3], + }) + .encode() + .into(); + let origin_kind = OriginKind::Native; + + let xcm = xcm_transact_unpaid_execution(call, origin_kind); + + // Send XCM message from Relay Chain + AssetHubPolkadot::execute_with(|| { + assert_err!( + ::PolkadotXcm::send( + signed_origin, + bx!(relay_destination), + bx!(xcm) + ), + DispatchError::BadOrigin + ); + }); +} + +/// Parachain should be able to send XCM paying its fee with sufficient asset +/// in the System Parachain +#[test] +fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() { + let para_sovereign_account = AssetHubPolkadot::sovereign_account_id_of( + AssetHubPolkadot::sibling_location_of(PenpalPolkadotA::para_id()), + ); + + // Force create and mint assets for Parachain's sovereign account + AssetHubPolkadot::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + para_sovereign_account.clone(), + ASSET_MIN_BALANCE * 1000000000, + ); + + // We just need a call that can pass the `SafeCallFilter` + // Call values are not relevant + let call = AssetHubPolkadot::force_create_asset_call( + ASSET_ID, + para_sovereign_account.clone(), + true, + ASSET_MIN_BALANCE, + ); + + let origin_kind = OriginKind::SovereignAccount; + let fee_amount = ASSET_MIN_BALANCE * 1000000; + let native_asset = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount).into(); + + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = + PenpalPolkadotA::sibling_location_of(AssetHubPolkadot::para_id()).into(); + let xcm = xcm_transact_paid_execution( + call, + origin_kind, + native_asset, + para_sovereign_account.clone(), + ); + + PenpalPolkadotA::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + root_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + PenpalPolkadotA::assert_xcm_pallet_sent(); + }); + + AssetHubPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubPolkadot::assert_xcmp_queue_success(Some(Weight::from_parts( + 2_176_414_000, + 203_593, + ))); + + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance }) => { + asset_id: *asset_id == ASSET_ID, + owner: *owner == para_sovereign_account, + balance: *balance == fee_amount, + }, + RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, .. }) => { + asset_id: *asset_id == ASSET_ID, + }, + ] + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/set_xcm_versions.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/set_xcm_versions.rs new file mode 100644 index 0000000000..e121c41679 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/set_xcm_versions.rs @@ -0,0 +1,96 @@ +// 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. + +use crate::*; + +#[test] +fn relay_sets_system_para_xcm_supported_version() { + // Init tests variables + let sudo_origin = ::RuntimeOrigin::root(); + let system_para_destination: MultiLocation = + Polkadot::child_location_of(AssetHubPolkadot::para_id()); + + // Relay Chain sets supported version for Asset Parachain + Polkadot::execute_with(|| { + assert_ok!(::XcmPallet::force_xcm_version( + sudo_origin, + bx!(system_para_destination), + XCM_V3 + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3 + }) => { location: *location == system_para_destination, }, + ] + ); + }); +} + +#[test] +fn system_para_sets_relay_xcm_supported_version() { + // Init test variables + let sudo_origin = ::RuntimeOrigin::root(); + let parent_location = AssetHubPolkadot::parent_location(); + let system_para_destination: VersionedMultiLocation = + Polkadot::child_location_of(AssetHubPolkadot::para_id()).into(); + let call = ::RuntimeCall::PolkadotXcm(pallet_xcm::Call::< + ::Runtime, + >::force_xcm_version { + location: bx!(parent_location), + version: XCM_V3, + }) + .encode() + .into(); + let origin_kind = OriginKind::Superuser; + + let xcm = xcm_transact_unpaid_execution(call, origin_kind); + + // System Parachain sets supported version for Relay Chain throught it + Polkadot::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + Polkadot::assert_xcm_pallet_sent(); + }); + + // System Parachain receive the XCM message + AssetHubPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubPolkadot::assert_dmp_queue_complete(Some(Weight::from_parts( + 1_019_210_000, + 200_000, + ))); + + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3 + }) => { location: *location == parent_location, }, + ] + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs new file mode 100644 index 0000000000..644c51d75b --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -0,0 +1,363 @@ +// 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. + +#![allow(dead_code)] // + +use crate::*; + +fn relay_origin_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + Polkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(632_207_000, 7_186))); + + assert_expected_events!( + Polkadot, + vec![ + // Amount to teleport is withdrawn from Sender + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + // Amount to teleport is deposited in Relay's `CheckAccount` + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, amount }) => { + who: *who == ::XcmPallet::check_account(), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn relay_dest_assertions(t: SystemParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + + Polkadot::assert_ump_queue_processed( + true, + Some(AssetHubPolkadot::para_id()), + Some(Weight::from_parts(368_931_000, 7_186)), + ); + + assert_expected_events!( + Polkadot, + vec![ + // Amount is witdrawn from Relay Chain's `CheckAccount` + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == ::XcmPallet::check_account(), + amount: *amount == t.args.amount, + }, + // Amount minus fees are deposited in Receiver's account + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == t.receiver.account_id, + }, + ] + ); +} + +fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { + Polkadot::assert_ump_queue_processed( + false, + Some(AssetHubPolkadot::para_id()), + Some(Weight::from_parts(232_982_000, 3_593)), + ); +} + +fn para_origin_assertions(t: SystemParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubPolkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 632_207_000, + 7_186, + ))); + + AssetHubPolkadot::assert_parachain_system_ump_sent(); + + assert_expected_events!( + AssetHubPolkadot, + vec![ + // Amount is withdrawn from Sender's account + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn para_dest_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubPolkadot::assert_dmp_queue_complete(Some(Weight::from_parts(161_196_000, 0))); + + assert_expected_events!( + AssetHubPolkadot, + vec![ + // Amount minus fees are deposited in Receiver's account + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == t.receiver.account_id, + }, + ] + ); +} + +fn relay_limited_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::limited_teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn relay_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged +// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { +// ::PolkadotXcm::teleport_assets( +// t.signed_origin, +// bx!(t.args.dest), +// bx!(t.args.beneficiary), +// bx!(t.args.assets), +// t.args.fee_asset_item, +// ) +// } + +/// Limited Teleport of native asset from Relay Chain to the System Parachain should work +#[test] +fn limited_teleport_native_assets_from_relay_to_system_para_works() { + // Init values for Relay Chain + let amount_to_send: Balance = POLKADOT_ED * 1000; + let test_args = TestContext { + sender: PolkadotSender::get(), + receiver: AssetHubPolkadotReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(para_dest_assertions); + test.set_dispatchable::(relay_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +/// Limited Teleport of native asset from System Parachain to Relay Chain +/// should work when there is enough balance in Relay Chain's `CheckAccount` +#[test] +fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { + // Dependency - Relay Chain's `CheckAccount` should have enough balance + limited_teleport_native_assets_from_relay_to_system_para_works(); + + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; + let destination = AssetHubPolkadot::parent_location(); + let beneficiary_id = PolkadotReceiver::get(); + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PolkadotReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions); + test.set_dispatchable::(system_para_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +/// Limited Teleport of native asset from System Parachain to Relay Chain +/// should't work when there is not enough balance in Relay Chain's `CheckAccount` +#[test] +fn limited_teleport_native_assets_from_system_para_to_relay_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; + let destination = AssetHubPolkadot::parent_location().into(); + let beneficiary_id = PolkadotReceiver::get().into(); + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PolkadotReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions_fail); + test.set_dispatchable::(system_para_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance does not change + assert_eq!(receiver_balance_after, receiver_balance_before); +} + +/// Teleport of native asset from Relay Chain to the System Parachain should work +#[test] +fn teleport_native_assets_from_relay_to_system_para_works() { + // Init values for Relay Chain + let amount_to_send: Balance = POLKADOT_ED * 1000; + let test_args = TestContext { + sender: PolkadotSender::get(), + receiver: AssetHubPolkadotReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(para_dest_assertions); + test.set_dispatchable::(relay_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged + +// Right now it is failing in the Relay Chain with a +// `messageQueue.ProcessingFailed` event `error: Unsupported`. +// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight` +// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier + +// /// Teleport of native asset from System Parachains to the Relay Chain +// /// should work when there is enough balance in Relay Chain's `CheckAccount` +// #[test] +// fn teleport_native_assets_back_from_system_para_to_relay_works() { +// // Dependency - Relay Chain's `CheckAccount` should have enough balance +// teleport_native_assets_from_relay_to_system_para_works(); + +// // Init values for Relay Chain +// let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; +// let test_args = TestContext { +// sender: AssetHubPolkadotSender::get(), +// receiver: PolkadotReceiver::get(), +// args: get_para_dispatch_args(amount_to_send), +// }; + +// let mut test = SystemParaToRelayTest::new(test_args); + +// let sender_balance_before = test.sender.balance; +// let receiver_balance_before = test.receiver.balance; + +// test.set_assertion::(para_origin_assertions); +// test.set_assertion::(relay_dest_assertions); +// test.set_dispatchable::(system_para_teleport_assets); +// test.assert(); + +// let sender_balance_after = test.sender.balance; +// let receiver_balance_after = test.receiver.balance; + +// // Sender's balance is reduced +// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); +// // Receiver's balance is increased +// assert!(receiver_balance_after > receiver_balance_before); +// } + +// /// Teleport of native asset from System Parachain to Relay Chain +// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` +// #[test] +// fn teleport_native_assets_from_system_para_to_relay_fails() { +// // Init values for Relay Chain +// let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; +// let assets = (Parent, amount_to_send).into(); +// +// let test_args = TestContext { +// sender: AssetHubPolkadotSender::get(), +// receiver: PolkadotReceiver::get(), +// args: system_para_test_args(amount_to_send), +// assets, +// None +// }; + +// let mut test = SystemParaToRelayTest::new(test_args); + +// let sender_balance_before = test.sender.balance; +// let receiver_balance_before = test.receiver.balance; + +// test.set_assertion::(para_origin_assertions); +// test.set_assertion::(relay_dest_assertions); +// test.set_dispatchable::(system_para_teleport_assets); +// test.assert(); + +// let sender_balance_after = test.sender.balance; +// let receiver_balance_after = test.receiver.balance; + +// // Sender's balance is reduced +// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); +// // Receiver's balance does not change +// assert_eq!(receiver_balance_after, receiver_balance_before); +// } diff --git a/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml b/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml new file mode 100644 index 0000000000..80c41c24aa --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml @@ -0,0 +1,53 @@ +[package] +name = "asset-hub-westend-integration-tests" +version = "1.0.0" +authors.workspace = true +edition.workspace = true +license = "Apache-2.0" +description = "Asset Hub Westend runtime integration tests with xcm-emulator" +publish = false + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } +assert_matches = "1.5.0" + +# Substrate +sp-runtime = { path = "../../../../../../substrate/primitives/runtime", default-features = false} +frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} +frame-system = { path = "../../../../../../substrate/frame/system", default-features = false} +pallet-balances = { path = "../../../../../../substrate/frame/balances", default-features = false} +pallet-assets = { path = "../../../../../../substrate/frame/assets", default-features = false} +pallet-asset-conversion = { path = "../../../../../../substrate/frame/asset-conversion", default-features = false} + +# Polkadot +polkadot-core-primitives = { path = "../../../../../../polkadot/core-primitives", default-features = false} +polkadot-parachain-primitives = { path = "../../../../../../polkadot/parachain", default-features = false} +polkadot-runtime-parachains = { path = "../../../../../../polkadot/runtime/parachains" } +polkadot-runtime = { path = "../../../../../../polkadot/runtime/polkadot" } +xcm = { package = "staging-xcm", path = "../../../../../../polkadot/xcm", default-features = false} +pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-features = false} + +# Cumulus +parachains-common = { path = "../../../../common" } +asset-hub-westend-runtime = { path = "../../../../runtimes/assets/asset-hub-westend" } + +# Local +xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} +integration-tests-common = { path = "../../common", default-features = false} + +[features] +runtime-benchmarks = [ + "asset-hub-westend-runtime/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "integration-tests-common/runtime-benchmarks", + "pallet-asset-conversion/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "parachains-common/runtime-benchmarks", + "polkadot-parachain-primitives/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs new file mode 100644 index 0000000000..6e0f3434ae --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -0,0 +1,92 @@ +// 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. + +pub use codec::Encode; +pub use frame_support::{ + assert_err, assert_ok, + instances::Instance2, + pallet_prelude::Weight, + sp_runtime::{AccountId32, DispatchError, DispatchResult, ModuleError}, + traits::fungibles::Inspect, + BoundedVec, +}; +pub use integration_tests_common::{ + constants::{ + asset_hub_westend::ED as ASSET_HUB_WESTEND_ED, westend::ED as WESTEND_ED, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + }, + xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, + AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, + PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, + WestendPallet, WestendReceiver, WestendSender, +}; +pub use parachains_common::{AccountId, Balance}; +pub use xcm::{ + prelude::{AccountId32 as AccountId32Junction, *}, + v3::{Error, NetworkId::Westend as WestendId}, +}; +pub use xcm_emulator::{ + assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, + RelayChain as Relay, Test, TestArgs, TestContext, TestExt, +}; + +pub const ASSET_ID: u32 = 1; +pub const ASSET_MIN_BALANCE: u128 = 1000; +// `Assets` pallet index +pub const ASSETS_PALLET_ID: u8 = 50; + +pub type RelayToSystemParaTest = Test; +pub type SystemParaToRelayTest = Test; +pub type SystemParaToParaTest = Test; + +/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests +pub fn relay_test_args(amount: Balance) -> TestArgs { + TestArgs { + dest: Westend::child_location_of(AssetHubWestend::para_id()), + beneficiary: AccountId32Junction { + network: None, + id: AssetHubWestendReceiver::get().into(), + } + .into(), + amount, + assets: (Here, amount).into(), + asset_id: None, + fee_asset_item: 0, + weight_limit: WeightLimit::Unlimited, + } +} + +/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests +pub fn system_para_test_args( + dest: MultiLocation, + beneficiary_id: AccountId32, + amount: Balance, + assets: MultiAssets, + asset_id: Option, +) -> TestArgs { + TestArgs { + dest, + beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(), + amount, + assets, + asset_id, + fee_asset_item: 0, + weight_limit: WeightLimit::Unlimited, + } +} + +#[cfg(test)] +#[cfg(not(feature = "runtime-benchmarks"))] +mod tests; diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs new file mode 100644 index 0000000000..b3841af0e6 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs @@ -0,0 +1,20 @@ +// 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. + +mod reserve_transfer; +mod send; +mod set_xcm_versions; +mod swap; +mod teleport; diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs new file mode 100644 index 0000000000..51fac43be1 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs @@ -0,0 +1,414 @@ +// 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. + +use crate::*; + +fn relay_origin_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + Westend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(629_384_000, 6_196))); + + assert_expected_events!( + Westend, + vec![ + // Amount to reserve transfer is transferred to System Parachain's Sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount }) => { + from: *from == t.sender.account_id, + to: *to == Westend::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) { + AssetHubWestend::assert_dmp_queue_incomplete( + Some(Weight::from_parts(1_000_000_000, 0)), + Some(Error::UntrustedReserveLocation), + ); +} + +fn system_para_to_relay_assertions(_t: SystemParaToRelayTest) { + AssetHubWestend::assert_xcm_pallet_attempted_error(Some(XcmError::Barrier)) +} + +fn system_para_to_para_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubWestend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 676_119_000, + 6196, + ))); + + assert_expected_events!( + AssetHubWestend, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereing account + RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from, to, amount } + ) => { + from: *from == t.sender.account_id, + to: *to == AssetHubWestend::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubWestend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 676_119_000, + 6196, + ))); + + assert_expected_events!( + AssetHubWestend, + vec![ + // Amount to reserve transfer is transferred to Parachain's Sovereing account + RuntimeEvent::Assets( + pallet_assets::Event::Transferred { asset_id, from, to, amount } + ) => { + asset_id: *asset_id == ASSET_ID, + from: *from == t.sender.account_id, + to: *to == AssetHubWestend::sovereign_account_id_of( + t.args.dest + ), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn relay_limited_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn relay_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_limited_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn system_para_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::limited_reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { + ::PolkadotXcm::reserve_transfer_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +/// Limited Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't +/// work +#[test] +fn limited_reserve_transfer_native_asset_from_relay_to_system_para_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = WESTEND_ED * 1000; + let test_args = TestContext { + sender: WestendSender::get(), + receiver: AssetHubWestendReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(system_para_dest_assertions_incomplete); + test.set_dispatchable::(relay_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Limited Reserve Transfers of native asset from System Parachain to Relay Chain shoudln't work +#[test] +fn limited_reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let destination = AssetHubWestend::parent_location(); + let beneficiary_id = WestendReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: WestendReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_relay_assertions); + test.set_dispatchable::(system_para_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work +#[test] +fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = WESTEND_ED * 1000; + let test_args = TestContext { + sender: WestendSender::get(), + receiver: AssetHubWestendReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(system_para_dest_assertions_incomplete); + test.set_dispatchable::(relay_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work +#[test] +fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { + // Init values for System Parachain + let destination = AssetHubWestend::parent_location(); + let beneficiary_id = WestendReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: WestendReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(system_para_to_relay_assertions); + test.set_dispatchable::(system_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + assert_eq!(sender_balance_before, sender_balance_after); + assert_eq!(receiver_balance_before, receiver_balance_after); +} + +/// Limited Reserve Transfers of native asset from System Parachain to Parachain should work +#[test] +fn limited_reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()); + let beneficiary_id = PenpalWestendAReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: PenpalWestendAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + + test.set_assertion::(system_para_to_para_assertions); + // TODO: Add assertion for Penpal runtime. Right now message is failing with + // `UntrustedReserveLocation` + test.set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve + // transfers +} + +/// Reserve Transfers of native asset from System Parachain to Parachain should work +#[test] +fn reserve_transfer_native_asset_from_system_para_to_para() { + // Init values for System Parachain + let destination = AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()); + let beneficiary_id = PenpalWestendAReceiver::get(); + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: PenpalWestendAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + + test.set_assertion::(system_para_to_para_assertions); + // TODO: Add assertion for Penpal runtime. Right now message is failing with + // `UntrustedReserveLocation` + test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve + // transfers +} + +/// Limited Reserve Transfers of a local asset from System Parachain to Parachain should work +#[test] +fn limited_reserve_transfer_asset_from_system_para_to_para() { + // Force create asset from Relay Chain and mint assets for System Parachain's sender account + AssetHubWestend::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + AssetHubWestendSender::get(), + ASSET_MIN_BALANCE * 1000000, + ); + + // Init values for System Parachain + let destination = AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()); + let beneficiary_id = PenpalWestendAReceiver::get(); + let amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) + .into(); + + let system_para_test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: PenpalWestendAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); + + system_para_test.set_assertion::(system_para_to_para_assets_assertions); + // TODO: Add assertions when Penpal is able to manage assets + system_para_test + .set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); + system_para_test.assert(); +} + +/// Reserve Transfers of a local asset from System Parachain to Parachain should work +#[test] +fn reserve_transfer_asset_from_system_para_to_para() { + // Force create asset from Relay Chain and mint assets for System Parachain's sender account + AssetHubWestend::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + AssetHubWestendSender::get(), + ASSET_MIN_BALANCE * 1000000, + ); + + // Init values for System Parachain + let destination = AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()); + let beneficiary_id = PenpalWestendAReceiver::get(); + let amount_to_send = ASSET_MIN_BALANCE * 1000; + let assets = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) + .into(); + + let system_para_test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: PenpalWestendAReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); + + system_para_test.set_assertion::(system_para_to_para_assets_assertions); + // TODO: Add assertions when Penpal is able to manage assets + system_para_test + .set_dispatchable::(system_para_to_para_reserve_transfer_assets); + system_para_test.assert(); +} diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs new file mode 100644 index 0000000000..424d222bef --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs @@ -0,0 +1,140 @@ +// 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. + +use crate::*; + +/// Relay Chain should be able to execute `Transact` instructions in System Parachain +/// when `OriginKind::Superuser` and signer is `sudo` +#[test] +fn send_transact_sudo_from_relay_to_system_para_works() { + // Init tests variables + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = Westend::child_location_of(AssetHubWestend::para_id()).into(); + let asset_owner: AccountId = AssetHubWestendSender::get().into(); + let xcm = AssetHubWestend::force_create_asset_xcm( + OriginKind::Superuser, + ASSET_ID, + asset_owner.clone(), + true, + 1000, + ); + // Send XCM message from Relay Chain + Westend::execute_with(|| { + assert_ok!(::XcmPallet::send( + root_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + Westend::assert_xcm_pallet_sent(); + }); + + // Receive XCM message in Assets Parachain + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts( + 1_019_445_000, + 200_000, + ))); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::Assets(pallet_assets::Event::ForceCreated { asset_id, owner }) => { + asset_id: *asset_id == ASSET_ID, + owner: *owner == asset_owner, + }, + ] + ); + + assert!(::Assets::asset_exists(ASSET_ID)); + }); +} + +/// Parachain should be able to send XCM paying its fee with sufficient asset +/// in the System Parachain +#[test] +fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() { + let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()), + ); + + // Force create and mint assets for Parachain's sovereign account + AssetHubWestend::force_create_and_mint_asset( + ASSET_ID, + ASSET_MIN_BALANCE, + true, + para_sovereign_account.clone(), + ASSET_MIN_BALANCE * 1000000000, + ); + + // We just need a call that can pass the `SafeCallFilter` + // Call values are not relevant + let call = AssetHubWestend::force_create_asset_call( + ASSET_ID, + para_sovereign_account.clone(), + true, + ASSET_MIN_BALANCE, + ); + + let origin_kind = OriginKind::SovereignAccount; + let fee_amount = ASSET_MIN_BALANCE * 1000000; + let native_asset = + (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount).into(); + + let root_origin = ::RuntimeOrigin::root(); + let system_para_destination = + PenpalWestendA::sibling_location_of(AssetHubWestend::para_id()).into(); + let xcm = xcm_transact_paid_execution( + call, + origin_kind, + native_asset, + para_sovereign_account.clone(), + ); + + PenpalWestendA::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + root_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + PenpalWestendA::assert_xcm_pallet_sent(); + }); + + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubWestend::assert_xcmp_queue_success(Some(Weight::from_parts( + 2_176_414_000, + 203_593, + ))); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance }) => { + asset_id: *asset_id == ASSET_ID, + owner: *owner == para_sovereign_account, + balance: *balance == fee_amount, + }, + RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, .. }) => { + asset_id: *asset_id == ASSET_ID, + }, + ] + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/set_xcm_versions.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/set_xcm_versions.rs new file mode 100644 index 0000000000..2720095aac --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-westend/src/tests/set_xcm_versions.rs @@ -0,0 +1,96 @@ +// 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. + +use crate::*; + +#[test] +fn relay_sets_system_para_xcm_supported_version() { + // Init tests variables + let sudo_origin = ::RuntimeOrigin::root(); + let system_para_destination: MultiLocation = + Westend::child_location_of(AssetHubWestend::para_id()); + + // Relay Chain sets supported version for Asset Parachain + Westend::execute_with(|| { + assert_ok!(::XcmPallet::force_xcm_version( + sudo_origin, + bx!(system_para_destination), + XCM_V3 + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3 + }) => { location: *location == system_para_destination, }, + ] + ); + }); +} + +#[test] +fn system_para_sets_relay_xcm_supported_version() { + // Init test variables + let sudo_origin = ::RuntimeOrigin::root(); + let parent_location = AssetHubWestend::parent_location(); + let system_para_destination: VersionedMultiLocation = + Westend::child_location_of(AssetHubWestend::para_id()).into(); + let call = ::RuntimeCall::PolkadotXcm(pallet_xcm::Call::< + ::Runtime, + >::force_xcm_version { + location: bx!(parent_location), + version: XCM_V3, + }) + .encode() + .into(); + let origin_kind = OriginKind::Superuser; + + let xcm = xcm_transact_unpaid_execution(call, origin_kind); + + // System Parachain sets supported version for Relay Chain throught it + Westend::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + bx!(system_para_destination), + bx!(xcm), + )); + + Westend::assert_xcm_pallet_sent(); + }); + + // System Parachain receive the XCM message + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts( + 1_019_210_000, + 200_000, + ))); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged { + location, + version: XCM_V3 + }) => { location: *location == parent_location, }, + ] + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/swap.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/swap.rs new file mode 100644 index 0000000000..7d1615c9e2 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-westend/src/tests/swap.rs @@ -0,0 +1,350 @@ +// 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. + +use crate::*; + +#[test] +fn swap_locally_on_chain_using_local_assets() { + let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocation::get()); + let asset_one = Box::new(MultiLocation { + parents: 0, + interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), + }); + + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_ok!(::Assets::create( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 1000, + )); + assert!(::Assets::asset_exists(ASSET_ID)); + + assert_ok!(::Assets::mint( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 3_000_000_000_000, + )); + + assert_ok!(::AssetConversion::create_pool( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + asset_native.clone(), + asset_one.clone(), + )); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {}, + ] + ); + + assert_ok!(::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + asset_native.clone(), + asset_one.clone(), + 1_000_000_000_000, + 2_000_000_000_000, + 0, + 0, + AssetHubWestendSender::get().into() + )); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {lp_token_minted, .. }) => { lp_token_minted: *lp_token_minted == 1414213562273, }, + ] + ); + + let path = BoundedVec::<_, _>::truncate_from(vec![asset_native.clone(), asset_one.clone()]); + + assert_ok!(::AssetConversion::swap_exact_tokens_for_tokens( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + path, + 100, + 1, + AssetHubWestendSender::get().into(), + true + )); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. }) => { + amount_in: *amount_in == 100, + amount_out: *amount_out == 199, + }, + ] + ); + + assert_ok!(::AssetConversion::remove_liquidity( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + asset_native, + asset_one, + 1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved. + 0, + 0, + AssetHubWestendSender::get().into(), + )); + }); +} + +#[test] +fn swap_locally_on_chain_using_foreign_assets() { + use frame_support::weights::WeightToFee; + + let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocation::get()); + + let foreign_asset1_at_asset_hub_westend = Box::new(MultiLocation { + parents: 1, + interior: X3( + Parachain(PenpalWestendA::para_id().into()), + PalletInstance(ASSETS_PALLET_ID), + GeneralIndex(ASSET_ID.into()), + ), + }); + + let assets_para_destination: VersionedMultiLocation = + MultiLocation { parents: 1, interior: X1(Parachain(AssetHubWestend::para_id().into())) } + .into(); + + let penpal_location = + MultiLocation { parents: 1, interior: X1(Parachain(PenpalWestendA::para_id().into())) }; + + // 1. Create asset on penpal: + PenpalWestendA::execute_with(|| { + assert_ok!(::Assets::create( + ::RuntimeOrigin::signed(PenpalWestendASender::get()), + ASSET_ID.into(), + PenpalWestendASender::get().into(), + 1000, + )); + + assert!(::Assets::asset_exists(ASSET_ID)); + }); + + // 2. Create foreign asset on asset_hub_westend: + + let require_weight_at_most = Weight::from_parts(1_100_000_000_000, 30_000); + let origin_kind = OriginKind::Xcm; + let sov_penpal_on_asset_hub_westend = AssetHubWestend::sovereign_account_id_of(penpal_location); + + AssetHubWestend::fund_accounts(vec![ + (AssetHubWestendSender::get().into(), 5_000_000 * WESTEND_ED), + (sov_penpal_on_asset_hub_westend.clone().into(), 1000_000_000_000_000_000 * WESTEND_ED), + ]); + + let sov_penpal_on_asset_hub_westend_as_location: MultiLocation = MultiLocation { + parents: 0, + interior: X1(AccountId32Junction { + network: None, + id: sov_penpal_on_asset_hub_westend.clone().into(), + }), + }; + + let call_foreign_assets_create = + ::RuntimeCall::ForeignAssets(pallet_assets::Call::< + ::Runtime, + Instance2, + >::create { + id: *foreign_asset1_at_asset_hub_westend, + min_balance: 1000, + admin: sov_penpal_on_asset_hub_westend.clone().into(), + }) + .encode() + .into(); + + let buy_execution_fee_amount = parachains_common::westend::fee::WeightToFee::weight_to_fee( + &Weight::from_parts(10_100_000_000_000, 300_000), + ); + let buy_execution_fee = MultiAsset { + id: Concrete(MultiLocation { parents: 1, interior: Here }), + fun: Fungible(buy_execution_fee_amount), + }; + + let xcm = VersionedXcm::from(Xcm(vec![ + WithdrawAsset { 0: vec![buy_execution_fee.clone()].into() }, + BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited }, + Transact { require_weight_at_most, origin_kind, call: call_foreign_assets_create }, + RefundSurplus, + DepositAsset { + assets: All.into(), + beneficiary: sov_penpal_on_asset_hub_westend_as_location, + }, + ])); + + // Send XCM message from penpal => asset_hub_westend + let sudo_penpal_origin = ::RuntimeOrigin::root(); + PenpalWestendA::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_penpal_origin.clone(), + bx!(assets_para_destination.clone()), + bx!(xcm), + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PenpalWestendA, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubWestend::execute_with(|| { + assert!(::ForeignAssets::asset_exists( + *foreign_asset1_at_asset_hub_westend + )); + + // 3: Mint foreign asset on asset_hub_westend: + // + // (While it might be nice to use batch, + // currently that's disabled due to safe call filters.) + + type RuntimeEvent = ::RuntimeEvent; + // 3. Mint foreign asset (in reality this should be a teleport or some such) + assert_ok!(::ForeignAssets::mint( + ::RuntimeOrigin::signed( + sov_penpal_on_asset_hub_westend.clone().into() + ), + *foreign_asset1_at_asset_hub_westend, + sov_penpal_on_asset_hub_westend.clone().into(), + 3_000_000_000_000, + )); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, + ] + ); + + // 4. Create pool: + assert_ok!(::AssetConversion::create_pool( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + asset_native.clone(), + foreign_asset1_at_asset_hub_westend.clone(), + )); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {}, + ] + ); + + // 5. Add liquidity: + assert_ok!(::AssetConversion::add_liquidity( + ::RuntimeOrigin::signed( + sov_penpal_on_asset_hub_westend.clone() + ), + asset_native.clone(), + foreign_asset1_at_asset_hub_westend.clone(), + 1_000_000_000_000, + 2_000_000_000_000, + 0, + 0, + sov_penpal_on_asset_hub_westend.clone().into() + )); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {lp_token_minted, .. }) => { + lp_token_minted: *lp_token_minted == 1414213562273, + }, + ] + ); + + // 6. Swap! + let path = BoundedVec::<_, _>::truncate_from(vec![ + asset_native.clone(), + foreign_asset1_at_asset_hub_westend.clone(), + ]); + + assert_ok!(::AssetConversion::swap_exact_tokens_for_tokens( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + path, + 100000, + 1000, + AssetHubWestendSender::get().into(), + true + )); + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. },) => { + amount_in: *amount_in == 100000, + amount_out: *amount_out == 199399, + }, + ] + ); + + // 7. Remove liquidity + assert_ok!(::AssetConversion::remove_liquidity( + ::RuntimeOrigin::signed( + sov_penpal_on_asset_hub_westend.clone() + ), + asset_native, + foreign_asset1_at_asset_hub_westend, + 1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved. + 0, + 0, + sov_penpal_on_asset_hub_westend.clone().into(), + )); + }); +} + +#[test] +fn cannot_create_pool_from_pool_assets() { + let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocation::get()); + let mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocation::get(); + asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); + + AssetHubWestend::execute_with(|| { + let pool_owner_account_id = asset_hub_westend_runtime::AssetConversionOrigin::get(); + + assert_ok!(::PoolAssets::create( + ::RuntimeOrigin::signed(pool_owner_account_id.clone()), + ASSET_ID.into(), + pool_owner_account_id.clone().into(), + 1000, + )); + assert!(::PoolAssets::asset_exists(ASSET_ID)); + + assert_ok!(::PoolAssets::mint( + ::RuntimeOrigin::signed(pool_owner_account_id), + ASSET_ID.into(), + AssetHubWestendSender::get().into(), + 3_000_000_000_000, + )); + + assert_matches::assert_matches!( + ::AssetConversion::create_pool( + ::RuntimeOrigin::signed(AssetHubWestendSender::get()), + asset_native.clone(), + Box::new(asset_one), + ), + Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("UnsupportedAsset")) + ); + }); +} diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs new file mode 100644 index 0000000000..8de73a7420 --- /dev/null +++ b/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -0,0 +1,363 @@ +// 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. + +#![allow(dead_code)] // + +use crate::*; + +fn relay_origin_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + Westend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(632_207_000, 7_186))); + + assert_expected_events!( + Westend, + vec![ + // Amount to teleport is withdrawn from Sender + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + // Amount to teleport is deposited in Relay's `CheckAccount` + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, amount }) => { + who: *who == ::XcmPallet::check_account(), + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn relay_dest_assertions(t: SystemParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + + Westend::assert_ump_queue_processed( + true, + Some(AssetHubWestend::para_id()), + Some(Weight::from_parts(308_222_000, 7_186)), + ); + + assert_expected_events!( + Westend, + vec![ + // Amount is witdrawn from Relay Chain's `CheckAccount` + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == ::XcmPallet::check_account(), + amount: *amount == t.args.amount, + }, + // Amount minus fees are deposited in Receiver's account + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == t.receiver.account_id, + }, + ] + ); +} + +fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { + Westend::assert_ump_queue_processed( + false, + Some(AssetHubWestend::para_id()), + Some(Weight::from_parts(148_705_000, 3_593)), + ); +} + +fn para_origin_assertions(t: SystemParaToRelayTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubWestend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( + 533_910_000, + 7167, + ))); + + AssetHubWestend::assert_parachain_system_ump_sent(); + + assert_expected_events!( + AssetHubWestend, + vec![ + // Amount is withdrawn from Sender's account + RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { + who: *who == t.sender.account_id, + amount: *amount == t.args.amount, + }, + ] + ); +} + +fn para_dest_assertions(t: RelayToSystemParaTest) { + type RuntimeEvent = ::RuntimeEvent; + + AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts(164_733_000, 0))); + + assert_expected_events!( + AssetHubWestend, + vec![ + // Amount minus fees are deposited in Receiver's account + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == t.receiver.account_id, + }, + ] + ); +} + +fn relay_limited_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::limited_teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +fn relay_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { + ::XcmPallet::teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} + +fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::limited_teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + t.args.weight_limit, + ) +} + +// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged +// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { +// ::PolkadotXcm::teleport_assets( +// t.signed_origin, +// bx!(t.args.dest), +// bx!(t.args.beneficiary), +// bx!(t.args.assets), +// t.args.fee_asset_item, +// ) +// } + +/// Limited Teleport of native asset from Relay Chain to the System Parachain should work +#[test] +fn limited_teleport_native_assets_from_relay_to_system_para_works() { + // Init values for Relay Chain + let amount_to_send: Balance = WESTEND_ED * 1000; + let test_args = TestContext { + sender: WestendSender::get(), + receiver: AssetHubWestendReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(para_dest_assertions); + test.set_dispatchable::(relay_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +/// Limited Teleport of native asset from System Parachain to Relay Chain +/// should work when there is enough balance in Relay Chain's `CheckAccount` +#[test] +fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { + // Dependency - Relay Chain's `CheckAccount` should have enough balance + limited_teleport_native_assets_from_relay_to_system_para_works(); + + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let destination = AssetHubWestend::parent_location(); + let beneficiary_id = WestendReceiver::get(); + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: WestendReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions); + test.set_dispatchable::(system_para_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +/// Limited Teleport of native asset from System Parachain to Relay Chain +/// should't work when there is not enough balance in Relay Chain's `CheckAccount` +#[test] +fn limited_teleport_native_assets_from_system_para_to_relay_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; + let destination = AssetHubWestend::parent_location().into(); + let beneficiary_id = WestendReceiver::get().into(); + let assets = (Parent, amount_to_send).into(); + + let test_args = TestContext { + sender: AssetHubWestendSender::get(), + receiver: WestendReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions_fail); + test.set_dispatchable::(system_para_limited_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance does not change + assert_eq!(receiver_balance_after, receiver_balance_before); +} + +/// Teleport of native asset from Relay Chain to the System Parachain should work +#[test] +fn teleport_native_assets_from_relay_to_system_para_works() { + // Init values for Relay Chain + let amount_to_send: Balance = WESTEND_ED * 1000; + let test_args = TestContext { + sender: WestendSender::get(), + receiver: AssetHubWestendReceiver::get(), + args: relay_test_args(amount_to_send), + }; + + let mut test = RelayToSystemParaTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(relay_origin_assertions); + test.set_assertion::(para_dest_assertions); + test.set_dispatchable::(relay_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged + +// Right now it is failing in the Relay Chain with a +// `messageQueue.ProcessingFailed` event `error: Unsupported`. +// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight` +// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier + +// /// Teleport of native asset from System Parachains to the Relay Chain +// /// should work when there is enough balance in Relay Chain's `CheckAccount` +// #[test] +// fn teleport_native_assets_back_from_system_para_to_relay_works() { +// // Dependency - Relay Chain's `CheckAccount` should have enough balance +// teleport_native_assets_from_relay_to_system_para_works(); + +// // Init values for Relay Chain +// let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; +// let test_args = TestContext { +// sender: AssetHubWestendSender::get(), +// receiver: WestendReceiver::get(), +// args: get_para_dispatch_args(amount_to_send), +// }; + +// let mut test = SystemParaToRelayTest::new(test_args); + +// let sender_balance_before = test.sender.balance; +// let receiver_balance_before = test.receiver.balance; + +// test.set_assertion::(para_origin_assertions); +// test.set_assertion::(relay_dest_assertions); +// test.set_dispatchable::(system_para_teleport_assets); +// test.assert(); + +// let sender_balance_after = test.sender.balance; +// let receiver_balance_after = test.receiver.balance; + +// // Sender's balance is reduced +// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); +// // Receiver's balance is increased +// assert!(receiver_balance_after > receiver_balance_before); +// } + +// /// Teleport of native asset from System Parachain to Relay Chain +// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` +// #[test] +// fn teleport_native_assets_from_system_para_to_relay_fails() { +// // Init values for Relay Chain +// let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; +// let assets = (Parent, amount_to_send).into(); +// +// let test_args = TestContext { +// sender: AssetHubWestendSender::get(), +// receiver: WestendReceiver::get(), +// args: system_para_test_args(amount_to_send), +// assets, +// None +// }; + +// let mut test = SystemParaToRelayTest::new(test_args); + +// let sender_balance_before = test.sender.balance; +// let receiver_balance_before = test.receiver.balance; + +// test.set_assertion::(para_origin_assertions); +// test.set_assertion::(relay_dest_assertions); +// test.set_dispatchable::(system_para_teleport_assets); +// test.assert(); + +// let sender_balance_after = test.sender.balance; +// let receiver_balance_after = test.receiver.balance; + +// // Sender's balance is reduced +// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); +// // Receiver's balance does not change +// assert_eq!(receiver_balance_after, receiver_balance_before); +// } From 14b3fd11b3e10632a3349d3ad23af9f6cfc43603 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 8 Dec 2023 14:18:57 +0200 Subject: [PATCH 04/18] asset-hub-kusama tests pass --- .../asset-hub-kusama/src/tests/reserve_transfer.rs | 10 +++++----- .../assets/asset-hub-kusama/src/tests/send.rs | 2 +- .../assets/asset-hub-kusama/src/tests/teleport.rs | 14 +++++++------- integration-tests/emulated/common/src/impls.rs | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs index 645dca5035..4d06732f66 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs @@ -37,7 +37,7 @@ fn relay_origin_assertions(t: RelayToSystemParaTest) { fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) { AssetHubKusama::assert_dmp_queue_incomplete( - Some(Weight::from_parts(1_000_000_000, 0)), + None, Some(Error::UntrustedReserveLocation), ); } @@ -185,7 +185,7 @@ fn limited_reserve_transfer_native_asset_from_relay_to_system_para_fails() { let sender_balance_after = test.sender.balance; let receiver_balance_after = test.receiver.balance; - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); assert_eq!(receiver_balance_before, receiver_balance_after); } @@ -244,7 +244,7 @@ fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { let sender_balance_after = test.sender.balance; let receiver_balance_after = test.receiver.balance; - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); assert_eq!(receiver_balance_before, receiver_balance_after); } @@ -306,7 +306,7 @@ fn limited_reserve_transfer_native_asset_from_system_para_to_para() { let sender_balance_after = test.sender.balance; - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve // transfers } @@ -338,7 +338,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() { let sender_balance_after = test.sender.balance; - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve // transfers } diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs index 5891b694c8..4256ca087e 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs @@ -176,7 +176,7 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() { AssetHubKusama::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; - AssetHubKusama::assert_xcmp_queue_success(Some(Weight::from_parts(2_176_414_000, 203_593))); + AssetHubKusama::assert_xcmp_queue_success(None); assert_expected_events!( AssetHubKusama, diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs index f69878f354..dd6be04f44 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -97,7 +97,7 @@ fn para_origin_assertions(t: SystemParaToRelayTest) { fn para_dest_assertions(t: RelayToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; - AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(165_592_000, 0))); + AssetHubKusama::assert_dmp_queue_complete(None); assert_expected_events!( AssetHubKusama, @@ -178,7 +178,7 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let receiver_balance_after = test.receiver.balance; // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // Receiver's balance is increased assert!(receiver_balance_after > receiver_balance_before); } @@ -216,13 +216,13 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let receiver_balance_after = test.receiver.balance; // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // Receiver's balance is increased assert!(receiver_balance_after > receiver_balance_before); } /// Limited Teleport of native asset from System Parachain to Relay Chain -/// should't work when there is not enough balance in Relay Chain's `CheckAccount` +/// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` #[test] fn limited_teleport_native_assets_from_system_para_to_relay_fails() { // Init values for Relay Chain @@ -250,8 +250,8 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let sender_balance_after = test.sender.balance; let receiver_balance_after = test.receiver.balance; - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + // Sender's balance is reduced by amount to send (+ delivery fees) + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // Receiver's balance does not change assert_eq!(receiver_balance_after, receiver_balance_before); } @@ -281,7 +281,7 @@ fn teleport_native_assets_from_relay_to_system_para_works() { let receiver_balance_after = test.receiver.balance; // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // Receiver's balance is increased assert!(receiver_balance_after > receiver_balance_before); } diff --git a/integration-tests/emulated/common/src/impls.rs b/integration-tests/emulated/common/src/impls.rs index 0a8acb8e7c..bcc5552f19 100644 --- a/integration-tests/emulated/common/src/impls.rs +++ b/integration-tests/emulated/common/src/impls.rs @@ -329,7 +329,7 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { // Force process HRMP open channel requests without waiting for the next session $crate::impls::assert_ok!(]>::Hrmp::force_process_hrmp_open( relay_root_origin, - 0 + u32::MAX, )); let channel_id = $crate::impls::HrmpChannelId { sender, recipient }; @@ -338,7 +338,7 @@ macro_rules! impl_hrmp_channels_helpers_for_relay_chain { ::Runtime, >::contains_key(&channel_id); - // Check the HRMP channel has been successfully registrered + // Check the HRMP channel has been successfully registered assert!(hrmp_channel_exist) }); } From 40909857c5262808bc89d64b43bab34cc4e8c961 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 8 Dec 2023 14:34:35 +0200 Subject: [PATCH 05/18] asset-hub-polkadot tests passing --- Cargo.lock | 21 +++++++++++++++++ Cargo.toml | 2 +- .../assets/asset-hub-kusama/Cargo.toml | 1 - .../assets/asset-hub-polkadot/Cargo.toml | 23 ++++++++++++++++--- .../src/tests/hrmp_channels.rs | 4 +--- .../src/tests/reserve_transfer.rs | 10 ++++---- .../asset-hub-polkadot/src/tests/send.rs | 5 +--- .../asset-hub-polkadot/src/tests/teleport.rs | 10 ++++---- 8 files changed, 54 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 874857f293..57a5363497 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -627,6 +627,27 @@ dependencies = [ "substrate-wasm-builder", ] +[[package]] +name = "asset-hub-polkadot-integration-tests" +version = "1.0.0" +dependencies = [ + "frame-support", + "frame-system", + "integration-tests-common", + "pallet-asset-conversion", + "pallet-assets", + "pallet-balances", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain-primitives", + "polkadot-runtime-parachains", + "sp-runtime", + "staging-xcm", + "xcm-emulator", +] + [[package]] name = "asset-hub-polkadot-runtime" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 1873c213a0..92e05dd8c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ members = [ "system-parachains/gluttons/glutton-kusama", "integration-tests/emulated/common", "integration-tests/emulated/assets/asset-hub-kusama", -# "integration-tests/emulated/assets/asset-hub-polkadot", + "integration-tests/emulated/assets/asset-hub-polkadot", ] [profile.release] diff --git a/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml b/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml index d0f050c1e4..5560ecc954 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml +++ b/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml @@ -25,7 +25,6 @@ polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } polkadot-runtime-parachains = { default-features = false, version = "4.0.0" } xcm = { package = "staging-xcm", default-features = false, version = "4.0.0" } pallet-xcm = { default-features = false, version = "4.0.0" } -#staging-kusama-runtime = { path = "../../../../relay/kusama", default-features = false } # Cumulus parachains-common = { default-features = false, version = "4.0.0" } diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml b/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml index bddf620556..8348fa831a 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml +++ b/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml @@ -24,12 +24,29 @@ polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } polkadot-runtime-parachains = { default-features = false, version = "4.0.0" } xcm = { package = "staging-xcm", default-features = false, version = "4.0.0" } pallet-xcm = { default-features = false, version = "4.0.0" } -#polkadot-runtime = { path = "../../../../relay/polkadot", default-features = false } # Cumulus parachains-common = { default-features = false, version = "4.0.0" } -xcm-emulator = { default-features = false, version = "0.2.0" } -asset-hub-polkadot-runtime = { path = "../../../../system-parachains/asset-hubs/asset-hub-polkadot", default-features = false } +xcm-emulator = { version = "0.2.0" } # Local integration-tests-common = { path = "../../common", default-features = false} + +[features] +default = [ "std" ] + +std = [ + "sp-runtime/std", + "frame-support/std", + "frame-system/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-asset-conversion/std", + "polkadot-core-primitives/std", + "polkadot-parachain-primitives/std", + "polkadot-runtime-parachains/std", + "xcm/std", + "pallet-xcm/std", + "parachains-common/std", + "integration-tests-common/std", +] diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs index e5bce267b9..ebe48a41b7 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs @@ -175,7 +175,7 @@ fn force_open_hrmp_channel_for_system_para_works() { vec![ // HRMP channel forced opened RuntimeEvent::Hrmp( - polkadot_runtime_parachains::hrmp::Event::HrmpChannelForceOpened{ + polkadot_runtime_parachains::hrmp::Event::HrmpChannelForceOpened { sender, recipient, proposed_max_capacity: max_capacity, proposed_max_message_size: max_message_size } ) => { @@ -187,6 +187,4 @@ fn force_open_hrmp_channel_for_system_para_works() { ] ); }); - - Polkadot::force_process_hrmp_open(system_para_id, para_a_id); } diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs index e53693d85d..e0c13f4315 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs @@ -37,7 +37,7 @@ fn relay_origin_assertions(t: RelayToSystemParaTest) { fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) { AssetHubPolkadot::assert_dmp_queue_incomplete( - Some(Weight::from_parts(1_000_000_000, 0)), + None, Some(Error::UntrustedReserveLocation), ); } @@ -185,7 +185,7 @@ fn limited_reserve_transfer_native_asset_from_relay_to_system_para_fails() { let sender_balance_after = test.sender.balance; let receiver_balance_after = test.receiver.balance; - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); assert_eq!(receiver_balance_before, receiver_balance_after); } @@ -244,7 +244,7 @@ fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { let sender_balance_after = test.sender.balance; let receiver_balance_after = test.receiver.balance; - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); assert_eq!(receiver_balance_before, receiver_balance_after); } @@ -306,7 +306,7 @@ fn limited_reserve_transfer_native_asset_from_system_para_to_para() { let sender_balance_after = test.sender.balance; - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve // transfers } @@ -338,7 +338,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() { let sender_balance_after = test.sender.balance; - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve // transfers } diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs index 244b428a75..1ede54a4d3 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs @@ -179,10 +179,7 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() { AssetHubPolkadot::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; - AssetHubPolkadot::assert_xcmp_queue_success(Some(Weight::from_parts( - 2_176_414_000, - 203_593, - ))); + AssetHubPolkadot::assert_xcmp_queue_success(None); assert_expected_events!( AssetHubPolkadot, diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs index 644c51d75b..40f6ba0f1d 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -97,7 +97,7 @@ fn para_origin_assertions(t: SystemParaToRelayTest) { fn para_dest_assertions(t: RelayToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; - AssetHubPolkadot::assert_dmp_queue_complete(Some(Weight::from_parts(161_196_000, 0))); + AssetHubPolkadot::assert_dmp_queue_complete(None); assert_expected_events!( AssetHubPolkadot, @@ -178,7 +178,7 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let receiver_balance_after = test.receiver.balance; // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // Receiver's balance is increased assert!(receiver_balance_after > receiver_balance_before); } @@ -216,7 +216,7 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let receiver_balance_after = test.receiver.balance; // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // Receiver's balance is increased assert!(receiver_balance_after > receiver_balance_before); } @@ -251,7 +251,7 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let receiver_balance_after = test.receiver.balance; // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // Receiver's balance does not change assert_eq!(receiver_balance_after, receiver_balance_before); } @@ -281,7 +281,7 @@ fn teleport_native_assets_from_relay_to_system_para_works() { let receiver_balance_after = test.receiver.balance; // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); + assert!(sender_balance_before - amount_to_send >= sender_balance_after); // Receiver's balance is increased assert!(receiver_balance_after > receiver_balance_before); } From 4bce94482fa3a8ed3ccbf8000b6cb65d1173e9f0 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 8 Dec 2023 14:45:33 +0200 Subject: [PATCH 06/18] remove westend tests --- .../assets/asset-hub-westend/Cargo.toml | 53 --- .../assets/asset-hub-westend/src/lib.rs | 92 ---- .../assets/asset-hub-westend/src/tests/mod.rs | 20 - .../src/tests/reserve_transfer.rs | 414 ------------------ .../asset-hub-westend/src/tests/send.rs | 140 ------ .../src/tests/set_xcm_versions.rs | 96 ---- .../asset-hub-westend/src/tests/swap.rs | 350 --------------- .../asset-hub-westend/src/tests/teleport.rs | 363 --------------- 8 files changed, 1528 deletions(-) delete mode 100644 integration-tests/emulated/assets/asset-hub-westend/Cargo.toml delete mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/lib.rs delete mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs delete mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs delete mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs delete mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/set_xcm_versions.rs delete mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/swap.rs delete mode 100644 integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs diff --git a/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml b/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml deleted file mode 100644 index 80c41c24aa..0000000000 --- a/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml +++ /dev/null @@ -1,53 +0,0 @@ -[package] -name = "asset-hub-westend-integration-tests" -version = "1.0.0" -authors.workspace = true -edition.workspace = true -license = "Apache-2.0" -description = "Asset Hub Westend runtime integration tests with xcm-emulator" -publish = false - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } -assert_matches = "1.5.0" - -# Substrate -sp-runtime = { path = "../../../../../../substrate/primitives/runtime", default-features = false} -frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} -frame-system = { path = "../../../../../../substrate/frame/system", default-features = false} -pallet-balances = { path = "../../../../../../substrate/frame/balances", default-features = false} -pallet-assets = { path = "../../../../../../substrate/frame/assets", default-features = false} -pallet-asset-conversion = { path = "../../../../../../substrate/frame/asset-conversion", default-features = false} - -# Polkadot -polkadot-core-primitives = { path = "../../../../../../polkadot/core-primitives", default-features = false} -polkadot-parachain-primitives = { path = "../../../../../../polkadot/parachain", default-features = false} -polkadot-runtime-parachains = { path = "../../../../../../polkadot/runtime/parachains" } -polkadot-runtime = { path = "../../../../../../polkadot/runtime/polkadot" } -xcm = { package = "staging-xcm", path = "../../../../../../polkadot/xcm", default-features = false} -pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-features = false} - -# Cumulus -parachains-common = { path = "../../../../common" } -asset-hub-westend-runtime = { path = "../../../../runtimes/assets/asset-hub-westend" } - -# Local -xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} -integration-tests-common = { path = "../../common", default-features = false} - -[features] -runtime-benchmarks = [ - "asset-hub-westend-runtime/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "integration-tests-common/runtime-benchmarks", - "pallet-asset-conversion/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "parachains-common/runtime-benchmarks", - "polkadot-parachain-primitives/runtime-benchmarks", - "polkadot-runtime-parachains/runtime-benchmarks", - "polkadot-runtime/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", -] diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs deleted file mode 100644 index 6e0f3434ae..0000000000 --- a/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ /dev/null @@ -1,92 +0,0 @@ -// 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. - -pub use codec::Encode; -pub use frame_support::{ - assert_err, assert_ok, - instances::Instance2, - pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult, ModuleError}, - traits::fungibles::Inspect, - BoundedVec, -}; -pub use integration_tests_common::{ - constants::{ - asset_hub_westend::ED as ASSET_HUB_WESTEND_ED, westend::ED as WESTEND_ED, - PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, - }, - xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, - PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, - WestendPallet, WestendReceiver, WestendSender, -}; -pub use parachains_common::{AccountId, Balance}; -pub use xcm::{ - prelude::{AccountId32 as AccountId32Junction, *}, - v3::{Error, NetworkId::Westend as WestendId}, -}; -pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, - RelayChain as Relay, Test, TestArgs, TestContext, TestExt, -}; - -pub const ASSET_ID: u32 = 1; -pub const ASSET_MIN_BALANCE: u128 = 1000; -// `Assets` pallet index -pub const ASSETS_PALLET_ID: u8 = 50; - -pub type RelayToSystemParaTest = Test; -pub type SystemParaToRelayTest = Test; -pub type SystemParaToParaTest = Test; - -/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests -pub fn relay_test_args(amount: Balance) -> TestArgs { - TestArgs { - dest: Westend::child_location_of(AssetHubWestend::para_id()), - beneficiary: AccountId32Junction { - network: None, - id: AssetHubWestendReceiver::get().into(), - } - .into(), - amount, - assets: (Here, amount).into(), - asset_id: None, - fee_asset_item: 0, - weight_limit: WeightLimit::Unlimited, - } -} - -/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests -pub fn system_para_test_args( - dest: MultiLocation, - beneficiary_id: AccountId32, - amount: Balance, - assets: MultiAssets, - asset_id: Option, -) -> TestArgs { - TestArgs { - dest, - beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(), - amount, - assets, - asset_id, - fee_asset_item: 0, - weight_limit: WeightLimit::Unlimited, - } -} - -#[cfg(test)] -#[cfg(not(feature = "runtime-benchmarks"))] -mod tests; diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs deleted file mode 100644 index b3841af0e6..0000000000 --- a/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -mod reserve_transfer; -mod send; -mod set_xcm_versions; -mod swap; -mod teleport; diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs deleted file mode 100644 index 51fac43be1..0000000000 --- a/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs +++ /dev/null @@ -1,414 +0,0 @@ -// 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. - -use crate::*; - -fn relay_origin_assertions(t: RelayToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - Westend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(629_384_000, 6_196))); - - assert_expected_events!( - Westend, - vec![ - // Amount to reserve transfer is transferred to System Parachain's Sovereign account - RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount }) => { - from: *from == t.sender.account_id, - to: *to == Westend::sovereign_account_id_of( - t.args.dest - ), - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) { - AssetHubWestend::assert_dmp_queue_incomplete( - Some(Weight::from_parts(1_000_000_000, 0)), - Some(Error::UntrustedReserveLocation), - ); -} - -fn system_para_to_relay_assertions(_t: SystemParaToRelayTest) { - AssetHubWestend::assert_xcm_pallet_attempted_error(Some(XcmError::Barrier)) -} - -fn system_para_to_para_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubWestend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 676_119_000, - 6196, - ))); - - assert_expected_events!( - AssetHubWestend, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereing account - RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from, to, amount } - ) => { - from: *from == t.sender.account_id, - to: *to == AssetHubWestend::sovereign_account_id_of( - t.args.dest - ), - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubWestend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 676_119_000, - 6196, - ))); - - assert_expected_events!( - AssetHubWestend, - vec![ - // Amount to reserve transfer is transferred to Parachain's Sovereing account - RuntimeEvent::Assets( - pallet_assets::Event::Transferred { asset_id, from, to, amount } - ) => { - asset_id: *asset_id == ASSET_ID, - from: *from == t.sender.account_id, - to: *to == AssetHubWestend::sovereign_account_id_of( - t.args.dest - ), - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn relay_limited_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -fn relay_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - -fn system_para_limited_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -fn system_para_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - -fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - ::PolkadotXcm::limited_reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - ::PolkadotXcm::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - -/// Limited Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't -/// work -#[test] -fn limited_reserve_transfer_native_asset_from_relay_to_system_para_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = WESTEND_ED * 1000; - let test_args = TestContext { - sender: WestendSender::get(), - receiver: AssetHubWestendReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(system_para_dest_assertions_incomplete); - test.set_dispatchable::(relay_limited_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - assert_eq!(receiver_balance_before, receiver_balance_after); -} - -/// Limited Reserve Transfers of native asset from System Parachain to Relay Chain shoudln't work -#[test] -fn limited_reserve_transfer_native_asset_from_system_para_to_relay_fails() { - // Init values for System Parachain - let destination = AssetHubWestend::parent_location(); - let beneficiary_id = WestendReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: WestendReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(system_para_to_relay_assertions); - test.set_dispatchable::(system_para_limited_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - assert_eq!(sender_balance_before, sender_balance_after); - assert_eq!(receiver_balance_before, receiver_balance_after); -} - -/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work -#[test] -fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = WESTEND_ED * 1000; - let test_args = TestContext { - sender: WestendSender::get(), - receiver: AssetHubWestendReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(system_para_dest_assertions_incomplete); - test.set_dispatchable::(relay_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - assert_eq!(receiver_balance_before, receiver_balance_after); -} - -/// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work -#[test] -fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { - // Init values for System Parachain - let destination = AssetHubWestend::parent_location(); - let beneficiary_id = WestendReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: WestendReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(system_para_to_relay_assertions); - test.set_dispatchable::(system_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - assert_eq!(sender_balance_before, sender_balance_after); - assert_eq!(receiver_balance_before, receiver_balance_after); -} - -/// Limited Reserve Transfers of native asset from System Parachain to Parachain should work -#[test] -fn limited_reserve_transfer_native_asset_from_system_para_to_para() { - // Init values for System Parachain - let destination = AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()); - let beneficiary_id = PenpalWestendAReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: PenpalWestendAReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - - test.set_assertion::(system_para_to_para_assertions); - // TODO: Add assertion for Penpal runtime. Right now message is failing with - // `UntrustedReserveLocation` - test.set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve - // transfers -} - -/// Reserve Transfers of native asset from System Parachain to Parachain should work -#[test] -fn reserve_transfer_native_asset_from_system_para_to_para() { - // Init values for System Parachain - let destination = AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()); - let beneficiary_id = PenpalWestendAReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: PenpalWestendAReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - - test.set_assertion::(system_para_to_para_assertions); - // TODO: Add assertion for Penpal runtime. Right now message is failing with - // `UntrustedReserveLocation` - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve - // transfers -} - -/// Limited Reserve Transfers of a local asset from System Parachain to Parachain should work -#[test] -fn limited_reserve_transfer_asset_from_system_para_to_para() { - // Force create asset from Relay Chain and mint assets for System Parachain's sender account - AssetHubWestend::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - AssetHubWestendSender::get(), - ASSET_MIN_BALANCE * 1000000, - ); - - // Init values for System Parachain - let destination = AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()); - let beneficiary_id = PenpalWestendAReceiver::get(); - let amount_to_send = ASSET_MIN_BALANCE * 1000; - let assets = - (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) - .into(); - - let system_para_test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: PenpalWestendAReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); - - system_para_test.set_assertion::(system_para_to_para_assets_assertions); - // TODO: Add assertions when Penpal is able to manage assets - system_para_test - .set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); - system_para_test.assert(); -} - -/// Reserve Transfers of a local asset from System Parachain to Parachain should work -#[test] -fn reserve_transfer_asset_from_system_para_to_para() { - // Force create asset from Relay Chain and mint assets for System Parachain's sender account - AssetHubWestend::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - AssetHubWestendSender::get(), - ASSET_MIN_BALANCE * 1000000, - ); - - // Init values for System Parachain - let destination = AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()); - let beneficiary_id = PenpalWestendAReceiver::get(); - let amount_to_send = ASSET_MIN_BALANCE * 1000; - let assets = - (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) - .into(); - - let system_para_test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: PenpalWestendAReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); - - system_para_test.set_assertion::(system_para_to_para_assets_assertions); - // TODO: Add assertions when Penpal is able to manage assets - system_para_test - .set_dispatchable::(system_para_to_para_reserve_transfer_assets); - system_para_test.assert(); -} diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs deleted file mode 100644 index 424d222bef..0000000000 --- a/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs +++ /dev/null @@ -1,140 +0,0 @@ -// 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. - -use crate::*; - -/// Relay Chain should be able to execute `Transact` instructions in System Parachain -/// when `OriginKind::Superuser` and signer is `sudo` -#[test] -fn send_transact_sudo_from_relay_to_system_para_works() { - // Init tests variables - let root_origin = ::RuntimeOrigin::root(); - let system_para_destination = Westend::child_location_of(AssetHubWestend::para_id()).into(); - let asset_owner: AccountId = AssetHubWestendSender::get().into(); - let xcm = AssetHubWestend::force_create_asset_xcm( - OriginKind::Superuser, - ASSET_ID, - asset_owner.clone(), - true, - 1000, - ); - // Send XCM message from Relay Chain - Westend::execute_with(|| { - assert_ok!(::XcmPallet::send( - root_origin, - bx!(system_para_destination), - bx!(xcm), - )); - - Westend::assert_xcm_pallet_sent(); - }); - - // Receive XCM message in Assets Parachain - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts( - 1_019_445_000, - 200_000, - ))); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::Assets(pallet_assets::Event::ForceCreated { asset_id, owner }) => { - asset_id: *asset_id == ASSET_ID, - owner: *owner == asset_owner, - }, - ] - ); - - assert!(::Assets::asset_exists(ASSET_ID)); - }); -} - -/// Parachain should be able to send XCM paying its fee with sufficient asset -/// in the System Parachain -#[test] -fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() { - let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalWestendA::para_id()), - ); - - // Force create and mint assets for Parachain's sovereign account - AssetHubWestend::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - para_sovereign_account.clone(), - ASSET_MIN_BALANCE * 1000000000, - ); - - // We just need a call that can pass the `SafeCallFilter` - // Call values are not relevant - let call = AssetHubWestend::force_create_asset_call( - ASSET_ID, - para_sovereign_account.clone(), - true, - ASSET_MIN_BALANCE, - ); - - let origin_kind = OriginKind::SovereignAccount; - let fee_amount = ASSET_MIN_BALANCE * 1000000; - let native_asset = - (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount).into(); - - let root_origin = ::RuntimeOrigin::root(); - let system_para_destination = - PenpalWestendA::sibling_location_of(AssetHubWestend::para_id()).into(); - let xcm = xcm_transact_paid_execution( - call, - origin_kind, - native_asset, - para_sovereign_account.clone(), - ); - - PenpalWestendA::execute_with(|| { - assert_ok!(::PolkadotXcm::send( - root_origin, - bx!(system_para_destination), - bx!(xcm), - )); - - PenpalWestendA::assert_xcm_pallet_sent(); - }); - - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubWestend::assert_xcmp_queue_success(Some(Weight::from_parts( - 2_176_414_000, - 203_593, - ))); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance }) => { - asset_id: *asset_id == ASSET_ID, - owner: *owner == para_sovereign_account, - balance: *balance == fee_amount, - }, - RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, .. }) => { - asset_id: *asset_id == ASSET_ID, - }, - ] - ); - }); -} diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/set_xcm_versions.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/set_xcm_versions.rs deleted file mode 100644 index 2720095aac..0000000000 --- a/integration-tests/emulated/assets/asset-hub-westend/src/tests/set_xcm_versions.rs +++ /dev/null @@ -1,96 +0,0 @@ -// 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. - -use crate::*; - -#[test] -fn relay_sets_system_para_xcm_supported_version() { - // Init tests variables - let sudo_origin = ::RuntimeOrigin::root(); - let system_para_destination: MultiLocation = - Westend::child_location_of(AssetHubWestend::para_id()); - - // Relay Chain sets supported version for Asset Parachain - Westend::execute_with(|| { - assert_ok!(::XcmPallet::force_xcm_version( - sudo_origin, - bx!(system_para_destination), - XCM_V3 - )); - - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - Westend, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged { - location, - version: XCM_V3 - }) => { location: *location == system_para_destination, }, - ] - ); - }); -} - -#[test] -fn system_para_sets_relay_xcm_supported_version() { - // Init test variables - let sudo_origin = ::RuntimeOrigin::root(); - let parent_location = AssetHubWestend::parent_location(); - let system_para_destination: VersionedMultiLocation = - Westend::child_location_of(AssetHubWestend::para_id()).into(); - let call = ::RuntimeCall::PolkadotXcm(pallet_xcm::Call::< - ::Runtime, - >::force_xcm_version { - location: bx!(parent_location), - version: XCM_V3, - }) - .encode() - .into(); - let origin_kind = OriginKind::Superuser; - - let xcm = xcm_transact_unpaid_execution(call, origin_kind); - - // System Parachain sets supported version for Relay Chain throught it - Westend::execute_with(|| { - assert_ok!(::XcmPallet::send( - sudo_origin, - bx!(system_para_destination), - bx!(xcm), - )); - - Westend::assert_xcm_pallet_sent(); - }); - - // System Parachain receive the XCM message - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts( - 1_019_210_000, - 200_000, - ))); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged { - location, - version: XCM_V3 - }) => { location: *location == parent_location, }, - ] - ); - }); -} diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/swap.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/swap.rs deleted file mode 100644 index 7d1615c9e2..0000000000 --- a/integration-tests/emulated/assets/asset-hub-westend/src/tests/swap.rs +++ /dev/null @@ -1,350 +0,0 @@ -// 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. - -use crate::*; - -#[test] -fn swap_locally_on_chain_using_local_assets() { - let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocation::get()); - let asset_one = Box::new(MultiLocation { - parents: 0, - interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), - }); - - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_ok!(::Assets::create( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 1000, - )); - assert!(::Assets::asset_exists(ASSET_ID)); - - assert_ok!(::Assets::mint( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 3_000_000_000_000, - )); - - assert_ok!(::AssetConversion::create_pool( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - asset_native.clone(), - asset_one.clone(), - )); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {}, - ] - ); - - assert_ok!(::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - asset_native.clone(), - asset_one.clone(), - 1_000_000_000_000, - 2_000_000_000_000, - 0, - 0, - AssetHubWestendSender::get().into() - )); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {lp_token_minted, .. }) => { lp_token_minted: *lp_token_minted == 1414213562273, }, - ] - ); - - let path = BoundedVec::<_, _>::truncate_from(vec![asset_native.clone(), asset_one.clone()]); - - assert_ok!(::AssetConversion::swap_exact_tokens_for_tokens( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - path, - 100, - 1, - AssetHubWestendSender::get().into(), - true - )); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. }) => { - amount_in: *amount_in == 100, - amount_out: *amount_out == 199, - }, - ] - ); - - assert_ok!(::AssetConversion::remove_liquidity( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - asset_native, - asset_one, - 1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved. - 0, - 0, - AssetHubWestendSender::get().into(), - )); - }); -} - -#[test] -fn swap_locally_on_chain_using_foreign_assets() { - use frame_support::weights::WeightToFee; - - let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocation::get()); - - let foreign_asset1_at_asset_hub_westend = Box::new(MultiLocation { - parents: 1, - interior: X3( - Parachain(PenpalWestendA::para_id().into()), - PalletInstance(ASSETS_PALLET_ID), - GeneralIndex(ASSET_ID.into()), - ), - }); - - let assets_para_destination: VersionedMultiLocation = - MultiLocation { parents: 1, interior: X1(Parachain(AssetHubWestend::para_id().into())) } - .into(); - - let penpal_location = - MultiLocation { parents: 1, interior: X1(Parachain(PenpalWestendA::para_id().into())) }; - - // 1. Create asset on penpal: - PenpalWestendA::execute_with(|| { - assert_ok!(::Assets::create( - ::RuntimeOrigin::signed(PenpalWestendASender::get()), - ASSET_ID.into(), - PenpalWestendASender::get().into(), - 1000, - )); - - assert!(::Assets::asset_exists(ASSET_ID)); - }); - - // 2. Create foreign asset on asset_hub_westend: - - let require_weight_at_most = Weight::from_parts(1_100_000_000_000, 30_000); - let origin_kind = OriginKind::Xcm; - let sov_penpal_on_asset_hub_westend = AssetHubWestend::sovereign_account_id_of(penpal_location); - - AssetHubWestend::fund_accounts(vec![ - (AssetHubWestendSender::get().into(), 5_000_000 * WESTEND_ED), - (sov_penpal_on_asset_hub_westend.clone().into(), 1000_000_000_000_000_000 * WESTEND_ED), - ]); - - let sov_penpal_on_asset_hub_westend_as_location: MultiLocation = MultiLocation { - parents: 0, - interior: X1(AccountId32Junction { - network: None, - id: sov_penpal_on_asset_hub_westend.clone().into(), - }), - }; - - let call_foreign_assets_create = - ::RuntimeCall::ForeignAssets(pallet_assets::Call::< - ::Runtime, - Instance2, - >::create { - id: *foreign_asset1_at_asset_hub_westend, - min_balance: 1000, - admin: sov_penpal_on_asset_hub_westend.clone().into(), - }) - .encode() - .into(); - - let buy_execution_fee_amount = parachains_common::westend::fee::WeightToFee::weight_to_fee( - &Weight::from_parts(10_100_000_000_000, 300_000), - ); - let buy_execution_fee = MultiAsset { - id: Concrete(MultiLocation { parents: 1, interior: Here }), - fun: Fungible(buy_execution_fee_amount), - }; - - let xcm = VersionedXcm::from(Xcm(vec![ - WithdrawAsset { 0: vec![buy_execution_fee.clone()].into() }, - BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited }, - Transact { require_weight_at_most, origin_kind, call: call_foreign_assets_create }, - RefundSurplus, - DepositAsset { - assets: All.into(), - beneficiary: sov_penpal_on_asset_hub_westend_as_location, - }, - ])); - - // Send XCM message from penpal => asset_hub_westend - let sudo_penpal_origin = ::RuntimeOrigin::root(); - PenpalWestendA::execute_with(|| { - assert_ok!(::PolkadotXcm::send( - sudo_penpal_origin.clone(), - bx!(assets_para_destination.clone()), - bx!(xcm), - )); - - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PenpalWestendA, - vec![ - RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - // Receive XCM message in Assets Parachain - AssetHubWestend::execute_with(|| { - assert!(::ForeignAssets::asset_exists( - *foreign_asset1_at_asset_hub_westend - )); - - // 3: Mint foreign asset on asset_hub_westend: - // - // (While it might be nice to use batch, - // currently that's disabled due to safe call filters.) - - type RuntimeEvent = ::RuntimeEvent; - // 3. Mint foreign asset (in reality this should be a teleport or some such) - assert_ok!(::ForeignAssets::mint( - ::RuntimeOrigin::signed( - sov_penpal_on_asset_hub_westend.clone().into() - ), - *foreign_asset1_at_asset_hub_westend, - sov_penpal_on_asset_hub_westend.clone().into(), - 3_000_000_000_000, - )); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - ] - ); - - // 4. Create pool: - assert_ok!(::AssetConversion::create_pool( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - asset_native.clone(), - foreign_asset1_at_asset_hub_westend.clone(), - )); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {}, - ] - ); - - // 5. Add liquidity: - assert_ok!(::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed( - sov_penpal_on_asset_hub_westend.clone() - ), - asset_native.clone(), - foreign_asset1_at_asset_hub_westend.clone(), - 1_000_000_000_000, - 2_000_000_000_000, - 0, - 0, - sov_penpal_on_asset_hub_westend.clone().into() - )); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded {lp_token_minted, .. }) => { - lp_token_minted: *lp_token_minted == 1414213562273, - }, - ] - ); - - // 6. Swap! - let path = BoundedVec::<_, _>::truncate_from(vec![ - asset_native.clone(), - foreign_asset1_at_asset_hub_westend.clone(), - ]); - - assert_ok!(::AssetConversion::swap_exact_tokens_for_tokens( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - path, - 100000, - 1000, - AssetHubWestendSender::get().into(), - true - )); - - assert_expected_events!( - AssetHubWestend, - vec![ - RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. },) => { - amount_in: *amount_in == 100000, - amount_out: *amount_out == 199399, - }, - ] - ); - - // 7. Remove liquidity - assert_ok!(::AssetConversion::remove_liquidity( - ::RuntimeOrigin::signed( - sov_penpal_on_asset_hub_westend.clone() - ), - asset_native, - foreign_asset1_at_asset_hub_westend, - 1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved. - 0, - 0, - sov_penpal_on_asset_hub_westend.clone().into(), - )); - }); -} - -#[test] -fn cannot_create_pool_from_pool_assets() { - let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocation::get()); - let mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocation::get(); - asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); - - AssetHubWestend::execute_with(|| { - let pool_owner_account_id = asset_hub_westend_runtime::AssetConversionOrigin::get(); - - assert_ok!(::PoolAssets::create( - ::RuntimeOrigin::signed(pool_owner_account_id.clone()), - ASSET_ID.into(), - pool_owner_account_id.clone().into(), - 1000, - )); - assert!(::PoolAssets::asset_exists(ASSET_ID)); - - assert_ok!(::PoolAssets::mint( - ::RuntimeOrigin::signed(pool_owner_account_id), - ASSET_ID.into(), - AssetHubWestendSender::get().into(), - 3_000_000_000_000, - )); - - assert_matches::assert_matches!( - ::AssetConversion::create_pool( - ::RuntimeOrigin::signed(AssetHubWestendSender::get()), - asset_native.clone(), - Box::new(asset_one), - ), - Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("UnsupportedAsset")) - ); - }); -} diff --git a/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs deleted file mode 100644 index 8de73a7420..0000000000 --- a/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs +++ /dev/null @@ -1,363 +0,0 @@ -// 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. - -#![allow(dead_code)] // - -use crate::*; - -fn relay_origin_assertions(t: RelayToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - Westend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(632_207_000, 7_186))); - - assert_expected_events!( - Westend, - vec![ - // Amount to teleport is withdrawn from Sender - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - // Amount to teleport is deposited in Relay's `CheckAccount` - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, amount }) => { - who: *who == ::XcmPallet::check_account(), - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn relay_dest_assertions(t: SystemParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - - Westend::assert_ump_queue_processed( - true, - Some(AssetHubWestend::para_id()), - Some(Weight::from_parts(308_222_000, 7_186)), - ); - - assert_expected_events!( - Westend, - vec![ - // Amount is witdrawn from Relay Chain's `CheckAccount` - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == ::XcmPallet::check_account(), - amount: *amount == t.args.amount, - }, - // Amount minus fees are deposited in Receiver's account - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { - who: *who == t.receiver.account_id, - }, - ] - ); -} - -fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { - Westend::assert_ump_queue_processed( - false, - Some(AssetHubWestend::para_id()), - Some(Weight::from_parts(148_705_000, 3_593)), - ); -} - -fn para_origin_assertions(t: SystemParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubWestend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 533_910_000, - 7167, - ))); - - AssetHubWestend::assert_parachain_system_ump_sent(); - - assert_expected_events!( - AssetHubWestend, - vec![ - // Amount is withdrawn from Sender's account - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn para_dest_assertions(t: RelayToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts(164_733_000, 0))); - - assert_expected_events!( - AssetHubWestend, - vec![ - // Amount minus fees are deposited in Receiver's account - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { - who: *who == t.receiver.account_id, - }, - ] - ); -} - -fn relay_limited_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::limited_teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -fn relay_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - -fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::limited_teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged -// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { -// ::PolkadotXcm::teleport_assets( -// t.signed_origin, -// bx!(t.args.dest), -// bx!(t.args.beneficiary), -// bx!(t.args.assets), -// t.args.fee_asset_item, -// ) -// } - -/// Limited Teleport of native asset from Relay Chain to the System Parachain should work -#[test] -fn limited_teleport_native_assets_from_relay_to_system_para_works() { - // Init values for Relay Chain - let amount_to_send: Balance = WESTEND_ED * 1000; - let test_args = TestContext { - sender: WestendSender::get(), - receiver: AssetHubWestendReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(para_dest_assertions); - test.set_dispatchable::(relay_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Limited Teleport of native asset from System Parachain to Relay Chain -/// should work when there is enough balance in Relay Chain's `CheckAccount` -#[test] -fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { - // Dependency - Relay Chain's `CheckAccount` should have enough balance - limited_teleport_native_assets_from_relay_to_system_para_works(); - - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let destination = AssetHubWestend::parent_location(); - let beneficiary_id = WestendReceiver::get(); - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: WestendReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions); - test.set_dispatchable::(system_para_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Limited Teleport of native asset from System Parachain to Relay Chain -/// should't work when there is not enough balance in Relay Chain's `CheckAccount` -#[test] -fn limited_teleport_native_assets_from_system_para_to_relay_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; - let destination = AssetHubWestend::parent_location().into(); - let beneficiary_id = WestendReceiver::get().into(); - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubWestendSender::get(), - receiver: WestendReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions_fail); - test.set_dispatchable::(system_para_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance does not change - assert_eq!(receiver_balance_after, receiver_balance_before); -} - -/// Teleport of native asset from Relay Chain to the System Parachain should work -#[test] -fn teleport_native_assets_from_relay_to_system_para_works() { - // Init values for Relay Chain - let amount_to_send: Balance = WESTEND_ED * 1000; - let test_args = TestContext { - sender: WestendSender::get(), - receiver: AssetHubWestendReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(para_dest_assertions); - test.set_dispatchable::(relay_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged - -// Right now it is failing in the Relay Chain with a -// `messageQueue.ProcessingFailed` event `error: Unsupported`. -// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight` -// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier - -// /// Teleport of native asset from System Parachains to the Relay Chain -// /// should work when there is enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_back_from_system_para_to_relay_works() { -// // Dependency - Relay Chain's `CheckAccount` should have enough balance -// teleport_native_assets_from_relay_to_system_para_works(); - -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; -// let test_args = TestContext { -// sender: AssetHubWestendSender::get(), -// receiver: WestendReceiver::get(), -// args: get_para_dispatch_args(amount_to_send), -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance is increased -// assert!(receiver_balance_after > receiver_balance_before); -// } - -// /// Teleport of native asset from System Parachain to Relay Chain -// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_from_system_para_to_relay_fails() { -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; -// let assets = (Parent, amount_to_send).into(); -// -// let test_args = TestContext { -// sender: AssetHubWestendSender::get(), -// receiver: WestendReceiver::get(), -// args: system_para_test_args(amount_to_send), -// assets, -// None -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance does not change -// assert_eq!(receiver_balance_after, receiver_balance_before); -// } From ffc1de0089240464bf5a968ec938815da7c5f75d Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 8 Dec 2023 14:46:31 +0200 Subject: [PATCH 07/18] remove unused chain definitions --- .../relays/kusama/Cargo.toml | 47 -------- .../relays/kusama/src/genesis.rs | 101 ----------------- .../relays/kusama/src/lib.rs | 48 -------- .../relays/polkadot/Cargo.toml | 30 ----- .../relays/polkadot/src/genesis.rs | 105 ------------------ .../relays/polkadot/src/lib.rs | 50 --------- 6 files changed, 381 deletions(-) delete mode 100644 integration-tests/emulated/chains-definitions/relays/kusama/Cargo.toml delete mode 100644 integration-tests/emulated/chains-definitions/relays/kusama/src/genesis.rs delete mode 100644 integration-tests/emulated/chains-definitions/relays/kusama/src/lib.rs delete mode 100644 integration-tests/emulated/chains-definitions/relays/polkadot/Cargo.toml delete mode 100644 integration-tests/emulated/chains-definitions/relays/polkadot/src/genesis.rs delete mode 100644 integration-tests/emulated/chains-definitions/relays/polkadot/src/lib.rs diff --git a/integration-tests/emulated/chains-definitions/relays/kusama/Cargo.toml b/integration-tests/emulated/chains-definitions/relays/kusama/Cargo.toml deleted file mode 100644 index d15358c74c..0000000000 --- a/integration-tests/emulated/chains-definitions/relays/kusama/Cargo.toml +++ /dev/null @@ -1,47 +0,0 @@ -[package] -name = "kusama-emulated-chain" -version = "0.0.0" -authors.workspace = true -edition.workspace = true -license = "Apache-2.0" -description = "Kusama emulated chain" -publish = false - -[dependencies] -serde_json = "1.0.104" - -# Substrate -sp-core = { default-features = false, version = "25.0.0" } -sp-runtime = { default-features = false, version = "28.0.0" } -sp-authority-discovery = { default-features = false , version = "23.0.0" } -sp-consensus-babe = { default-features = false , version = "0.29.0" } -beefy-primitives = { package = "sp-consensus-beefy", default-features = false , version = "10.0.0" } -grandpa-primitives = { package = "sp-consensus-grandpa", default-features = false , version = "10.0.0" } -pallet-im-online = { default-features = false, version = "24.0.0" } - -# Polkadot -polkadot-primitives = { default-features = false , version = "4.0.0" } -kusama-runtime-constants = { path = "../../../../../relay/kusama/constants", default-features = false } -kusama-runtime = { package = "staging-kusama-runtime", path = "../../../../../relay/kusama", default-features = false } - -# Cumulus -parachains-common = { default-features = false, version = "4.0.0" } -#emulated-integration-tests-common = { default-features = false, version = "1.0.0" } -emulated-integration-tests-common = { path = "../../../common", default-features = false } - -[features] -default = [ "std" ] - -std = [ - "sp-core/std", - "sp-runtime/std", - "sp-authority-discovery/std", - "sp-consensus-babe/std", - "beefy-primitives/std", - "grandpa-primitives/std", - "polkadot-primitives/std", - "kusama-runtime-constants/std", - "kusama-runtime/std", - "parachains-common/std", - "pallet-im-online/std", -] diff --git a/integration-tests/emulated/chains-definitions/relays/kusama/src/genesis.rs b/integration-tests/emulated/chains-definitions/relays/kusama/src/genesis.rs deleted file mode 100644 index 128da59486..0000000000 --- a/integration-tests/emulated/chains-definitions/relays/kusama/src/genesis.rs +++ /dev/null @@ -1,101 +0,0 @@ -// 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. - -// Substrate -use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; -use grandpa_primitives::AuthorityId as GrandpaId; -use pallet_im_online::sr25519::AuthorityId as ImOnlineId; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_consensus_babe::AuthorityId as BabeId; -use sp_core::{sr25519, storage::Storage}; - -// Polkadot -use polkadot_primitives::{AssignmentId, ValidatorId}; - -// Cumulus -use emulated_integration_tests_common::{ - accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config, - validators, -}; -use parachains_common::Balance; -use kusama_runtime_constants::currency::UNITS as KSM; - -pub const ED: Balance = kusama_runtime_constants::currency::EXISTENTIAL_DEPOSIT; -const ENDOWMENT: u128 = 1_000_000 * KSM; - -fn session_keys( - babe: BabeId, - grandpa: GrandpaId, - im_online: ImOnlineId, - para_validator: ValidatorId, - para_assignment: AssignmentId, - authority_discovery: AuthorityDiscoveryId, - beefy: BeefyId, -) -> kusama_runtime::SessionKeys { - kusama_runtime::SessionKeys { - babe, - grandpa, - im_online, - para_validator, - para_assignment, - authority_discovery, - beefy, - } -} - -pub fn genesis() -> Storage { - let genesis_config = kusama_runtime::RuntimeGenesisConfig { - system: kusama_runtime::SystemConfig::default(), - balances: kusama_runtime::BalancesConfig { - balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(), - }, - session: kusama_runtime::SessionConfig { - keys: validators::initial_authorities() - .iter() - .map(|x| { - ( - x.0.clone(), - x.0.clone(), - session_keys( - x.2.clone(), - x.3.clone(), - x.4.clone(), - x.5.clone(), - x.6.clone(), - x.7.clone(), - get_from_seed::("Alice"), - ), - ) - }) - .collect::>(), - }, - babe: kusama_runtime::BabeConfig { - authorities: Default::default(), - epoch_config: Some(kusama_runtime::BABE_GENESIS_EPOCH_CONFIG), - ..Default::default() - }, - // sudo: kusama_runtime::SudoConfig { - // key: Some(get_account_id_from_seed::("Alice")), - // }, - configuration: kusama_runtime::ConfigurationConfig { config: get_host_config() }, - // registrar: kusama_runtime::RegistrarConfig { - // next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID, - // ..Default::default() - // }, - ..Default::default() - }; - - build_genesis_storage(&genesis_config, kusama_runtime::WASM_BINARY.unwrap()) -} diff --git a/integration-tests/emulated/chains-definitions/relays/kusama/src/lib.rs b/integration-tests/emulated/chains-definitions/relays/kusama/src/lib.rs deleted file mode 100644 index 2ebc10f7db..0000000000 --- a/integration-tests/emulated/chains-definitions/relays/kusama/src/lib.rs +++ /dev/null @@ -1,48 +0,0 @@ -// 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. - -pub mod genesis; - -// Cumulus -use emulated_integration_tests_common::{ - impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, - impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, - xcm_emulator::decl_test_relay_chains, -}; - -// Kusama declaration -decl_test_relay_chains! { - #[api_version(9)] - pub struct Kusama { - genesis = genesis::genesis(), - on_init = (), - runtime = kusama_runtime, - core = { - SovereignAccountOf: kusama_runtime::xcm_config::LocalOriginConverter, - }, - pallets = { - XcmPallet: kusama_runtime::XcmPallet, - // Sudo: kusama_runtime::Sudo, - Balances: kusama_runtime::Balances, - Hrmp: kusama_runtime::Hrmp, - } - }, -} - -// Kusama implementation -impl_accounts_helpers_for_relay_chain!(Kusama); -impl_assert_events_helpers_for_relay_chain!(Kusama); -impl_hrmp_channels_helpers_for_relay_chain!(Kusama); -impl_send_transact_helpers_for_relay_chain!(Kusama); diff --git a/integration-tests/emulated/chains-definitions/relays/polkadot/Cargo.toml b/integration-tests/emulated/chains-definitions/relays/polkadot/Cargo.toml deleted file mode 100644 index 20b9737735..0000000000 --- a/integration-tests/emulated/chains-definitions/relays/polkadot/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "westend-emulated-chain" -version = "0.0.0" -authors.workspace = true -edition.workspace = true -license = "Apache-2.0" -description = "Westend emulated chain" -publish = false - -[dependencies] -serde_json = "1.0.104" - -# Substrate -sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false } -sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false } -sp-authority-discovery = { path = "../../../../../../../substrate/primitives/authority-discovery", default-features = false } -sp-consensus-babe = { path = "../../../../../../../substrate/primitives/consensus/babe", default-features = false } -beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../../../substrate/primitives/consensus/beefy" } -grandpa = { package = "sc-consensus-grandpa", path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false } -pallet-im-online = { path = "../../../../../../../substrate/frame/im-online", default-features = false } -pallet-staking = { path = "../../../../../../../substrate/frame/staking", default-features = false } - -# Polkadot -polkadot-primitives = { path = "../../../../../../../polkadot/primitives", default-features = false } -westend-runtime-constants = { path = "../../../../../../../polkadot/runtime/westend/constants", default-features = false } -westend-runtime = { path = "../../../../../../../polkadot/runtime/westend" } - -# Cumulus -parachains-common = { path = "../../../../../../parachains/common" } -emulated-integration-tests-common = { path = "../../../common", default-features = false } diff --git a/integration-tests/emulated/chains-definitions/relays/polkadot/src/genesis.rs b/integration-tests/emulated/chains-definitions/relays/polkadot/src/genesis.rs deleted file mode 100644 index e2297100a4..0000000000 --- a/integration-tests/emulated/chains-definitions/relays/polkadot/src/genesis.rs +++ /dev/null @@ -1,105 +0,0 @@ -// 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. - -// Substrate -use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; -use grandpa::AuthorityId as GrandpaId; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_consensus_babe::AuthorityId as BabeId; -use sp_core::storage::Storage; -use sp_runtime::Perbill; - -// Polkadot -use polkadot_primitives::{AssignmentId, ValidatorId}; - -// Cumulus -use emulated_integration_tests_common::{ - accounts, build_genesis_storage, get_from_seed, get_host_config, validators, -}; -use parachains_common::Balance; -use westend_runtime_constants::currency::UNITS as WND; - -pub const ED: Balance = westend_runtime_constants::currency::EXISTENTIAL_DEPOSIT; -const ENDOWMENT: u128 = 1_000_000 * WND; -const STASH: u128 = 100 * WND; - -fn session_keys( - babe: BabeId, - grandpa: GrandpaId, - para_validator: ValidatorId, - para_assignment: AssignmentId, - authority_discovery: AuthorityDiscoveryId, - beefy: BeefyId, -) -> westend_runtime::SessionKeys { - westend_runtime::SessionKeys { - babe, - grandpa, - para_validator, - para_assignment, - authority_discovery, - beefy, - } -} - -pub fn genesis() -> Storage { - let genesis_config = westend_runtime::RuntimeGenesisConfig { - system: westend_runtime::SystemConfig::default(), - balances: westend_runtime::BalancesConfig { - balances: accounts::init_balances().iter().cloned().map(|k| (k, ENDOWMENT)).collect(), - }, - session: westend_runtime::SessionConfig { - keys: validators::initial_authorities() - .iter() - .map(|x| { - ( - x.0.clone(), - x.0.clone(), - session_keys( - x.2.clone(), - x.3.clone(), - x.4.clone(), - x.5.clone(), - x.6.clone(), - get_from_seed::("Alice"), - ), - ) - }) - .collect::>(), - }, - staking: westend_runtime::StakingConfig { - validator_count: validators::initial_authorities().len() as u32, - minimum_validator_count: 1, - stakers: validators::initial_authorities() - .iter() - .map(|x| { - (x.0.clone(), x.1.clone(), STASH, westend_runtime::StakerStatus::Validator) - }) - .collect(), - invulnerables: validators::initial_authorities().iter().map(|x| x.0.clone()).collect(), - force_era: pallet_staking::Forcing::ForceNone, - slash_reward_fraction: Perbill::from_percent(10), - ..Default::default() - }, - babe: westend_runtime::BabeConfig { - authorities: Default::default(), - epoch_config: Some(westend_runtime::BABE_GENESIS_EPOCH_CONFIG), - ..Default::default() - }, - configuration: westend_runtime::ConfigurationConfig { config: get_host_config() }, - ..Default::default() - }; - - build_genesis_storage(&genesis_config, westend_runtime::WASM_BINARY.unwrap()) -} diff --git a/integration-tests/emulated/chains-definitions/relays/polkadot/src/lib.rs b/integration-tests/emulated/chains-definitions/relays/polkadot/src/lib.rs deleted file mode 100644 index 2ba47250d5..0000000000 --- a/integration-tests/emulated/chains-definitions/relays/polkadot/src/lib.rs +++ /dev/null @@ -1,50 +0,0 @@ -// 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. - -pub mod genesis; - -// Cumulus -use emulated_integration_tests_common::{ - impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain, - impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain, - xcm_emulator::decl_test_relay_chains, -}; - -// Westend declaration -decl_test_relay_chains! { - #[api_version(9)] - pub struct Westend { - genesis = genesis::genesis(), - on_init = (), - runtime = westend_runtime, - core = { - SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, - }, - pallets = { - XcmPallet: westend_runtime::XcmPallet, - Sudo: westend_runtime::Sudo, - Balances: westend_runtime::Balances, - Treasury: westend_runtime::Treasury, - AssetRate: westend_runtime::AssetRate, - Hrmp: westend_runtime::Hrmp, - } - }, -} - -// Westend implementation -impl_accounts_helpers_for_relay_chain!(Westend); -impl_assert_events_helpers_for_relay_chain!(Westend); -impl_hrmp_channels_helpers_for_relay_chain!(Westend); -impl_send_transact_helpers_for_relay_chain!(Westend); From 7dc38632e3d89e8cb56c959eda731907d3da96ee Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 8 Dec 2023 15:03:19 +0200 Subject: [PATCH 08/18] fix some TODOs --- .../asset-hub-kusama/src/tests/teleport.rs | 164 +++++++++--------- .../asset-hub-polkadot/src/tests/teleport.rs | 164 +++++++++--------- 2 files changed, 158 insertions(+), 170 deletions(-) diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs index dd6be04f44..a7b05808c1 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -142,16 +142,15 @@ fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResu ) } -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged -// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { -// ::PolkadotXcm::teleport_assets( -// t.signed_origin, -// bx!(t.args.dest), -// bx!(t.args.beneficiary), -// bx!(t.args.assets), -// t.args.fee_asset_item, -// ) -// } +fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} /// Limited Teleport of native asset from Relay Chain to the System Parachain should work #[test] @@ -286,78 +285,73 @@ fn teleport_native_assets_from_relay_to_system_para_works() { assert!(receiver_balance_after > receiver_balance_before); } -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged - -// Right now it is failing in the Relay Chain with a -// `messageQueue.ProcessingFailed` event `error: Unsupported`. -// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight` -// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier - -// /// Teleport of native asset from System Parachains to the Relay Chain -// /// should work when there is enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_back_from_system_para_to_relay_works() { -// // Dependency - Relay Chain's `CheckAccount` should have enough balance -// teleport_native_assets_from_relay_to_system_para_works(); - -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; -// let test_args = TestContext { -// sender: AssetHubKusamaSender::get(), -// receiver: KusamaReceiver::get(), -// args: get_para_dispatch_args(amount_to_send), -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance is increased -// assert!(receiver_balance_after > receiver_balance_before); -// } - -// /// Teleport of native asset from System Parachain to Relay Chain -// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_from_system_para_to_relay_fails() { -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; -// let assets = (Parent, amount_to_send).into(); -// -// let test_args = TestContext { -// sender: AssetHubKusamaSender::get(), -// receiver: KusamaReceiver::get(), -// args: system_para_test_args(amount_to_send), -// assets, -// None -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance does not change -// assert_eq!(receiver_balance_after, receiver_balance_before); -// } +/// Teleport of native asset from System Parachains to the Relay Chain +/// should work when there is enough balance in Relay Chain's `CheckAccount` +#[test] +fn teleport_native_assets_back_from_system_para_to_relay_works() { + // Dependency - Relay Chain's `CheckAccount` should have enough balance + teleport_native_assets_from_relay_to_system_para_works(); + + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; + let destination = AssetHubKusama::parent_location(); + let beneficiary_id = KusamaReceiver::get(); + let assets = (Parent, amount_to_send).into(); + let test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: KusamaReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions); + test.set_dispatchable::(system_para_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert!(sender_balance_before - amount_to_send >= sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +/// Teleport of native asset from System Parachain to Relay Chain +/// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` +#[test] +fn teleport_native_assets_from_system_para_to_relay_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; + let destination = AssetHubKusama::parent_location(); + let beneficiary_id = KusamaReceiver::get(); + let assets = (Parent, amount_to_send).into(); + let test_args = TestContext { + sender: AssetHubKusamaSender::get(), + receiver: KusamaReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions_fail); + test.set_dispatchable::(system_para_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert!(sender_balance_before - amount_to_send >= sender_balance_after); + // Receiver's balance does not change + assert_eq!(receiver_balance_after, receiver_balance_before); +} diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs index 40f6ba0f1d..0dd20094ab 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -142,16 +142,15 @@ fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResu ) } -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged -// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { -// ::PolkadotXcm::teleport_assets( -// t.signed_origin, -// bx!(t.args.dest), -// bx!(t.args.beneficiary), -// bx!(t.args.assets), -// t.args.fee_asset_item, -// ) -// } +fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { + ::PolkadotXcm::teleport_assets( + t.signed_origin, + bx!(t.args.dest.into()), + bx!(t.args.beneficiary.into()), + bx!(t.args.assets.into()), + t.args.fee_asset_item, + ) +} /// Limited Teleport of native asset from Relay Chain to the System Parachain should work #[test] @@ -286,78 +285,73 @@ fn teleport_native_assets_from_relay_to_system_para_works() { assert!(receiver_balance_after > receiver_balance_before); } -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged - -// Right now it is failing in the Relay Chain with a -// `messageQueue.ProcessingFailed` event `error: Unsupported`. -// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight` -// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier - -// /// Teleport of native asset from System Parachains to the Relay Chain -// /// should work when there is enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_back_from_system_para_to_relay_works() { -// // Dependency - Relay Chain's `CheckAccount` should have enough balance -// teleport_native_assets_from_relay_to_system_para_works(); - -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; -// let test_args = TestContext { -// sender: AssetHubPolkadotSender::get(), -// receiver: PolkadotReceiver::get(), -// args: get_para_dispatch_args(amount_to_send), -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance is increased -// assert!(receiver_balance_after > receiver_balance_before); -// } - -// /// Teleport of native asset from System Parachain to Relay Chain -// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_from_system_para_to_relay_fails() { -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; -// let assets = (Parent, amount_to_send).into(); -// -// let test_args = TestContext { -// sender: AssetHubPolkadotSender::get(), -// receiver: PolkadotReceiver::get(), -// args: system_para_test_args(amount_to_send), -// assets, -// None -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance does not change -// assert_eq!(receiver_balance_after, receiver_balance_before); -// } +/// Teleport of native asset from System Parachains to the Relay Chain +/// should work when there is enough balance in Relay Chain's `CheckAccount` +#[test] +fn teleport_native_assets_back_from_system_para_to_relay_works() { + // Dependency - Relay Chain's `CheckAccount` should have enough balance + teleport_native_assets_from_relay_to_system_para_works(); + + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; + let destination = AssetHubPolkadot::parent_location(); + let beneficiary_id = PolkadotReceiver::get(); + let assets = (Parent, amount_to_send).into(); + let test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PolkadotReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions); + test.set_dispatchable::(system_para_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert!(sender_balance_before - amount_to_send >= sender_balance_after); + // Receiver's balance is increased + assert!(receiver_balance_after > receiver_balance_before); +} + +/// Teleport of native asset from System Parachain to Relay Chain +/// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` +#[test] +fn teleport_native_assets_from_system_para_to_relay_fails() { + // Init values for Relay Chain + let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; + let destination = AssetHubPolkadot::parent_location(); + let beneficiary_id = PolkadotReceiver::get(); + let assets = (Parent, amount_to_send).into(); + let test_args = TestContext { + sender: AssetHubPolkadotSender::get(), + receiver: PolkadotReceiver::get(), + args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), + }; + + let mut test = SystemParaToRelayTest::new(test_args); + + let sender_balance_before = test.sender.balance; + let receiver_balance_before = test.receiver.balance; + + test.set_assertion::(para_origin_assertions); + test.set_assertion::(relay_dest_assertions_fail); + test.set_dispatchable::(system_para_teleport_assets); + test.assert(); + + let sender_balance_after = test.sender.balance; + let receiver_balance_after = test.receiver.balance; + + // Sender's balance is reduced + assert!(sender_balance_before - amount_to_send >= sender_balance_after); + // Receiver's balance does not change + assert_eq!(receiver_balance_after, receiver_balance_before); +} From 2cd46095e49c6b5d7a0538ad96ffdd38956bceb7 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 8 Dec 2023 15:19:00 +0200 Subject: [PATCH 09/18] rust fmt --- .../assets/asset-hub-kusama/src/tests/reserve_transfer.rs | 5 +---- .../asset-hub-polkadot/src/tests/reserve_transfer.rs | 5 +---- integration-tests/emulated/common/src/lib.rs | 7 +++++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs index 4d06732f66..9f107b9950 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs @@ -36,10 +36,7 @@ fn relay_origin_assertions(t: RelayToSystemParaTest) { } fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) { - AssetHubKusama::assert_dmp_queue_incomplete( - None, - Some(Error::UntrustedReserveLocation), - ); + AssetHubKusama::assert_dmp_queue_incomplete(None, Some(Error::UntrustedReserveLocation)); } fn system_para_to_relay_assertions(_t: SystemParaToRelayTest) { diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs index e0c13f4315..16a7d69d8e 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs @@ -36,10 +36,7 @@ fn relay_origin_assertions(t: RelayToSystemParaTest) { } fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) { - AssetHubPolkadot::assert_dmp_queue_incomplete( - None, - Some(Error::UntrustedReserveLocation), - ); + AssetHubPolkadot::assert_dmp_queue_incomplete(None, Some(Error::UntrustedReserveLocation)); } fn system_para_to_relay_assertions(_t: SystemParaToRelayTest) { diff --git a/integration-tests/emulated/common/src/lib.rs b/integration-tests/emulated/common/src/lib.rs index d5e3305da9..add6635915 100644 --- a/integration-tests/emulated/common/src/lib.rs +++ b/integration-tests/emulated/common/src/lib.rs @@ -29,8 +29,11 @@ use frame_support::traits::OnInitialize; // Cumulus use xcm_emulator::{ // decl_test_bridges, - decl_test_networks, decl_test_parachains, decl_test_relay_chains, - decl_test_sender_receiver_accounts_parameter_types, DefaultMessageProcessor, + decl_test_networks, + decl_test_parachains, + decl_test_relay_chains, + decl_test_sender_receiver_accounts_parameter_types, + DefaultMessageProcessor, }; use polkadot_primitives::runtime_api::runtime_decl_for_parachain_host::ParachainHostV7; From 02442ad68cd74377d8204c5c7217d400f8693774 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 13 Dec 2023 15:23:52 +0200 Subject: [PATCH 10/18] add BEEFY keys for Polkadot Relay --- integration-tests/emulated/common/src/constants.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/integration-tests/emulated/common/src/constants.rs b/integration-tests/emulated/common/src/constants.rs index f5be05511b..7813ed828b 100644 --- a/integration-tests/emulated/common/src/constants.rs +++ b/integration-tests/emulated/common/src/constants.rs @@ -170,6 +170,7 @@ pub mod polkadot { para_validator: ValidatorId, para_assignment: AssignmentId, authority_discovery: AuthorityDiscoveryId, + beefy: BeefyId, ) -> polkadot_runtime::SessionKeys { polkadot_runtime::SessionKeys { babe, @@ -178,6 +179,7 @@ pub mod polkadot { para_validator, para_assignment, authority_discovery, + beefy, } } @@ -208,6 +210,7 @@ pub mod polkadot { x.5.clone(), x.6.clone(), x.7.clone(), + get_from_seed::("Alice"), ), ) }) From e8fb5596ce2d4faa43af45bae1d022c91951a8bc Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 13 Dec 2023 15:50:26 +0200 Subject: [PATCH 11/18] integration-tests: add AHs and BHs as Relay parachains --- .../emulated/common/src/constants.rs | 60 ++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/integration-tests/emulated/common/src/constants.rs b/integration-tests/emulated/common/src/constants.rs index 7813ed828b..0ef97c6541 100644 --- a/integration-tests/emulated/common/src/constants.rs +++ b/integration-tests/emulated/common/src/constants.rs @@ -241,16 +241,26 @@ pub mod polkadot { configuration: polkadot_runtime::ConfigurationConfig { config: get_host_config() }, paras: polkadot_runtime::ParasConfig { paras: vec![ - // ( - // asset_hub_polkadot::PARA_ID.into(), - // ParaGenesisArgs { - // genesis_head: HeadData::default(), - // validation_code: ValidationCode( - // asset_hub_polkadot_runtime::WASM_BINARY.unwrap().to_vec(), - // ), - // para_kind: ParaKind::Parachain, - // }, - // ), + ( + asset_hub_polkadot::PARA_ID.into(), + ParaGenesisArgs { + genesis_head: HeadData::default(), + validation_code: ValidationCode( + asset_hub_polkadot_runtime::WASM_BINARY.unwrap().to_vec(), + ), + para_kind: ParaKind::Parachain, + }, + ), + ( + bridge_hub_polkadot::PARA_ID.into(), + ParaGenesisArgs { + genesis_head: HeadData::default(), + validation_code: ValidationCode( + bridge_hub_polkadot_runtime::WASM_BINARY.unwrap().to_vec(), + ), + para_kind: ParaKind::Parachain, + }, + ), ( penpal::PARA_ID_A.into(), ParaGenesisArgs { @@ -384,16 +394,26 @@ pub mod kusama { configuration: kusama_runtime::ConfigurationConfig { config: get_host_config() }, paras: kusama_runtime::ParasConfig { paras: vec![ - // ( - // asset_hub_kusama::PARA_ID.into(), - // ParaGenesisArgs { - // genesis_head: HeadData::default(), - // validation_code: ValidationCode( - // asset_hub_kusama_runtime::WASM_BINARY.unwrap().to_vec(), - // ), - // para_kind: ParaKind::Parachain, - // }, - // ), + ( + asset_hub_kusama::PARA_ID.into(), + ParaGenesisArgs { + genesis_head: HeadData::default(), + validation_code: ValidationCode( + asset_hub_kusama_runtime::WASM_BINARY.unwrap().to_vec(), + ), + para_kind: ParaKind::Parachain, + }, + ), + ( + bridge_hub_kusama::PARA_ID.into(), + ParaGenesisArgs { + genesis_head: HeadData::default(), + validation_code: ValidationCode( + bridge_hub_kusama_runtime::WASM_BINARY.unwrap().to_vec(), + ), + para_kind: ParaKind::Parachain, + }, + ), ( penpal::PARA_ID_A.into(), ParaGenesisArgs { From 7b51f197144dc34990ff9dbc1cfaa451f12d8561 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 13 Dec 2023 15:53:06 +0200 Subject: [PATCH 12/18] CI: build WASMs to be used in integration-tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2672bc2b00..5d6acedab4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,7 +55,7 @@ jobs: run: cargo test --workspace --release --locked -q --features=runtime-metrics,try-runtime env: RUSTFLAGS: "-C debug-assertions -D warnings" - SKIP_WASM_BUILD: 1 + SKIP_WASM_BUILD: 0 - name: Test all features run: cargo test --workspace --release --locked -q --features=runtime-benchmarks,runtime-metrics,try-runtime From a6a53bd16c17cfc9bab770f9726e1f7503d9ac54 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 13 Dec 2023 16:51:43 +0200 Subject: [PATCH 13/18] integration-tests: fix feature dependencies --- Cargo.lock | 1 + Cargo.toml | 1 - .../assets/asset-hub-kusama/Cargo.toml | 49 ++++------ .../assets/asset-hub-kusama/src/lib.rs | 6 +- .../assets/asset-hub-kusama/src/tests/mod.rs | 2 + .../assets/asset-hub-polkadot/Cargo.toml | 46 ++++------ .../assets/asset-hub-polkadot/src/lib.rs | 6 +- .../asset-hub-polkadot/src/tests/mod.rs | 2 + integration-tests/emulated/common/Cargo.toml | 89 ++++++++----------- integration-tests/emulated/common/src/lib.rs | 2 + 10 files changed, 85 insertions(+), 119 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57a5363497..f2a45b9cff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8085,6 +8085,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", + "hex-literal", "log", "pallet-asset-tx-payment", "pallet-assets", diff --git a/Cargo.toml b/Cargo.toml index 92e05dd8c2..1062ab77cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ members = [ "system-parachains/bridge-hubs/bridge-hub-polkadot", "system-parachains/collectives/collectives-polkadot", "system-parachains/gluttons/glutton-kusama", - "integration-tests/emulated/common", "integration-tests/emulated/assets/asset-hub-kusama", "integration-tests/emulated/assets/asset-hub-polkadot", ] diff --git a/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml b/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml index 5560ecc954..4b61aa5b12 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml +++ b/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml @@ -8,48 +8,33 @@ description = "Asset Hub Kusama runtime integration tests with xcm-emulator" publish = false [dependencies] -codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.4.0" } assert_matches = "1.5.0" # Substrate -sp-runtime = { default-features = false, version = "28.0.0" } -frame-support = { default-features = false, version = "25.0.0" } -frame-system = { default-features = false, version = "25.0.0" } -pallet-assets = { default-features = false, version = "26.0.0" } -pallet-balances = { default-features = false, version = "25.0.0" } -pallet-asset-conversion = { default-features = false, version = "7.0.0" } +sp-runtime = { version = "28.0.0" } +frame-support = { version = "25.0.0" } +frame-system = { version = "25.0.0" } +pallet-assets = { version = "26.0.0" } +pallet-balances = { version = "25.0.0" } +pallet-asset-conversion = { version = "7.0.0" } # Polkadot -polkadot-core-primitives = { default-features = false, version = "4.0.0" } -polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } -polkadot-runtime-parachains = { default-features = false, version = "4.0.0" } -xcm = { package = "staging-xcm", default-features = false, version = "4.0.0" } -pallet-xcm = { default-features = false, version = "4.0.0" } +polkadot-core-primitives = { version = "4.0.0" } +polkadot-parachain-primitives = { version = "3.0.0" } +polkadot-runtime-parachains = { version = "4.0.0" } +xcm = { package = "staging-xcm", version = "4.0.0" } +pallet-xcm = { version = "4.0.0" } # Cumulus -parachains-common = { default-features = false, version = "4.0.0" } +parachains-common = { version = "4.0.0" } xcm-emulator = { version = "0.2.0" } -asset-hub-kusama-runtime = { path = "../../../../system-parachains/asset-hubs/asset-hub-kusama", default-features = false } +asset-hub-kusama-runtime = { path = "../../../../system-parachains/asset-hubs/asset-hub-kusama" } # Local -integration-tests-common = { path = "../../common", default-features = false} +integration-tests-common = { path = "../../common" } [features] -default = [ "std" ] - -std = [ - "sp-runtime/std", - "frame-support/std", - "frame-system/std", - "pallet-assets/std", - "pallet-balances/std", - "pallet-asset-conversion/std", - "polkadot-core-primitives/std", - "polkadot-parachain-primitives/std", - "polkadot-runtime-parachains/std", - "xcm/std", - "pallet-xcm/std", - "parachains-common/std", - "asset-hub-kusama-runtime/std", - "integration-tests-common/std", +runtime-benchmarks = [ + "integration-tests-common/runtime-benchmarks" ] diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index ad74aa2301..60c4551459 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![cfg(not(feature = "runtime-benchmarks"))] + pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, @@ -49,7 +51,7 @@ pub type RelayToSystemParaTest = Test; pub type SystemParaToRelayTest = Test; pub type SystemParaToParaTest = Test; -/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests +/// Returns a `TestArgs` instance to be used for the Relay Chain across integration tests pub fn relay_test_args(amount: Balance) -> TestArgs { TestArgs { dest: Kusama::child_location_of(AssetHubKusama::para_id()), @@ -66,7 +68,7 @@ pub fn relay_test_args(amount: Balance) -> TestArgs { } } -/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests +/// Returns a `TestArgs` instance to be used for the System Parachain across integration tests pub fn system_para_test_args( dest: MultiLocation, beneficiary_id: AccountId32, diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs index b3089a3b38..ac0b92004e 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![cfg(not(feature = "runtime-benchmarks"))] + mod hrmp_channels; mod reserve_transfer; mod send; diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml b/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml index 8348fa831a..eb01b282b8 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml +++ b/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml @@ -8,45 +8,31 @@ description = "Asset Hub Polkadot runtime integration tests with xcm-emulator" publish = false [dependencies] -codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.4.0" } # Substrate -sp-runtime = { default-features = false, version = "28.0.0" } -frame-support = { default-features = false, version = "25.0.0" } -frame-system = { default-features = false, version = "25.0.0" } -pallet-assets = { default-features = false, version = "26.0.0" } -pallet-balances = { default-features = false, version = "25.0.0" } -pallet-asset-conversion = { default-features = false, version = "7.0.0" } +sp-runtime = { version = "28.0.0" } +frame-support = { version = "25.0.0" } +frame-system = { version = "25.0.0" } +pallet-assets = { version = "26.0.0" } +pallet-balances = { version = "25.0.0" } +pallet-asset-conversion = { version = "7.0.0" } # Polkadot -polkadot-core-primitives = { default-features = false, version = "4.0.0" } -polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } -polkadot-runtime-parachains = { default-features = false, version = "4.0.0" } -xcm = { package = "staging-xcm", default-features = false, version = "4.0.0" } -pallet-xcm = { default-features = false, version = "4.0.0" } +polkadot-core-primitives = { version = "4.0.0" } +polkadot-parachain-primitives = { version = "3.0.0" } +polkadot-runtime-parachains = { version = "4.0.0" } +xcm = { package = "staging-xcm", version = "4.0.0" } +pallet-xcm = { version = "4.0.0" } # Cumulus -parachains-common = { default-features = false, version = "4.0.0" } +parachains-common = { version = "4.0.0" } xcm-emulator = { version = "0.2.0" } # Local -integration-tests-common = { path = "../../common", default-features = false} +integration-tests-common = { path = "../../common" } [features] -default = [ "std" ] - -std = [ - "sp-runtime/std", - "frame-support/std", - "frame-system/std", - "pallet-assets/std", - "pallet-balances/std", - "pallet-asset-conversion/std", - "polkadot-core-primitives/std", - "polkadot-parachain-primitives/std", - "polkadot-runtime-parachains/std", - "xcm/std", - "pallet-xcm/std", - "parachains-common/std", - "integration-tests-common/std", +runtime-benchmarks = [ + "integration-tests-common/runtime-benchmarks" ] diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index e8ba8e44f2..8daf8c81e7 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![cfg(not(feature = "runtime-benchmarks"))] + pub use codec::Encode; pub use frame_support::{ assert_err, assert_ok, @@ -49,7 +51,7 @@ pub type RelayToSystemParaTest = Test; pub type SystemParaToRelayTest = Test; pub type SystemParaToParaTest = Test; -/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests +/// Returns a `TestArgs` instance to be used for the Relay Chain across integration tests pub fn relay_test_args(amount: Balance) -> TestArgs { TestArgs { dest: Polkadot::child_location_of(AssetHubPolkadot::para_id()), @@ -66,7 +68,7 @@ pub fn relay_test_args(amount: Balance) -> TestArgs { } } -/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests +/// Returns a `TestArgs` instance to be used for the System Parachain across integration tests pub fn system_para_test_args( dest: MultiLocation, beneficiary_id: AccountId32, diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs index c22de4f1c3..27c92c543b 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![cfg(not(feature = "runtime-benchmarks"))] + mod hrmp_channels; mod reserve_transfer; mod send; diff --git a/integration-tests/emulated/common/Cargo.toml b/integration-tests/emulated/common/Cargo.toml index f01331bfd1..311cbbdd45 100644 --- a/integration-tests/emulated/common/Cargo.toml +++ b/integration-tests/emulated/common/Cargo.toml @@ -7,53 +7,53 @@ license = "Apache-2.0" description = "Common resources for integration testing with xcm-emulator" [dependencies] -codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.4.0" } paste = "1.0.14" serde_json = "1.0.108" # Substrate -grandpa-primitives = { package = "sp-consensus-grandpa", default-features = false, version = "10.0.0" } -sp-authority-discovery = { default-features = false, version = "23.0.0" } -sp-runtime = { default-features = false, version = "28.0.0" } -frame-support = { default-features = false, version = "25.0.0" } -sp-core = { default-features = false, version = "25.0.0" } -sp-consensus-babe = { default-features = false, version = "0.29.0" } -pallet-assets = { default-features = false, version = "26.0.0" } -pallet-balances = { default-features = false, version = "25.0.0" } -pallet-message-queue = { default-features = false, version = "28.0.0" } -pallet-im-online = { default-features = false, version = "24.0.0" } -pallet-staking = { default-features = false , version = "25.0.0" } -beefy-primitives = { package = "sp-consensus-beefy", default-features = false, version = "10.0.0" } +grandpa-primitives = { package = "sp-consensus-grandpa", version = "10.0.0" } +sp-authority-discovery = { version = "23.0.0" } +sp-runtime = { version = "28.0.0" } +frame-support = { version = "25.0.0" } +sp-core = { version = "25.0.0" } +sp-consensus-babe = { version = "0.29.0" } +pallet-assets = { version = "26.0.0" } +pallet-balances = { version = "25.0.0" } +pallet-message-queue = { version = "28.0.0" } +pallet-im-online = { version = "24.0.0" } +pallet-staking = { version = "25.0.0" } +beefy-primitives = { package = "sp-consensus-beefy", version = "10.0.0" } # Polkadot -polkadot-service = { default-features = false, features = ["full-node"], version = "4.0.0" } -polkadot-primitives = { default-features = false, version = "4.0.0" } -polkadot-runtime-parachains = { default-features = false, version = "4.0.0" } -xcm = { package = "staging-xcm", default-features = false, version = "4.0.0" } -pallet-xcm = { default-features = false, version = "4.0.0" } -polkadot-core-primitives = { default-features = false, version = "4.0.0" } -polkadot-parachain-primitives = { default-features = false, version = "3.0.0" } +polkadot-service = { features = ["full-node"], version = "4.0.0" } +polkadot-primitives = { version = "4.0.0" } +polkadot-runtime-parachains = { version = "4.0.0" } +xcm = { package = "staging-xcm", version = "4.0.0" } +pallet-xcm = { version = "4.0.0" } +polkadot-core-primitives = { version = "4.0.0" } +polkadot-parachain-primitives = { version = "3.0.0" } # Cumulus -parachains-common = { default-features = false, version = "4.0.0" } -cumulus-primitives-core = { default-features = false, version = "0.4.0" } +parachains-common = { version = "4.0.0" } +cumulus-primitives-core = { version = "0.4.0" } xcm-emulator = { version = "0.2.0" } -cumulus-pallet-xcmp-queue = { default-features = false, version = "0.4.0" } -cumulus-pallet-parachain-system = { default-features = false, features = ["parameterized-consensus-hook",] , version = "0.4.0" } +cumulus-pallet-xcmp-queue = { version = "0.4.0" } +cumulus-pallet-parachain-system = { features = ["parameterized-consensus-hook",] , version = "0.4.0" } asset-test-utils = { version = "4.0.0" } -cumulus-pallet-dmp-queue = { default-features = false , version = "0.4.0" } -penpal-runtime = { default-features = false, version = "0.11.0" } +cumulus-pallet-dmp-queue = { version = "0.4.0" } +penpal-runtime = { version = "0.11.0" } # Local runtimes -kusama-runtime = { package = "staging-kusama-runtime", path = "../../../relay/kusama", default-features = false } -kusama-runtime-constants = { path = "../../../relay/kusama/constants", default-features = false } -polkadot-runtime = { path = "../../../relay/polkadot", default-features = false } -polkadot-runtime-constants = { path = "../../../relay/polkadot/constants", default-features = false } -asset-hub-polkadot-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-polkadot", default-features = false } -asset-hub-kusama-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-kusama", default-features = false } -collectives-polkadot-runtime = { path = "../../../system-parachains/collectives/collectives-polkadot", default-features = false } -bridge-hub-polkadot-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-polkadot", default-features = false } -bridge-hub-kusama-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-kusama", default-features = false } +kusama-runtime = { package = "staging-kusama-runtime", path = "../../../relay/kusama" } +kusama-runtime-constants = { path = "../../../relay/kusama/constants" } +polkadot-runtime = { path = "../../../relay/polkadot" } +polkadot-runtime-constants = { path = "../../../relay/polkadot/constants" } +asset-hub-polkadot-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-polkadot" } +asset-hub-kusama-runtime = { path = "../../../system-parachains/asset-hubs/asset-hub-kusama" } +collectives-polkadot-runtime = { path = "../../../system-parachains/collectives/collectives-polkadot" } +bridge-hub-polkadot-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-polkadot" } +bridge-hub-kusama-runtime = { path = "../../../system-parachains/bridge-hubs/bridge-hub-kusama" } # Bridges bp-messages = { version = "0.4.0" } @@ -61,21 +61,6 @@ pallet-bridge-messages = { version = "0.4.0" } bridge-runtime-common = { version = "0.4.0" } [features] -default = [ "std" ] - -std = [ - "sp-core/std", - "bp-messages/std", - "pallet-bridge-messages/std", - "bridge-runtime-common/std", - "penpal-runtime/std", - "kusama-runtime/std", - "kusama-runtime-constants/std", - "polkadot-runtime/std", - "polkadot-runtime-constants/std", - "asset-hub-polkadot-runtime/std", - "asset-hub-kusama-runtime/std", - "collectives-polkadot-runtime/std", - "bridge-hub-polkadot-runtime/std", - "bridge-hub-kusama-runtime/std", +runtime-benchmarks = [ + "penpal-runtime/runtime-benchmarks" ] diff --git a/integration-tests/emulated/common/src/lib.rs b/integration-tests/emulated/common/src/lib.rs index add6635915..d2eb63090f 100644 --- a/integration-tests/emulated/common/src/lib.rs +++ b/integration-tests/emulated/common/src/lib.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![cfg(not(feature = "runtime-benchmarks"))] + pub mod constants; pub mod impls; pub mod xcm_helpers; From 016ed174d0b0bd0ec3dfb073d8fae93edc188b48 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 13 Dec 2023 16:52:18 +0200 Subject: [PATCH 14/18] CI: build WASMs to be used in integration-tests --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d6acedab4..6ec7604957 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,7 +55,6 @@ jobs: run: cargo test --workspace --release --locked -q --features=runtime-metrics,try-runtime env: RUSTFLAGS: "-C debug-assertions -D warnings" - SKIP_WASM_BUILD: 0 - name: Test all features run: cargo test --workspace --release --locked -q --features=runtime-benchmarks,runtime-metrics,try-runtime From f9e09b22e94a475e2be2cc611c78d6ab47807477 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Mon, 18 Dec 2023 12:20:04 +0200 Subject: [PATCH 15/18] integration-tests: round up/down weight_within_threshold estimations --- .../assets/asset-hub-kusama/src/tests/hrmp_channels.rs | 4 ++-- .../asset-hub-kusama/src/tests/reserve_transfer.rs | 10 +++++----- .../emulated/assets/asset-hub-kusama/src/tests/send.rs | 2 +- .../asset-hub-kusama/src/tests/set_xcm_versions.rs | 2 +- .../assets/asset-hub-kusama/src/tests/teleport.rs | 10 +++++----- .../asset-hub-polkadot/src/tests/hrmp_channels.rs | 4 ++-- .../asset-hub-polkadot/src/tests/reserve_transfer.rs | 10 +++++----- .../assets/asset-hub-polkadot/src/tests/send.rs | 2 +- .../asset-hub-polkadot/src/tests/set_xcm_versions.rs | 2 +- .../assets/asset-hub-polkadot/src/tests/teleport.rs | 10 +++++----- integration-tests/emulated/common/src/impls.rs | 2 +- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs index 3c3342d9ca..f930e3182c 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs @@ -62,7 +62,7 @@ fn open_hrmp_channel_between_paras_works() { Kusama::assert_ump_queue_processed( true, Some(para_a_id), - Some(Weight::from_parts(1_312_558_000, 200000)), + Some(Weight::from_parts(1_300_000_000, 200000)), ); assert_expected_events!( @@ -119,7 +119,7 @@ fn open_hrmp_channel_between_paras_works() { Kusama::assert_ump_queue_processed( true, Some(para_b_id), - Some(Weight::from_parts(1_312_558_000, 200_000)), + Some(Weight::from_parts(1_300_000_000, 200_000)), ); assert_expected_events!( diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs index 9f107b9950..92c320e300 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs @@ -18,7 +18,7 @@ use crate::*; fn relay_origin_assertions(t: RelayToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; - Kusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(630_092_000, 6_196))); + Kusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(630_000_000, 6_000))); assert_expected_events!( Kusama, @@ -47,8 +47,8 @@ fn system_para_to_para_assertions(t: SystemParaToParaTest) { type RuntimeEvent = ::RuntimeEvent; AssetHubKusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 630_092_000, - 6_196, + 630_000_000, + 6_000, ))); assert_expected_events!( @@ -72,8 +72,8 @@ fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) { type RuntimeEvent = ::RuntimeEvent; AssetHubKusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 676_119_000, - 6196, + 680_000_000, + 6000, ))); assert_expected_events!( diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs index 4256ca087e..face60a3a5 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/send.rs @@ -45,7 +45,7 @@ fn send_transact_sudo_from_relay_to_system_para_works() { AssetHubKusama::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; - AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(1_019_445_000, 200_000))); + AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(1_020_000_000, 200_000))); assert_expected_events!( AssetHubKusama, diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/set_xcm_versions.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/set_xcm_versions.rs index a7af96096c..4b2716e90f 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/set_xcm_versions.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/set_xcm_versions.rs @@ -78,7 +78,7 @@ fn system_para_sets_relay_xcm_supported_version() { AssetHubKusama::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; - AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(1_019_210_000, 200_000))); + AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(1_020_000_000, 200_000))); assert_expected_events!( AssetHubKusama, diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs index a7b05808c1..30da0d9edf 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -20,7 +20,7 @@ use crate::*; fn relay_origin_assertions(t: RelayToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; - Kusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(631_531_000, 7_186))); + Kusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(630_000_000, 7_000))); assert_expected_events!( Kusama, @@ -45,7 +45,7 @@ fn relay_dest_assertions(t: SystemParaToRelayTest) { Kusama::assert_ump_queue_processed( true, Some(AssetHubKusama::para_id()), - Some(Weight::from_parts(307_225_000, 7_186)), + Some(Weight::from_parts(310_000_000, 7_000)), ); assert_expected_events!( @@ -68,7 +68,7 @@ fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { Kusama::assert_ump_queue_processed( false, Some(AssetHubKusama::para_id()), - Some(Weight::from_parts(148_433_000, 3_593)), + Some(Weight::from_parts(150_000_000, 3_500)), ); } @@ -76,8 +76,8 @@ fn para_origin_assertions(t: SystemParaToRelayTest) { type RuntimeEvent = ::RuntimeEvent; AssetHubKusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 534_872_000, - 7_133, + 535_000_000, + 7_000, ))); AssetHubKusama::assert_parachain_system_ump_sent(); diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs index ebe48a41b7..731e601aea 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/hrmp_channels.rs @@ -62,7 +62,7 @@ fn open_hrmp_channel_between_paras_works() { Polkadot::assert_ump_queue_processed( true, Some(para_a_id), - Some(Weight::from_parts(1_282_426_000, 207_186)), + Some(Weight::from_parts(1_300_000_000, 207_000)), ); assert_expected_events!( @@ -116,7 +116,7 @@ fn open_hrmp_channel_between_paras_works() { Polkadot::assert_ump_queue_processed( true, Some(para_b_id), - Some(Weight::from_parts(1_282_426_000, 207_186)), + Some(Weight::from_parts(1_300_000_000, 207_000)), ); assert_expected_events!( diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs index 16a7d69d8e..5d4d437df2 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs @@ -18,7 +18,7 @@ use crate::*; fn relay_origin_assertions(t: RelayToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; - Polkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(629_384_000, 6_196))); + Polkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(630_000_000, 6_000))); assert_expected_events!( Polkadot, @@ -47,8 +47,8 @@ fn system_para_to_para_assertions(t: SystemParaToParaTest) { type RuntimeEvent = ::RuntimeEvent; AssetHubPolkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 676_119_000, - 6196, + 680_000_000, + 6000, ))); assert_expected_events!( @@ -72,8 +72,8 @@ fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) { type RuntimeEvent = ::RuntimeEvent; AssetHubPolkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 676_119_000, - 6196, + 680_000_000, + 6000, ))); assert_expected_events!( diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs index 1ede54a4d3..86ee5838b4 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/send.rs @@ -46,7 +46,7 @@ fn send_transact_sudo_from_relay_to_system_para_works() { type RuntimeEvent = ::RuntimeEvent; AssetHubPolkadot::assert_dmp_queue_complete(Some(Weight::from_parts( - 1_019_445_000, + 1_020_000_000, 200_000, ))); diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/set_xcm_versions.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/set_xcm_versions.rs index e121c41679..8ec3ab4426 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/set_xcm_versions.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/set_xcm_versions.rs @@ -79,7 +79,7 @@ fn system_para_sets_relay_xcm_supported_version() { type RuntimeEvent = ::RuntimeEvent; AssetHubPolkadot::assert_dmp_queue_complete(Some(Weight::from_parts( - 1_019_210_000, + 1_020_000_000, 200_000, ))); diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs index 0dd20094ab..11bc31d7fd 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -20,7 +20,7 @@ use crate::*; fn relay_origin_assertions(t: RelayToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; - Polkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(632_207_000, 7_186))); + Polkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(635_000_000, 7_000))); assert_expected_events!( Polkadot, @@ -45,7 +45,7 @@ fn relay_dest_assertions(t: SystemParaToRelayTest) { Polkadot::assert_ump_queue_processed( true, Some(AssetHubPolkadot::para_id()), - Some(Weight::from_parts(368_931_000, 7_186)), + Some(Weight::from_parts(370_000_000, 7_000)), ); assert_expected_events!( @@ -68,7 +68,7 @@ fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { Polkadot::assert_ump_queue_processed( false, Some(AssetHubPolkadot::para_id()), - Some(Weight::from_parts(232_982_000, 3_593)), + Some(Weight::from_parts(235_000_000, 3_500)), ); } @@ -76,8 +76,8 @@ fn para_origin_assertions(t: SystemParaToRelayTest) { type RuntimeEvent = ::RuntimeEvent; AssetHubPolkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 632_207_000, - 7_186, + 635_000_000, + 7_000, ))); AssetHubPolkadot::assert_parachain_system_ump_sent(); diff --git a/integration-tests/emulated/common/src/impls.rs b/integration-tests/emulated/common/src/impls.rs index bcc5552f19..5969b8ac84 100644 --- a/integration-tests/emulated/common/src/impls.rs +++ b/integration-tests/emulated/common/src/impls.rs @@ -616,7 +616,7 @@ macro_rules! impl_assets_helpers_for_parachain { }); Self::execute_with(|| { - Self::assert_dmp_queue_complete(Some($crate::impls::Weight::from_parts(1_019_445_000, 200_000))); + Self::assert_dmp_queue_complete(Some($crate::impls::Weight::from_parts(1_020_000_000, 200_000))); type RuntimeEvent = <$chain as $crate::impls::Chain>::RuntimeEvent; From 1881195de8421934c4507fc8d2daf4c05f1cf03b Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Mon, 18 Dec 2023 20:09:31 +0200 Subject: [PATCH 16/18] integration-tests: remove dep on polkadot-service --- Cargo.lock | 1658 ++--------------- integration-tests/emulated/common/Cargo.toml | 1 - .../emulated/common/src/constants.rs | 19 +- 3 files changed, 157 insertions(+), 1521 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2a45b9cff..e59cb4ac97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -185,12 +185,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" -[[package]] -name = "always-assert" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" - [[package]] name = "android-tzdata" version = "0.1.1" @@ -1950,17 +1944,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "comfy-table" -version = "7.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" -dependencies = [ - "strum 0.25.0", - "strum_macros 0.25.3", - "unicode-width", -] - [[package]] name = "common-path" version = "1.0.0" @@ -2075,16 +2058,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "cpu-time" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "cpufeatures" version = "0.2.9" @@ -3520,55 +3493,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "frame-benchmarking-cli" -version = "29.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e51c371bff90ba44767a79e72a036d7d648cee621cd2fe9f693e8c1d62941e" -dependencies = [ - "Inflector", - "array-bytes 6.1.0", - "chrono", - "clap", - "comfy-table", - "frame-benchmarking", - "frame-support", - "frame-system", - "gethostname", - "handlebars", - "itertools 0.10.5", - "lazy_static", - "linked-hash-map", - "log", - "parity-scale-codec", - "rand 0.8.5", - "rand_pcg", - "sc-block-builder", - "sc-cli", - "sc-client-api", - "sc-client-db", - "sc-executor", - "sc-service", - "sc-sysinfo", - "serde", - "serde_json", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-database", - "sp-externalities", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-runtime", - "sp-state-machine", - "sp-storage", - "sp-trie", - "sp-wasm-interface", - "thiserror", - "thousands", -] - [[package]] name = "frame-election-provider-solution-type" version = "12.0.0" @@ -3969,16 +3893,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "gethostname" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "getrandom" version = "0.1.16" @@ -4136,20 +4050,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "handlebars" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" -dependencies = [ - "log", - "pest", - "pest_derive", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "hash-db" version = "0.16.0" @@ -4631,7 +4531,6 @@ dependencies = [ "polkadot-runtime", "polkadot-runtime-constants", "polkadot-runtime-parachains", - "polkadot-service", "serde_json", "sp-authority-discovery", "sp-consensus-babe", @@ -4709,15 +4608,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "is_executable" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa9acdc6d67b75e626ad644734e8bc6df893d9cd2a834129065d3dd6158ea9c8" -dependencies = [ - "winapi", -] - [[package]] name = "itertools" version = "0.10.5" @@ -4979,17 +4869,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "landlock" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1530c5b973eeed4ac216af7e24baf5737645a6272e361f1fb95710678b67d9cc" -dependencies = [ - "enumflags2", - "libc", - "thiserror", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -5886,43 +5765,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "mmr-gadget" -version = "26.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62eff76fd1de7bad43b0e9e666970ae11ef8c24f49622585362c21ae5470986f" -dependencies = [ - "futures", - "log", - "parity-scale-codec", - "sc-client-api", - "sc-offchain", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-consensus-beefy", - "sp-core", - "sp-mmr-primitives", - "sp-runtime", -] - -[[package]] -name = "mmr-rpc" -version = "25.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a387f061e68601d268aade23387eaaf6542e82b357ebc1f8d6a95a251b996d30" -dependencies = [ - "anyhow", - "jsonrpsee", - "parity-scale-codec", - "serde", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-mmr-primitives", - "sp-runtime", -] - [[package]] name = "mockall" version = "0.11.4" @@ -6220,7 +6062,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", - "num-bigint", "num-integer", "num-traits", ] @@ -6893,7 +6734,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "strum 0.24.1", + "strum", ] [[package]] @@ -7621,23 +7462,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-transaction-payment-rpc" -version = "27.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99adb3915b29d04362648a4be9114de3bfe37c431f214b1ef96b71f358950d9d" -dependencies = [ - "jsonrpsee", - "pallet-transaction-payment-rpc-runtime-api", - "parity-scale-codec", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-rpc", - "sp-runtime", - "sp-weights", -] - [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "25.0.0" @@ -8132,51 +7956,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" -[[package]] -name = "pest" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" -dependencies = [ - "memchr", - "thiserror", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "pest_meta" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" -dependencies = [ - "once_cell", - "pest", - "sha2 0.10.7", -] - [[package]] name = "petgraph" version = "0.6.4" @@ -8258,640 +8037,110 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] -name = "polkadot-approval-distribution" +name = "polkadot-core-primitives" version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcdaca311b3f8ea463548cc2f62289a2689d3198ea8cba2d100fab378fff3c" +checksum = "b08d1d6ca24e1b13f8069e015cfab794344212dd7436aadd61de8086a82664ef" dependencies = [ - "futures", - "futures-timer", - "polkadot-node-jaeger", - "polkadot-node-metrics", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "rand 0.8.5", - "tracing-gum", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", ] [[package]] -name = "polkadot-availability-bitfield-distribution" +name = "polkadot-node-jaeger" version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "316fa25f773ac3f470578d2dc2ff73cefc2a01c9ea0a9a00767529184701792c" +checksum = "2cfe6d4769181dce55b1b8fc53f0bd85bb4aa20473702fbce95a94abafa19379" dependencies = [ - "always-assert", - "futures", - "futures-timer", - "polkadot-node-network-protocol", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", + "lazy_static", + "log", + "mick-jaeger", + "parity-scale-codec", + "parking_lot 0.12.1", + "polkadot-node-primitives", "polkadot-primitives", - "rand 0.8.5", - "tracing-gum", + "sc-network", + "sp-core", + "thiserror", + "tokio", ] [[package]] -name = "polkadot-availability-distribution" +name = "polkadot-node-metrics" version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "118ed63ece1ec1ccf240ab44d932a932ae778ece57a6fba34953b7c0b436f6b1" +checksum = "c51a586fc3ef87c685588a650c18882b4cf069d8adc0d7d9bd2670749cb4e82b" dependencies = [ - "derive_more", - "fatality", + "bs58 0.5.0", "futures", + "futures-timer", + "log", "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", "polkadot-primitives", - "rand 0.8.5", - "schnellru", - "sp-core", - "sp-keystore", - "thiserror", + "prioritized-metered-channel", + "sc-cli", + "sc-service", + "sc-tracing", + "substrate-prometheus-endpoint", "tracing-gum", ] [[package]] -name = "polkadot-availability-recovery" +name = "polkadot-node-network-protocol" version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13245b9f37a4d409c47cf46f74d2601df82f1bf12678b1a792ad1aa5effebd13" +checksum = "f6de513655bf71400299cda1ccaebfa612fd3965e7ce5a9120b4ff37bfc80931" dependencies = [ + "async-channel", "async-trait", + "bitvec", + "derive_more", "fatality", "futures", + "hex", "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-network-protocol", + "polkadot-node-jaeger", "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", "polkadot-primitives", "rand 0.8.5", + "sc-authority-discovery", "sc-network", - "schnellru", + "strum", "thiserror", "tracing-gum", ] [[package]] -name = "polkadot-collator-protocol" +name = "polkadot-node-primitives" version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f5ed0e739de576e41203ba99b9da1347998174a84fb5ea825f1a8e30e1dff88" +checksum = "3e82ee5edac871310bd1ce16a035ad2fc901d6ddd69ea0bbabc7f0a70a02770a" dependencies = [ - "bitvec", - "fatality", + "bounded-vec", "futures", - "futures-timer", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", + "parity-scale-codec", + "polkadot-parachain-primitives", "polkadot-primitives", + "schnorrkel", + "serde", + "sp-application-crypto", + "sp-consensus-babe", "sp-core", "sp-keystore", + "sp-maybe-compressed-blob", "sp-runtime", "thiserror", - "tokio-util", - "tracing-gum", + "zstd 0.12.4", ] [[package]] -name = "polkadot-core-primitives" +name = "polkadot-node-subsystem-types" version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b08d1d6ca24e1b13f8069e015cfab794344212dd7436aadd61de8086a82664ef" -dependencies = [ - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "polkadot-dispute-distribution" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffa05fec2897e38a2ec42df5f84110fbb170dbe549d5d1e454f635b141cb2aca" -dependencies = [ - "derive_more", - "fatality", - "futures", - "futures-timer", - "indexmap 1.9.3", - "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sc-network", - "schnellru", - "sp-application-crypto", - "sp-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-erasure-coding" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9714c537368095f1bc2e70c45fb8ae3347c19b344f8d5b4722cc781690a74924" -dependencies = [ - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-primitives", - "reed-solomon-novelpoly", - "sp-core", - "sp-trie", - "thiserror", -] - -[[package]] -name = "polkadot-gossip-support" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9acc782f4c0efb0809cc325a49b50c498255a973dfc665e940043af20936d525" -dependencies = [ - "futures", - "futures-timer", - "polkadot-node-network-protocol", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "rand 0.8.5", - "rand_chacha 0.3.1", - "sc-network", - "sc-network-common", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "tracing-gum", -] - -[[package]] -name = "polkadot-network-bridge" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7355e7f9cac8e5fe4899796e92aea2ea94678854dc44e21890a33d4c6c6ec3" -dependencies = [ - "always-assert", - "async-trait", - "bytes", - "fatality", - "futures", - "parity-scale-codec", - "parking_lot 0.12.1", - "polkadot-node-metrics", - "polkadot-node-network-protocol", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "sc-network", - "sp-consensus", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-collation-generation" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bed91a561c9edfc5bd1d8e432cec8cecde63aaf12131cc19881d67e39be0fce" -dependencies = [ - "futures", - "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sp-core", - "sp-maybe-compressed-blob", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-approval-voting" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976e5fcd0c10fbe37d120a9e4702324585e529498c56d03fd7b529f17644fe34" -dependencies = [ - "bitvec", - "derive_more", - "futures", - "futures-timer", - "kvdb", - "merlin", - "parity-scale-codec", - "polkadot-node-jaeger", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-primitives", - "sc-keystore", - "schnellru", - "schnorrkel", - "sp-application-crypto", - "sp-consensus", - "sp-consensus-slots", - "sp-runtime", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-av-store" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9d1018400db515cec0748e4c83d6010601d1784350dfd465386a7ee47699cd3" -dependencies = [ - "bitvec", - "futures", - "futures-timer", - "kvdb", - "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-jaeger", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-primitives", - "sp-consensus", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-backing" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051940f4f7214dcc370077ead642052cda2c7316641ea9ff1f05624be2a272d2" -dependencies = [ - "bitvec", - "fatality", - "futures", - "polkadot-erasure-coding", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "polkadot-statement-table", - "sp-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-bitfield-signing" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77cea47f010914b5e52f2f1eb96c058cb117045c5864c733236e7b24ea103d22" -dependencies = [ - "futures", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sp-keystore", - "thiserror", - "tracing-gum", - "wasm-timer", -] - -[[package]] -name = "polkadot-node-core-candidate-validation" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb2306632d1ee08cc2f4d5945b4ec795fd79ce801ae03e79961c18877220ed2" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "parity-scale-codec", - "polkadot-node-core-pvf", - "polkadot-node-metrics", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-parachain-primitives", - "polkadot-primitives", - "sp-maybe-compressed-blob", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-chain-api" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e8787fcec6e036d21421adf3db0295c142a878c482e0aba2e5aefcf050f10" -dependencies = [ - "futures", - "polkadot-node-metrics", - "polkadot-node-subsystem", - "polkadot-primitives", - "sc-client-api", - "sc-consensus-babe", - "sp-blockchain", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-chain-selection" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8028469b10f5f1fa10ea9b08cb09bb53bcb55a25298e4154928d3aaf7d5d066a" -dependencies = [ - "futures", - "futures-timer", - "kvdb", - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-dispute-coordinator" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662387f0e7b23596326754796fbb6f52e32c3deb0c11f9ff341e23a0a7139608" -dependencies = [ - "fatality", - "futures", - "kvdb", - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sc-keystore", - "schnellru", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-parachains-inherent" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f57ce13de845fe1441fa3ab3405dcb142d3dc0ea985c4e28efa35b97d07d0" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "sp-blockchain", - "sp-inherents", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-prospective-parachains" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a010a14312c5c5eec800397cc60cce10131d4a29cedf563ee639fc7b9b27ba1" -dependencies = [ - "bitvec", - "fatality", - "futures", - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-provisioner" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a67ac3aa0a0e89ff20d5eb761fca78c124848a2627e35343e824d78cc9fe91" -dependencies = [ - "bitvec", - "fatality", - "futures", - "futures-timer", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-pvf" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f58224dbfbd773947ff3fccc3318bda11909e8a0f7c36f7f1234c0c1f25a62a" -dependencies = [ - "always-assert", - "cfg-if", - "futures", - "futures-timer", - "is_executable", - "libc", - "parity-scale-codec", - "pin-project", - "polkadot-core-primitives", - "polkadot-node-core-pvf-common", - "polkadot-node-metrics", - "polkadot-node-primitives", - "polkadot-parachain-primitives", - "polkadot-primitives", - "rand 0.8.5", - "slotmap", - "sp-core", - "sp-maybe-compressed-blob", - "sp-wasm-interface", - "tempfile", - "tokio", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-pvf-checker" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe14484e66b365748bd4b2988cc2c68e03146bc399bdf8139f9eb5cf6c6cf0" -dependencies = [ - "futures", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-primitives", - "sp-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-pvf-common" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94004d011a260b8efdf6ddf80ac815ba6ede84bb46e32d588161c1d860c5a65d" -dependencies = [ - "cfg-if", - "cpu-time", - "futures", - "landlock", - "libc", - "parity-scale-codec", - "polkadot-parachain-primitives", - "polkadot-primitives", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", - "sp-core", - "sp-externalities", - "sp-io", - "sp-tracing", - "tokio", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-runtime-api" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dccc7a95fea3562bd3a47f22c0e4ddcb755114dc0477f3173db8d5ebf0d84f50" -dependencies = [ - "futures", - "polkadot-node-metrics", - "polkadot-node-subsystem", - "polkadot-node-subsystem-types", - "polkadot-primitives", - "schnellru", - "sp-consensus-babe", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-jaeger" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfe6d4769181dce55b1b8fc53f0bd85bb4aa20473702fbce95a94abafa19379" -dependencies = [ - "lazy_static", - "log", - "mick-jaeger", - "parity-scale-codec", - "parking_lot 0.12.1", - "polkadot-node-primitives", - "polkadot-primitives", - "sc-network", - "sp-core", - "thiserror", - "tokio", -] - -[[package]] -name = "polkadot-node-metrics" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51a586fc3ef87c685588a650c18882b4cf069d8adc0d7d9bd2670749cb4e82b" -dependencies = [ - "bs58 0.5.0", - "futures", - "futures-timer", - "log", - "parity-scale-codec", - "polkadot-primitives", - "prioritized-metered-channel", - "sc-cli", - "sc-service", - "sc-tracing", - "substrate-prometheus-endpoint", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-network-protocol" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6de513655bf71400299cda1ccaebfa612fd3965e7ce5a9120b4ff37bfc80931" -dependencies = [ - "async-channel", - "async-trait", - "bitvec", - "derive_more", - "fatality", - "futures", - "hex", - "parity-scale-codec", - "polkadot-node-jaeger", - "polkadot-node-primitives", - "polkadot-primitives", - "rand 0.8.5", - "sc-authority-discovery", - "sc-network", - "strum 0.24.1", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-primitives" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e82ee5edac871310bd1ce16a035ad2fc901d6ddd69ea0bbabc7f0a70a02770a" -dependencies = [ - "bounded-vec", - "futures", - "parity-scale-codec", - "polkadot-parachain-primitives", - "polkadot-primitives", - "schnorrkel", - "serde", - "sp-application-crypto", - "sp-consensus-babe", - "sp-core", - "sp-keystore", - "sp-maybe-compressed-blob", - "sp-runtime", - "thiserror", - "zstd 0.12.4", -] - -[[package]] -name = "polkadot-node-subsystem" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e89d3f964ebd57275c2fff4d3cc755d210698fedeac1a0a238c0eb31534c96d" -dependencies = [ - "polkadot-node-jaeger", - "polkadot-node-subsystem-types", - "polkadot-overseer", -] - -[[package]] -name = "polkadot-node-subsystem-types" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1013b3bac6e9b76bbd71433c3eba36b5c0fa9306bfc473ec02e3a104e156d2" +checksum = "8e1013b3bac6e9b76bbd71433c3eba36b5c0fa9306bfc473ec02e3a104e156d2" dependencies = [ "async-trait", "derive_more", @@ -8913,42 +8162,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "polkadot-node-subsystem-util" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8134075bfee921305ff229412e9282a3351215bf049c6a403197cc795f919941" -dependencies = [ - "async-trait", - "derive_more", - "fatality", - "futures", - "futures-channel", - "itertools 0.10.5", - "kvdb", - "parity-db", - "parity-scale-codec", - "parking_lot 0.11.2", - "pin-project", - "polkadot-node-jaeger", - "polkadot-node-metrics", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-types", - "polkadot-overseer", - "polkadot-primitives", - "prioritized-metered-channel", - "rand 0.8.5", - "sc-client-api", - "schnellru", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "thiserror", - "tracing-gum", -] - [[package]] name = "polkadot-overseer" version = "4.0.0" @@ -9017,39 +8230,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "polkadot-rpc" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce0432643ea2e4923db1f0ba6c82305c53725e18c857e911c4d979e4f7aafae5" -dependencies = [ - "jsonrpsee", - "mmr-rpc", - "pallet-transaction-payment-rpc", - "polkadot-primitives", - "sc-chain-spec", - "sc-client-api", - "sc-consensus-babe", - "sc-consensus-babe-rpc", - "sc-consensus-beefy", - "sc-consensus-beefy-rpc", - "sc-consensus-epochs", - "sc-consensus-grandpa", - "sc-consensus-grandpa-rpc", - "sc-rpc", - "sc-sync-state-rpc", - "sc-transaction-pool-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-keystore", - "sp-runtime", - "substrate-frame-rpc-system", - "substrate-state-trie-migration-rpc", -] - [[package]] name = "polkadot-runtime" version = "1.0.0" @@ -9270,164 +8450,24 @@ dependencies = [ "polkadot-primitives", "polkadot-runtime-metrics", "rand 0.8.5", - "rand_chacha 0.3.1", - "rustc-hex", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-tracing", - "staging-xcm", - "staging-xcm-executor", - "static_assertions", -] - -[[package]] -name = "polkadot-service" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc65d44c4dd6a8be74194dcac66552dd4e79ee0bcc287349721925e8238177a" -dependencies = [ - "async-trait", - "frame-benchmarking", - "frame-benchmarking-cli", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "futures", - "hex-literal", - "is_executable", - "kvdb", - "kvdb-rocksdb", - "log", - "mmr-gadget", - "pallet-babe", - "pallet-im-online", - "pallet-staking", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "parity-db", - "parity-scale-codec", - "polkadot-approval-distribution", - "polkadot-availability-bitfield-distribution", - "polkadot-availability-distribution", - "polkadot-availability-recovery", - "polkadot-collator-protocol", - "polkadot-core-primitives", - "polkadot-dispute-distribution", - "polkadot-gossip-support", - "polkadot-network-bridge", - "polkadot-node-collation-generation", - "polkadot-node-core-approval-voting", - "polkadot-node-core-av-store", - "polkadot-node-core-backing", - "polkadot-node-core-bitfield-signing", - "polkadot-node-core-candidate-validation", - "polkadot-node-core-chain-api", - "polkadot-node-core-chain-selection", - "polkadot-node-core-dispute-coordinator", - "polkadot-node-core-parachains-inherent", - "polkadot-node-core-prospective-parachains", - "polkadot-node-core-provisioner", - "polkadot-node-core-pvf", - "polkadot-node-core-pvf-checker", - "polkadot-node-core-runtime-api", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-types", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-parachain-primitives", - "polkadot-primitives", - "polkadot-rpc", - "polkadot-runtime-parachains", - "polkadot-statement-distribution", - "sc-authority-discovery", - "sc-basic-authorship", - "sc-block-builder", - "sc-chain-spec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-beefy", - "sc-consensus-grandpa", - "sc-consensus-slots", - "sc-executor", - "sc-keystore", - "sc-network", - "sc-network-common", - "sc-network-sync", - "sc-offchain", - "sc-service", - "sc-sync-state-rpc", - "sc-sysinfo", - "sc-telemetry", - "sc-transaction-pool", - "sc-transaction-pool-api", - "schnellru", - "serde", - "serde_json", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keyring", - "sp-keystore", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-state-machine", - "sp-storage", - "sp-timestamp", - "sp-transaction-pool", - "sp-version", - "sp-weights", - "substrate-prometheus-endpoint", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-statement-distribution" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6992cb6e2ba744752f9f403cb5e0f70ac5431f39f9ea859a3978f22c79799cb" -dependencies = [ - "arrayvec 0.7.4", - "bitvec", - "fatality", - "futures", - "futures-timer", - "indexmap 1.9.3", - "parity-scale-codec", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-types", - "polkadot-node-subsystem-util", - "polkadot-primitives", + "rand_chacha 0.3.1", + "rustc-hex", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-inherents", + "sp-io", "sp-keystore", + "sp-runtime", + "sp-session", "sp-staking", - "thiserror", - "tracing-gum", + "sp-std", + "sp-tracing", + "staging-xcm", + "staging-xcm-executor", + "static_assertions", ] [[package]] @@ -9989,19 +9029,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "reed-solomon-novelpoly" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58130877ca403ab42c864fbac74bb319a0746c07a634a92a5cfc7f54af272582" -dependencies = [ - "derive_more", - "fs-err", - "itertools 0.11.0", - "static_init", - "thiserror", -] - [[package]] name = "ref-cast" version = "1.0.20" @@ -10458,30 +9485,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "sc-basic-authorship" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0aa6c85e3e0b5af9cab7078166d8c4575b7b9edac0ade6be1aadee828420104" -dependencies = [ - "futures", - "futures-timer", - "log", - "parity-scale-codec", - "sc-block-builder", - "sc-client-api", - "sc-proposer-metrics", - "sc-telemetry", - "sc-transaction-pool-api", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-inherents", - "sp-runtime", - "substrate-prometheus-endpoint", -] - [[package]] name = "sc-block-builder" version = "0.30.0" @@ -10527,344 +9530,129 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", -] - -[[package]] -name = "sc-cli" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22c61058223f80c1f961b03f7737529609a3283eef91129e971a1966101c18ea" -dependencies = [ - "array-bytes 6.1.0", - "chrono", - "clap", - "fdlimit", - "futures", - "libp2p-identity", - "log", - "names", - "parity-scale-codec", - "rand 0.8.5", - "regex", - "rpassword", - "sc-client-api", - "sc-client-db", - "sc-keystore", - "sc-mixnet", - "sc-network", - "sc-service", - "sc-telemetry", - "sc-tracing", - "sc-utils", - "serde", - "serde_json", - "sp-blockchain", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-panic-handler", - "sp-runtime", - "sp-version", - "thiserror", - "tiny-bip39", - "tokio", -] - -[[package]] -name = "sc-client-api" -version = "25.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d32101f415f4d7ddbe8b5de1c1387a78d6dce070e26407ec605fe9f3fc9e23" -dependencies = [ - "fnv", - "futures", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-executor", - "sc-transaction-pool-api", - "sc-utils", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-database", - "sp-externalities", - "sp-runtime", - "sp-state-machine", - "sp-statement-store", - "sp-storage", - "sp-trie", - "substrate-prometheus-endpoint", -] - -[[package]] -name = "sc-client-db" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4ced79f609a44782874d856cf39d256838957195ef34f4fb8ced90bf4b725d0" -dependencies = [ - "hash-db", - "kvdb", - "kvdb-memorydb", - "kvdb-rocksdb", - "linked-hash-map", - "log", - "parity-db", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-client-api", - "sc-state-db", - "schnellru", - "sp-arithmetic", - "sp-blockchain", - "sp-core", - "sp-database", - "sp-runtime", - "sp-state-machine", - "sp-trie", -] - -[[package]] -name = "sc-consensus" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e4100cc8fb3876708e1ec5a7c63af3baa75febd5051beb9ddd1e4835fdfc27" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "libp2p-identity", - "log", - "mockall", - "parking_lot 0.12.1", - "sc-client-api", - "sc-utils", - "serde", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-runtime", - "sp-state-machine", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-consensus-babe" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a48ef5eaf7bffc647dfdfd42c7c02a929d89410b065beeb80753fd94f5fe70d" -dependencies = [ - "async-trait", - "fork-tree", - "futures", - "log", - "num-bigint", - "num-rational", - "num-traits", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-client-api", - "sc-consensus", - "sc-consensus-epochs", - "sc-consensus-slots", - "sc-telemetry", - "sc-transaction-pool-api", - "sp-api", - "sp-application-crypto", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-slots", - "sp-core", - "sp-inherents", - "sp-keystore", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-consensus-babe-rpc" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a78a543d8d2e8d9a6a8b60f16ac12e6fbeffbc2322ef8fa139f733ce53ccaa8" -dependencies = [ - "futures", - "jsonrpsee", - "sc-consensus-babe", - "sc-consensus-epochs", - "sc-rpc-api", - "serde", - "sp-api", - "sp-application-crypto", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-core", - "sp-keystore", - "sp-runtime", - "thiserror", -] - -[[package]] -name = "sc-consensus-beefy" -version = "10.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3709a96723feaeb7a7ca0d3f7995d084029f8effeeb09d45975a8aa3ba1a63b" -dependencies = [ - "array-bytes 6.1.0", - "async-channel", - "async-trait", - "fnv", - "futures", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-client-api", - "sc-consensus", - "sc-network", - "sc-network-gossip", - "sc-network-sync", - "sc-utils", - "sp-api", - "sp-application-crypto", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-consensus-beefy", - "sp-core", - "sp-keystore", - "sp-mmr-primitives", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", - "wasm-timer", + "syn 2.0.38", ] [[package]] -name = "sc-consensus-beefy-rpc" -version = "10.0.0" +name = "sc-cli" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1699fe1791dd985a5dd6075c84136027eb3e2ccff46d3e5273fdbd5b246f763" +checksum = "22c61058223f80c1f961b03f7737529609a3283eef91129e971a1966101c18ea" dependencies = [ + "array-bytes 6.1.0", + "chrono", + "clap", + "fdlimit", "futures", - "jsonrpsee", + "libp2p-identity", "log", + "names", "parity-scale-codec", - "parking_lot 0.12.1", - "sc-consensus-beefy", - "sc-rpc", + "rand 0.8.5", + "regex", + "rpassword", + "sc-client-api", + "sc-client-db", + "sc-keystore", + "sc-mixnet", + "sc-network", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-utils", "serde", - "sp-consensus-beefy", + "serde_json", + "sp-blockchain", "sp-core", + "sp-keyring", + "sp-keystore", + "sp-panic-handler", "sp-runtime", + "sp-version", "thiserror", + "tiny-bip39", + "tokio", ] [[package]] -name = "sc-consensus-epochs" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eafc0534bb118f614fc50fe066e423dbecfedf816cd9c43e0b492e30c1782c8" -dependencies = [ - "fork-tree", - "parity-scale-codec", - "sc-client-api", - "sc-consensus", - "sp-blockchain", - "sp-runtime", -] - -[[package]] -name = "sc-consensus-grandpa" -version = "0.16.0" +name = "sc-client-api" +version = "25.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cbc5db21ea2c4ba65b23315e73e69e8155630fb47c84b93d40b0e759c9d86d" +checksum = "c7d32101f415f4d7ddbe8b5de1c1387a78d6dce070e26407ec605fe9f3fc9e23" dependencies = [ - "ahash 0.8.3", - "array-bytes 6.1.0", - "async-trait", - "dyn-clone", - "finality-grandpa", - "fork-tree", + "fnv", "futures", - "futures-timer", "log", "parity-scale-codec", "parking_lot 0.12.1", - "rand 0.8.5", - "sc-block-builder", - "sc-chain-spec", - "sc-client-api", - "sc-consensus", - "sc-network", - "sc-network-common", - "sc-network-gossip", - "sc-telemetry", + "sc-executor", "sc-transaction-pool-api", "sc-utils", - "serde_json", "sp-api", - "sp-application-crypto", - "sp-arithmetic", "sp-blockchain", "sp-consensus", - "sp-consensus-grandpa", "sp-core", - "sp-keystore", + "sp-database", + "sp-externalities", "sp-runtime", + "sp-state-machine", + "sp-statement-store", + "sp-storage", + "sp-trie", "substrate-prometheus-endpoint", - "thiserror", ] [[package]] -name = "sc-consensus-grandpa-rpc" -version = "0.16.0" +name = "sc-client-db" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3c545dac29d5dd002170e063ca0725be95ef653be135d251f91dbe053f63173" +checksum = "d4ced79f609a44782874d856cf39d256838957195ef34f4fb8ced90bf4b725d0" dependencies = [ - "finality-grandpa", - "futures", - "jsonrpsee", + "hash-db", + "kvdb", + "kvdb-memorydb", + "kvdb-rocksdb", + "linked-hash-map", "log", + "parity-db", "parity-scale-codec", + "parking_lot 0.12.1", "sc-client-api", - "sc-consensus-grandpa", - "sc-rpc", - "serde", + "sc-state-db", + "schnellru", + "sp-arithmetic", "sp-blockchain", "sp-core", + "sp-database", "sp-runtime", - "thiserror", + "sp-state-machine", + "sp-trie", ] [[package]] -name = "sc-consensus-slots" +name = "sc-consensus" version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2059681962e33394682627e7bd7245b5094236594f5c97c4c96988d901bda534" +checksum = "86e4100cc8fb3876708e1ec5a7c63af3baa75febd5051beb9ddd1e4835fdfc27" dependencies = [ "async-trait", "futures", "futures-timer", + "libp2p-identity", "log", - "parity-scale-codec", + "mockall", + "parking_lot 0.12.1", "sc-client-api", - "sc-consensus", - "sc-telemetry", - "sp-arithmetic", + "sc-utils", + "serde", + "sp-api", "sp-blockchain", "sp-consensus", - "sp-consensus-slots", "sp-core", - "sp-inherents", "sp-runtime", "sp-state-machine", + "substrate-prometheus-endpoint", + "thiserror", ] [[package]] @@ -11064,25 +9852,6 @@ dependencies = [ "sp-runtime", ] -[[package]] -name = "sc-network-gossip" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b884a9f7cd348c4c1899c0bbf95237e39dffba4baec48d4b98c1046f6bb04fa5" -dependencies = [ - "ahash 0.8.3", - "futures", - "futures-timer", - "libp2p", - "log", - "sc-network", - "sc-network-common", - "schnellru", - "sp-runtime", - "substrate-prometheus-endpoint", - "tracing", -] - [[package]] name = "sc-network-light" version = "0.30.0" @@ -11160,51 +9929,6 @@ dependencies = [ "substrate-prometheus-endpoint", ] -[[package]] -name = "sc-offchain" -version = "26.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47950facab8dedf71c39667ccce8834252944e8f091f3a3bcdfc0b4503573da4" -dependencies = [ - "array-bytes 6.1.0", - "bytes", - "fnv", - "futures", - "futures-timer", - "hyper", - "hyper-rustls", - "libp2p", - "log", - "num_cpus", - "once_cell", - "parity-scale-codec", - "parking_lot 0.12.1", - "rand 0.8.5", - "sc-client-api", - "sc-network", - "sc-network-common", - "sc-transaction-pool-api", - "sc-utils", - "sp-api", - "sp-core", - "sp-externalities", - "sp-keystore", - "sp-offchain", - "sp-runtime", - "threadpool", - "tracing", -] - -[[package]] -name = "sc-proposer-metrics" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "221845dce4e7adb57eca5f73318699b377cff29aef92a586e71aa5cef62f879b" -dependencies = [ - "log", - "substrate-prometheus-endpoint", -] - [[package]] name = "sc-rpc" version = "26.0.0" @@ -11381,26 +10105,6 @@ dependencies = [ "sp-core", ] -[[package]] -name = "sc-sync-state-rpc" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe1efc0811813b73b9bb6eccc630ccd43d13b4306255a41ef55b9304d32e64c2" -dependencies = [ - "jsonrpsee", - "parity-scale-codec", - "sc-chain-spec", - "sc-client-api", - "sc-consensus-babe", - "sc-consensus-epochs", - "sc-consensus-grandpa", - "serde", - "serde_json", - "sp-blockchain", - "sp-runtime", - "thiserror", -] - [[package]] name = "sc-sysinfo" version = "24.0.0" @@ -11960,15 +10664,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "slotmap" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" -dependencies = [ - "version_check", -] - [[package]] name = "smallvec" version = "1.11.0" @@ -12217,7 +10912,7 @@ dependencies = [ "sp-mmr-primitives", "sp-runtime", "sp-std", - "strum 0.24.1", + "strum", ] [[package]] @@ -12418,7 +11113,7 @@ dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum 0.24.1", + "strum", ] [[package]] @@ -12841,7 +11536,7 @@ checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", "maplit", - "strum 0.24.1", + "strum", ] [[package]] @@ -13123,15 +11818,9 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros 0.24.3", + "strum_macros", ] -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" - [[package]] name = "strum_macros" version = "0.24.3" @@ -13145,19 +11834,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.38", -] - [[package]] name = "stun" version = "0.4.4" @@ -13190,26 +11866,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "substrate-frame-rpc-system" -version = "25.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c241af714c378075b1185e574202cbb9105e849b8c9ea44ef87880bdb3e9a75" -dependencies = [ - "frame-system-rpc-runtime-api", - "futures", - "jsonrpsee", - "log", - "parity-scale-codec", - "sc-rpc-api", - "sc-transaction-pool-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-core", - "sp-runtime", -] - [[package]] name = "substrate-prometheus-endpoint" version = "0.16.0" @@ -13237,24 +11893,6 @@ dependencies = [ "sp-runtime", ] -[[package]] -name = "substrate-state-trie-migration-rpc" -version = "24.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d57888ccce554552c535346893a497d2cfd232f15b6b676d130cdd5bf3f2ccea" -dependencies = [ - "jsonrpsee", - "parity-scale-codec", - "sc-client-api", - "sc-rpc-api", - "serde", - "sp-core", - "sp-runtime", - "sp-state-machine", - "sp-trie", - "trie-db", -] - [[package]] name = "substrate-wasm-builder" version = "14.0.0" @@ -13267,7 +11905,7 @@ dependencies = [ "filetime", "parity-wasm", "sp-maybe-compressed-blob", - "strum 0.24.1", + "strum", "tempfile", "toml 0.7.6", "walkdir", @@ -13410,12 +12048,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "thousands" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" - [[package]] name = "thread_local" version = "1.1.7" @@ -13954,12 +12586,6 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" -[[package]] -name = "ucd-trie" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" - [[package]] name = "uint" version = "0.9.5" @@ -14252,8 +12878,8 @@ checksum = "fc942673e7684671f0c5708fc18993569d184265fd5223bb51fc8e5b9b6cfd52" dependencies = [ "anyhow", "libc", - "strum 0.24.1", - "strum_macros 0.24.3", + "strum", + "strum_macros", "tempfile", "thiserror", "wasm-opt-cxx-sys", diff --git a/integration-tests/emulated/common/Cargo.toml b/integration-tests/emulated/common/Cargo.toml index 311cbbdd45..bd52994ceb 100644 --- a/integration-tests/emulated/common/Cargo.toml +++ b/integration-tests/emulated/common/Cargo.toml @@ -26,7 +26,6 @@ pallet-staking = { version = "25.0.0" } beefy-primitives = { package = "sp-consensus-beefy", version = "10.0.0" } # Polkadot -polkadot-service = { features = ["full-node"], version = "4.0.0" } polkadot-primitives = { version = "4.0.0" } polkadot-runtime-parachains = { version = "4.0.0" } xcm = { package = "staging-xcm", version = "4.0.0" } diff --git a/integration-tests/emulated/common/src/constants.rs b/integration-tests/emulated/common/src/constants.rs index 0ef97c6541..e0cfb9f658 100644 --- a/integration-tests/emulated/common/src/constants.rs +++ b/integration-tests/emulated/common/src/constants.rs @@ -33,7 +33,6 @@ use polkadot_runtime_parachains::{ configuration::HostConfiguration, paras::{ParaGenesisArgs, ParaKind}, }; -use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy; use xcm; pub const XCM_V2: u32 = 3; @@ -131,8 +130,20 @@ pub mod validators { ValidatorId, AssignmentId, AuthorityDiscoveryId, + BeefyId, )> { - vec![get_authority_keys_from_seed_no_beefy("Alice")] + let seed = "Alice"; + vec![( + get_account_id_from_seed::(&format!("{}//stash", seed)), + get_account_id_from_seed::(seed), + get_from_seed::(seed), + get_from_seed::(seed), + get_from_seed::(seed), + get_from_seed::(seed), + get_from_seed::(seed), + get_from_seed::(seed), + get_from_seed::(seed), + )] } } @@ -210,7 +221,7 @@ pub mod polkadot { x.5.clone(), x.6.clone(), x.7.clone(), - get_from_seed::("Alice"), + x.8.clone(), ), ) }) @@ -363,7 +374,7 @@ pub mod kusama { x.5.clone(), x.6.clone(), x.7.clone(), - get_from_seed::("Alice"), + x.8.clone(), ), ) }) From f9a04a1a6b4549d95e2c3bb355ba578031a28963 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 3 Jan 2024 14:41:20 +0200 Subject: [PATCH 17/18] remove tests for deprecated teleport_assets() --- .../asset-hub-kusama/src/tests/teleport.rs | 121 ------------------ .../asset-hub-polkadot/src/tests/teleport.rs | 121 ------------------ 2 files changed, 242 deletions(-) diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs index 30da0d9edf..b0d2712046 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -121,16 +121,6 @@ fn relay_limited_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { ) } -fn relay_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { ::PolkadotXcm::limited_teleport_assets( t.signed_origin, @@ -142,16 +132,6 @@ fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResu ) } -fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - /// Limited Teleport of native asset from Relay Chain to the System Parachain should work #[test] fn limited_teleport_native_assets_from_relay_to_system_para_works() { @@ -254,104 +234,3 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { // Receiver's balance does not change assert_eq!(receiver_balance_after, receiver_balance_before); } - -/// Teleport of native asset from Relay Chain to the System Parachain should work -#[test] -fn teleport_native_assets_from_relay_to_system_para_works() { - // Init values for Relay Chain - let amount_to_send: Balance = KUSAMA_ED * 1000; - let test_args = TestContext { - sender: KusamaSender::get(), - receiver: AssetHubKusamaReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(para_dest_assertions); - test.set_dispatchable::(relay_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Teleport of native asset from System Parachains to the Relay Chain -/// should work when there is enough balance in Relay Chain's `CheckAccount` -#[test] -fn teleport_native_assets_back_from_system_para_to_relay_works() { - // Dependency - Relay Chain's `CheckAccount` should have enough balance - teleport_native_assets_from_relay_to_system_para_works(); - - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; - let destination = AssetHubKusama::parent_location(); - let beneficiary_id = KusamaReceiver::get(); - let assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: AssetHubKusamaSender::get(), - receiver: KusamaReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions); - test.set_dispatchable::(system_para_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Teleport of native asset from System Parachain to Relay Chain -/// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` -#[test] -fn teleport_native_assets_from_system_para_to_relay_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; - let destination = AssetHubKusama::parent_location(); - let beneficiary_id = KusamaReceiver::get(); - let assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: AssetHubKusamaSender::get(), - receiver: KusamaReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions_fail); - test.set_dispatchable::(system_para_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - // Receiver's balance does not change - assert_eq!(receiver_balance_after, receiver_balance_before); -} diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs index 11bc31d7fd..8d2aec13bd 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -121,16 +121,6 @@ fn relay_limited_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { ) } -fn relay_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { ::PolkadotXcm::limited_teleport_assets( t.signed_origin, @@ -142,16 +132,6 @@ fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResu ) } -fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - /// Limited Teleport of native asset from Relay Chain to the System Parachain should work #[test] fn limited_teleport_native_assets_from_relay_to_system_para_works() { @@ -254,104 +234,3 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { // Receiver's balance does not change assert_eq!(receiver_balance_after, receiver_balance_before); } - -/// Teleport of native asset from Relay Chain to the System Parachain should work -#[test] -fn teleport_native_assets_from_relay_to_system_para_works() { - // Init values for Relay Chain - let amount_to_send: Balance = POLKADOT_ED * 1000; - let test_args = TestContext { - sender: PolkadotSender::get(), - receiver: AssetHubPolkadotReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(para_dest_assertions); - test.set_dispatchable::(relay_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Teleport of native asset from System Parachains to the Relay Chain -/// should work when there is enough balance in Relay Chain's `CheckAccount` -#[test] -fn teleport_native_assets_back_from_system_para_to_relay_works() { - // Dependency - Relay Chain's `CheckAccount` should have enough balance - teleport_native_assets_from_relay_to_system_para_works(); - - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; - let destination = AssetHubPolkadot::parent_location(); - let beneficiary_id = PolkadotReceiver::get(); - let assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: AssetHubPolkadotSender::get(), - receiver: PolkadotReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions); - test.set_dispatchable::(system_para_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Teleport of native asset from System Parachain to Relay Chain -/// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` -#[test] -fn teleport_native_assets_from_system_para_to_relay_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; - let destination = AssetHubPolkadot::parent_location(); - let beneficiary_id = PolkadotReceiver::get(); - let assets = (Parent, amount_to_send).into(); - let test_args = TestContext { - sender: AssetHubPolkadotSender::get(), - receiver: PolkadotReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions_fail); - test.set_dispatchable::(system_para_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - // Receiver's balance does not change - assert_eq!(receiver_balance_after, receiver_balance_before); -} From 09136edce2300a4320627da5be6a40bdef4844fc Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 3 Jan 2024 14:48:35 +0200 Subject: [PATCH 18/18] remove tests for deprecated reserve_transfer_assets() --- .../src/tests/reserve_transfer.rs | 156 ------------------ .../src/tests/reserve_transfer.rs | 156 ------------------ 2 files changed, 312 deletions(-) diff --git a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs index 92c320e300..cc2e7a66b3 100644 --- a/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs @@ -105,16 +105,6 @@ fn relay_limited_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchRe ) } -fn relay_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - fn system_para_limited_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { ::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, @@ -126,16 +116,6 @@ fn system_para_limited_reserve_transfer_assets(t: SystemParaToRelayTest) -> Disp ) } -fn system_para_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { ::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, @@ -147,16 +127,6 @@ fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) ) } -fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - ::PolkadotXcm::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - /// Limited Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't /// work #[test] @@ -217,65 +187,6 @@ fn limited_reserve_transfer_native_asset_from_system_para_to_relay_fails() { assert_eq!(receiver_balance_before, receiver_balance_after); } -/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work -#[test] -fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = KUSAMA_ED * 1000; - let test_args = TestContext { - sender: KusamaSender::get(), - receiver: AssetHubKusamaReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(system_para_dest_assertions_incomplete); - test.set_dispatchable::(relay_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - assert_eq!(receiver_balance_before, receiver_balance_after); -} - -/// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work -#[test] -fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { - // Init values for System Parachain - let destination = AssetHubKusama::parent_location(); - let beneficiary_id = KusamaReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubKusamaSender::get(), - receiver: KusamaReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(system_para_to_relay_assertions); - test.set_dispatchable::(system_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - assert_eq!(sender_balance_before, sender_balance_after); - assert_eq!(receiver_balance_before, receiver_balance_after); -} - /// Limited Reserve Transfers of native asset from System Parachain to Parachain should work #[test] fn limited_reserve_transfer_native_asset_from_system_para_to_para() { @@ -308,38 +219,6 @@ fn limited_reserve_transfer_native_asset_from_system_para_to_para() { // transfers } -/// Reserve Transfers of native asset from System Parachain to Parachain should work -#[test] -fn reserve_transfer_native_asset_from_system_para_to_para() { - // Init values for System Parachain - let destination = AssetHubKusama::sibling_location_of(PenpalKusamaA::para_id()); - let beneficiary_id = PenpalKusamaAReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubKusamaSender::get(), - receiver: PenpalKusamaAReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - - test.set_assertion::(system_para_to_para_assertions); - // TODO: Add assertion for Penpal runtime. Right now message is failing with - // `UntrustedReserveLocation` - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve - // transfers -} - /// Limited Reserve Transfers of a local asset from System Parachain to Parachain should work #[test] fn limited_reserve_transfer_asset_from_system_para_to_para() { @@ -374,38 +253,3 @@ fn limited_reserve_transfer_asset_from_system_para_to_para() { .set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); system_para_test.assert(); } - -/// Reserve Transfers of a local asset from System Parachain to Parachain should work -#[test] -fn reserve_transfer_asset_from_system_para_to_para() { - // Force create asset from Relay Chain and mint assets for System Parachain's sender account - AssetHubKusama::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - AssetHubKusamaSender::get(), - ASSET_MIN_BALANCE * 1000000, - ); - - // Init values for System Parachain - let destination = AssetHubKusama::sibling_location_of(PenpalKusamaA::para_id()); - let beneficiary_id = PenpalKusamaAReceiver::get(); - let amount_to_send = ASSET_MIN_BALANCE * 1000; - let assets = - (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) - .into(); - - let system_para_test_args = TestContext { - sender: AssetHubKusamaSender::get(), - receiver: PenpalKusamaAReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); - - system_para_test.set_assertion::(system_para_to_para_assets_assertions); - // TODO: Add assertions when Penpal is able to manage assets - system_para_test - .set_dispatchable::(system_para_to_para_reserve_transfer_assets); - system_para_test.assert(); -} diff --git a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs index 5d4d437df2..96c4358abd 100644 --- a/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs +++ b/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs @@ -105,16 +105,6 @@ fn relay_limited_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchRe ) } -fn relay_reserve_transfer_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - fn system_para_limited_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { ::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, @@ -126,16 +116,6 @@ fn system_para_limited_reserve_transfer_assets(t: SystemParaToRelayTest) -> Disp ) } -fn system_para_reserve_transfer_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { ::PolkadotXcm::limited_reserve_transfer_assets( t.signed_origin, @@ -147,16 +127,6 @@ fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) ) } -fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { - ::PolkadotXcm::reserve_transfer_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - /// Limited Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't /// work #[test] @@ -217,65 +187,6 @@ fn limited_reserve_transfer_native_asset_from_system_para_to_relay_fails() { assert_eq!(receiver_balance_before, receiver_balance_after); } -/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work -#[test] -fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = POLKADOT_ED * 1000; - let test_args = TestContext { - sender: PolkadotSender::get(), - receiver: AssetHubPolkadotReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(system_para_dest_assertions_incomplete); - test.set_dispatchable::(relay_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - assert_eq!(receiver_balance_before, receiver_balance_after); -} - -/// Reserve Transfers of native asset from System Parachain to Relay Chain shouldn't work -#[test] -fn reserve_transfer_native_asset_from_system_para_to_relay_fails() { - // Init values for System Parachain - let destination = AssetHubPolkadot::parent_location(); - let beneficiary_id = PolkadotReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubPolkadotSender::get(), - receiver: PolkadotReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(system_para_to_relay_assertions); - test.set_dispatchable::(system_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - assert_eq!(sender_balance_before, sender_balance_after); - assert_eq!(receiver_balance_before, receiver_balance_after); -} - /// Limited Reserve Transfers of native asset from System Parachain to Parachain should work #[test] fn limited_reserve_transfer_native_asset_from_system_para_to_para() { @@ -308,38 +219,6 @@ fn limited_reserve_transfer_native_asset_from_system_para_to_para() { // transfers } -/// Reserve Transfers of native asset from System Parachain to Parachain should work -#[test] -fn reserve_transfer_native_asset_from_system_para_to_para() { - // Init values for System Parachain - let destination = AssetHubPolkadot::sibling_location_of(PenpalPolkadotA::para_id()); - let beneficiary_id = PenpalPolkadotAReceiver::get(); - let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubPolkadotSender::get(), - receiver: PenpalPolkadotAReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - - test.set_assertion::(system_para_to_para_assertions); - // TODO: Add assertion for Penpal runtime. Right now message is failing with - // `UntrustedReserveLocation` - test.set_dispatchable::(system_para_to_para_reserve_transfer_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - - assert!(sender_balance_before - amount_to_send >= sender_balance_after); - // TODO: Check receiver balance when Penpal runtime is improved to propery handle reserve - // transfers -} - /// Limited Reserve Transfers of a local asset from System Parachain to Parachain should work #[test] fn limited_reserve_transfer_asset_from_system_para_to_para() { @@ -374,38 +253,3 @@ fn limited_reserve_transfer_asset_from_system_para_to_para() { .set_dispatchable::(system_para_to_para_limited_reserve_transfer_assets); system_para_test.assert(); } - -/// Reserve Transfers of a local asset from System Parachain to Parachain should work -#[test] -fn reserve_transfer_asset_from_system_para_to_para() { - // Force create asset from Relay Chain and mint assets for System Parachain's sender account - AssetHubPolkadot::force_create_and_mint_asset( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - AssetHubPolkadotSender::get(), - ASSET_MIN_BALANCE * 1000000, - ); - - // Init values for System Parachain - let destination = AssetHubPolkadot::sibling_location_of(PenpalPolkadotA::para_id()); - let beneficiary_id = PenpalPolkadotAReceiver::get(); - let amount_to_send = ASSET_MIN_BALANCE * 1000; - let assets = - (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) - .into(); - - let system_para_test_args = TestContext { - sender: AssetHubPolkadotSender::get(), - receiver: PenpalPolkadotAReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); - - system_para_test.set_assertion::(system_para_to_para_assets_assertions); - // TODO: Add assertions when Penpal is able to manage assets - system_para_test - .set_dispatchable::(system_para_to_para_reserve_transfer_assets); - system_para_test.assert(); -}