diff --git a/.gitignore b/.gitignore index 6892a1980e..8900680f8a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ .vscode **/__pycache__ + +**/node_modules + +runtimes/spiritnet/src/xcm_tests/e2e/out diff --git a/Cargo.lock b/Cargo.lock index 85ca535051..ab0e707ca0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -201,6 +201,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -376,6 +382,226 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "asset-hub-kusama-runtime" +version = "0.9.420" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "assets-common", + "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-timestamp", + "cumulus-primitives-utility", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "hex-literal 0.4.1", + "kusama-runtime-constants", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-nft-fractionalization", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-state-trie-migration", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "asset-hub-polkadot-runtime" +version = "0.9.420" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "assets-common", + "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-timestamp", + "cumulus-primitives-utility", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "polkadot-runtime-constants", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "asset-hub-westend-runtime" +version = "0.9.420" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "assets-common", + "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-timestamp", + "cumulus-primitives-utility", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "log", + "pallet-asset-conversion", + "pallet-asset-conversion-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-nft-fractionalization", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "primitive-types", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "westend-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "assets-common" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "log", + "pallet-asset-conversion", + "pallet-asset-tx-payment", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -747,12 +973,426 @@ dependencies = [ ] [[package]] -name = "bounded-vec" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68534a48cbf63a4b1323c433cf21238c9ec23711e0df13b08c33e5c2082663ce" +name = "bounded-vec" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68534a48cbf63a4b1323c433cf21238c9ec23711e0df13b08c33e5c2082663ce" +dependencies = [ + "thiserror", +] + +[[package]] +name = "bp-bridge-hub-cumulus" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-messages", + "bp-polkadot-core", + "bp-runtime", + "frame-support", + "frame-system", + "polkadot-primitives", + "sp-api", + "sp-std", +] + +[[package]] +name = "bp-bridge-hub-rococo" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-bridge-hub-cumulus", + "bp-messages", + "bp-runtime", + "frame-support", + "sp-api", + "sp-std", +] + +[[package]] +name = "bp-bridge-hub-wococo" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-bridge-hub-cumulus", + "bp-messages", + "bp-runtime", + "frame-support", + "sp-api", + "sp-std", +] + +[[package]] +name = "bp-header-chain" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-runtime", + "finality-grandpa", + "frame-support", + "parity-scale-codec", + "scale-info", + "serde", + "sp-consensus-grandpa", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-messages" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-header-chain", + "bp-runtime", + "frame-support", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-std", +] + +[[package]] +name = "bp-parachains" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-header-chain", + "bp-polkadot-core", + "bp-runtime", + "frame-support", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-polkadot-core" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-support", + "frame-system", + "parity-scale-codec", + "parity-util-mem", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-relayers" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-support", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-rococo" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-header-chain", + "bp-polkadot-core", + "bp-runtime", + "frame-support", + "sp-api", +] + +[[package]] +name = "bp-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "frame-support", + "frame-system", + "hash-db", + "impl-trait-for-tuples", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", + "trie-db", +] + +[[package]] +name = "bp-test-utils" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-header-chain", + "bp-parachains", + "bp-polkadot-core", + "bp-runtime", + "ed25519-dalek 1.0.1", + "finality-grandpa", + "parity-scale-codec", + "sp-application-crypto", + "sp-consensus-grandpa", + "sp-core", + "sp-runtime", + "sp-std", + "sp-trie", +] + +[[package]] +name = "bp-wococo" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-header-chain", + "bp-polkadot-core", + "bp-rococo", + "bp-runtime", + "frame-support", + "sp-api", +] + +[[package]] +name = "bridge-hub-kusama-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +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-timestamp", + "cumulus-primitives-utility", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "hex-literal 0.4.1", + "kusama-runtime-constants", + "log", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "bridge-hub-polkadot-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +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-timestamp", + "cumulus-primitives-utility", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "hex-literal 0.4.1", + "log", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "polkadot-runtime-constants", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "bridge-hub-rococo-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-bridge-hub-rococo", + "bp-bridge-hub-wococo", + "bp-messages", + "bp-parachains", + "bp-polkadot-core", + "bp-relayers", + "bp-rococo", + "bp-runtime", + "bp-wococo", + "bridge-runtime-common", + "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-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "hex-literal 0.4.1", + "log", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-bridge-grandpa", + "pallet-bridge-messages", + "pallet-bridge-parachains", + "pallet-bridge-relayers", + "pallet-collator-selection", + "pallet-multisig", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "rococo-runtime-constants", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "bridge-runtime-common" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" dependencies = [ - "thiserror", + "bp-header-chain", + "bp-messages", + "bp-parachains", + "bp-polkadot-core", + "bp-relayers", + "bp-runtime", + "frame-support", + "frame-system", + "hash-db", + "log", + "pallet-bridge-grandpa", + "pallet-bridge-messages", + "pallet-bridge-parachains", + "pallet-bridge-relayers", + "pallet-transaction-payment", + "pallet-utility", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-trie", + "xcm", + "xcm-builder", ] [[package]] @@ -859,6 +1499,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "casey" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.83" @@ -948,6 +1603,33 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cid" version = "0.9.0" @@ -1127,6 +1809,73 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "collectives-polkadot-runtime" +version = "1.0.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +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-timestamp", + "cumulus-primitives-utility", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "hex-literal 0.4.1", + "log", + "pallet-alliance", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-collective", + "pallet-core-fellowship", + "pallet-multisig", + "pallet-preimage", + "pallet-proxy", + "pallet-ranked-collective", + "pallet-referenda", + "pallet-salary", + "pallet-scheduler", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "polkadot-runtime-constants", + "scale-info", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -1385,6 +2134,44 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "futures", + "is-terminal", + "itertools 0.10.5", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "tokio", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -1650,6 +2437,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cumulus-client-consensus-relay-chain" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "async-trait", + "cumulus-client-consensus-common", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "parking_lot 0.12.1", + "sc-consensus", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "substrate-prometheus-endpoint", + "tracing", +] + [[package]] name = "cumulus-client-network" version = "0.1.0" @@ -2013,57 +2823,170 @@ dependencies = [ "sc-tracing", "sc-utils", "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-runtime", + "tokio", + "tracing", +] + +[[package]] +name = "cumulus-relay-chain-rpc-interface" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "async-trait", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "futures-timer", + "jsonrpsee", + "lru 0.9.0", + "parity-scale-codec", + "polkadot-overseer", + "sc-client-api", + "sc-rpc-api", + "sc-service", + "serde", + "serde_json", + "sp-api", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-core", + "sp-state-machine", + "sp-storage", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "cumulus-test-relay-sproof-builder" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "cumulus-primitives-core", + "parity-scale-codec", + "polkadot-primitives", + "sp-runtime", + "sp-state-machine", + "sp-std", +] + +[[package]] +name = "cumulus-test-relay-validation-worker-provider" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "polkadot-node-core-pvf", + "toml 0.7.8", +] + +[[package]] +name = "cumulus-test-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "pallet-balances", + "pallet-glutton", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-block-builder", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", "sp-runtime", - "tokio", - "tracing", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", ] [[package]] -name = "cumulus-relay-chain-rpc-interface" +name = "cumulus-test-service" version = "0.1.0" source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" dependencies = [ "async-trait", + "clap", + "criterion", + "cumulus-client-cli", + "cumulus-client-consensus-common", + "cumulus-client-consensus-relay-chain", + "cumulus-client-pov-recovery", + "cumulus-client-service", + "cumulus-pallet-parachain-system", "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-inprocess-interface", "cumulus-relay-chain-interface", - "futures", - "futures-timer", + "cumulus-relay-chain-minimal-node", + "cumulus-test-relay-sproof-builder", + "cumulus-test-relay-validation-worker-provider", + "cumulus-test-runtime", + "frame-system", + "frame-system-rpc-runtime-api", "jsonrpsee", - "lru 0.9.0", + "pallet-timestamp", + "pallet-transaction-payment", + "parachains-common", "parity-scale-codec", + "polkadot-cli", + "polkadot-node-subsystem", "polkadot-overseer", + "polkadot-primitives", + "polkadot-service", + "polkadot-test-service", + "rand 0.8.5", + "sc-basic-authorship", + "sc-block-builder", + "sc-chain-spec", + "sc-cli", "sc-client-api", - "sc-rpc-api", + "sc-consensus", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sc-network", "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", "serde", - "serde_json", "sp-api", - "sp-authority-discovery", - "sp-consensus-babe", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", "sp-core", + "sp-io", + "sp-keyring", + "sp-runtime", "sp-state-machine", - "sp-storage", + "sp-timestamp", + "sp-tracing", + "sp-trie", + "substrate-test-client", + "tempfile", "tokio", "tracing", "url", ] -[[package]] -name = "cumulus-test-relay-sproof-builder" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" -dependencies = [ - "cumulus-primitives-core", - "parity-scale-codec", - "polkadot-primitives", - "sp-runtime", - "sp-state-machine", - "sp-std", -] - [[package]] name = "curve25519-dalek" version = "2.1.3" @@ -2804,6 +3727,8 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek 3.2.0", "ed25519 1.5.3", + "rand 0.7.3", + "serde", "sha2 0.9.9", "zeroize", ] @@ -3001,6 +3926,33 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "ethbloom" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash", + "impl-rlp", + "impl-serde", + "tiny-keccak", +] + +[[package]] +name = "ethereum-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +dependencies = [ + "ethbloom", + "fixed-hash", + "impl-rlp", + "impl-serde", + "primitive-types", + "uint", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -3856,6 +4808,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "handlebars" version = "4.5.0" @@ -4192,6 +5154,26 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "impl-num-traits" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951641f13f873bff03d4bf19ae8bec531935ac0ac2cc775f84d7edfdcfed3f17" +dependencies = [ + "integer-sqrt", + "num-traits", + "uint", +] + +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + [[package]] name = "impl-serde" version = "0.4.0" @@ -4279,6 +5261,59 @@ dependencies = [ "num-traits", ] +[[package]] +name = "integration-tests-common" +version = "1.0.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "asset-hub-kusama-runtime", + "asset-hub-polkadot-runtime", + "asset-hub-westend-runtime", + "bp-messages", + "bp-runtime", + "bridge-hub-kusama-runtime", + "bridge-hub-polkadot-runtime", + "bridge-hub-rococo-runtime", + "bridge-runtime-common", + "collectives-polkadot-runtime", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "kusama-runtime", + "kusama-runtime-constants", + "pallet-assets", + "pallet-balances", + "pallet-bridge-messages", + "pallet-im-online", + "pallet-staking", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-service", + "rococo-runtime", + "rococo-runtime-constants", + "sc-consensus-grandpa", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-runtime", + "sp-weights", + "westend-runtime", + "westend-runtime-constants", + "xcm", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "interceptor" version = "0.8.2" @@ -5530,6 +6565,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +dependencies = [ + "hashbrown 0.12.3", +] + [[package]] name = "lru" version = "0.9.0" @@ -6197,6 +7241,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -6278,6 +7328,91 @@ dependencies = [ "sha2 0.10.8", ] +[[package]] +name = "pallet-alliance" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-collective", + "pallet-identity", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-core-hashing", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-asset-conversion" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-asset-conversion-tx-payment" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-support", + "frame-system", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-asset-tx-payment" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-assets" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-aura" version = "4.0.0-dev" @@ -6444,6 +7579,87 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-bridge-grandpa" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-header-chain", + "bp-runtime", + "bp-test-utils", + "finality-grandpa", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-consensus-grandpa", + "sp-runtime", + "sp-std", + "sp-trie", +] + +[[package]] +name = "pallet-bridge-messages" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "num-traits", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-bridge-parachains" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-header-chain", + "bp-parachains", + "bp-polkadot-core", + "bp-runtime", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-bridge-grandpa", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", + "sp-trie", +] + +[[package]] +name = "pallet-bridge-relayers" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "bp-messages", + "bp-relayers", + "bp-runtime", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-bridge-messages", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" @@ -6535,6 +7751,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-core-fellowship" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-democracy" version = "4.0.0-dev" @@ -6709,6 +7943,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-glutton" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "blake2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -6902,6 +8154,52 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-nft-fractionalization" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-assets", + "pallet-nfts", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-nfts" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-nfts-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-support", + "pallet-nfts", + "parity-scale-codec", + "sp-api", +] + [[package]] name = "pallet-nis" version = "4.0.0-dev" @@ -7123,6 +8421,24 @@ dependencies = [ "sp-trie", ] +[[package]] +name = "pallet-salary" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-scheduler" version = "4.0.0-dev" @@ -7378,6 +8694,21 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-uniques" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -7523,6 +8854,35 @@ dependencies = [ "sp-std", ] +[[package]] +name = "parachains-common" +version = "1.0.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "cumulus-primitives-core", + "cumulus-primitives-utility", + "frame-support", + "frame-system", + "num-traits", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "parity-scale-codec", + "polkadot-primitives", + "scale-info", + "sp-consensus-aura", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "parity-db" version = "0.4.12" @@ -7576,6 +8936,35 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" +[[package]] +name = "parity-util-mem" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d32c34f4f5ca7f9196001c0aba5a1f9a5a12382c8944b8b0f90233282d1e8f8" +dependencies = [ + "cfg-if", + "ethereum-types", + "hashbrown 0.12.3", + "impl-trait-for-tuples", + "lru 0.8.1", + "parity-util-mem-derive", + "parking_lot 0.12.1", + "primitive-types", + "smallvec", + "winapi", +] + +[[package]] +name = "parity-util-mem-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" +dependencies = [ + "proc-macro2", + "syn 1.0.109", + "synstructure", +] + [[package]] name = "parity-wasm" version = "0.45.0" @@ -7690,6 +9079,62 @@ dependencies = [ "base64ct", ] +[[package]] +name = "penpal-runtime" +version = "0.9.27" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +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-timestamp", + "cumulus-primitives-utility", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "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", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -7905,6 +9350,34 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + [[package]] name = "polkadot-approval-distribution" version = "1.0.0" @@ -9091,6 +10564,118 @@ dependencies = [ "sp-core", ] +[[package]] +name = "polkadot-test-runtime" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "bitvec", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-indices", + "pallet-offences", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", + "pallet-xcm", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "test-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "polkadot-test-service" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "frame-system", + "futures", + "hex", + "pallet-balances", + "pallet-staking", + "pallet-transaction-payment", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-rpc", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "polkadot-service", + "polkadot-test-runtime", + "rand 0.8.5", + "sc-authority-discovery", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-grandpa", + "sc-network", + "sc-service", + "sc-tracing", + "sc-transaction-pool", + "sp-arithmetic", + "sp-authority-discovery", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-core", + "sp-inherents", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "substrate-test-client", + "tempfile", + "test-runtime-constants", + "tokio", + "tracing-gum", +] + [[package]] name = "polling" version = "3.3.0" @@ -9216,6 +10801,8 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", + "impl-num-traits", + "impl-rlp", "impl-serde", "scale-info", "uint", @@ -9801,6 +11388,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + [[package]] name = "rocksdb" version = "0.21.0" @@ -12841,6 +14438,32 @@ dependencies = [ "trie-db", ] +[[package]] +name = "substrate-test-client" +version = "2.0.1" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "array-bytes", + "async-trait", + "futures", + "parity-scale-codec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-executor", + "sc-offchain", + "sc-service", + "serde", + "serde_json", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-keyring", + "sp-keystore", + "sp-runtime", + "sp-state-machine", +] + [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" @@ -12980,6 +14603,20 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "test-runtime-constants" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + [[package]] name = "thiserror" version = "1.0.50" @@ -14788,6 +16425,39 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "xcm-emulator" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6bef320f156f2859d6d2b0abd4154ae1d5" +dependencies = [ + "casey", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "cumulus-test-service", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-message-queue", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "paste", + "polkadot-primitives", + "polkadot-runtime-parachains", + "quote", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-trie", + "xcm", +] + [[package]] name = "xcm-executor" version = "1.0.0" @@ -14808,6 +16478,58 @@ dependencies = [ "xcm", ] +[[package]] +name = "xcm-integration-tests" +version = "1.13.0-dev" +dependencies = [ + "asset-hub-kusama-runtime", + "asset-hub-polkadot-runtime", + "asset-hub-westend-runtime", + "attestation", + "bridge-hub-kusama-runtime", + "bridge-hub-polkadot-runtime", + "bridge-hub-rococo-runtime", + "collectives-polkadot-runtime", + "ctype", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "did", + "frame-support", + "frame-system", + "integration-tests-common", + "kilt-asset-dids", + "pallet-did-lookup", + "pallet-message-queue", + "pallet-web3-names", + "pallet-xcm", + "parity-scale-codec", + "penpal-runtime", + "peregrine-runtime", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-service", + "polkadot-test-runtime", + "public-credentials", + "rococo-runtime", + "runtime-common", + "sc-consensus-grandpa", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-io", + "sp-runtime", + "sp-tracing", + "spiritnet-runtime", + "xcm", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "xcm-procedural" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 7e17e3cd67..2686e4fca5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ members = [ "runtime-api/*", "runtimes/*", "support", + "integration-tests/emulated", ] [profile.release] @@ -51,6 +52,9 @@ serde_json = "1.0.85" sha3 = {version = "0.10.0", default-features = false} smallvec = "1.8.0" +#tests +xcm-integration-tests = {path = "integration-tests/emulated", default-features = false} + # Internal pallets (with default disabled) attestation = {path = "pallets/attestation", default-features = false} ctype = {path = "pallets/ctype", default-features = false} @@ -58,15 +62,15 @@ delegation = {path = "pallets/delegation", default-features = false} did = {path = "pallets/did", default-features = false} pallet-configuration = {path = "pallets/pallet-configuration", default-features = false} pallet-deposit-storage = {path = "pallets/pallet-deposit-storage", default-features = false} +pallet-did-lookup = {path = "pallets/pallet-did-lookup", default-features = false} pallet-dip-consumer = {path = "pallets/pallet-dip-consumer", default-features = false} pallet-dip-provider = {path = "pallets/pallet-dip-provider", default-features = false} -pallet-did-lookup = {path = "pallets/pallet-did-lookup", default-features = false} pallet-inflation = {path = "pallets/pallet-inflation", default-features = false} +pallet-migration = {path = "pallets/pallet-migration", default-features = false} pallet-relay-store = {path = "pallets/pallet-relay-store", default-features = false} pallet-web3-names = {path = "pallets/pallet-web3-names", default-features = false} parachain-staking = {path = "pallets/parachain-staking", default-features = false} public-credentials = {path = "pallets/public-credentials", default-features = false} -pallet-migration = {path = "pallets/pallet-migration", default-features = false} # Internal support (with default disabled) kilt-asset-dids = {path = "crates/assets", default-features = false} @@ -86,16 +90,17 @@ kilt-runtime-api-public-credentials = {path = "runtime-api/public-credentials", kilt-runtime-api-staking = {path = "runtime-api/staking", default-features = false} # Internal KILT runtimes (with default disabled) +clone-runtime = {path = "runtimes/clone", default-features = false} kestrel-runtime = {path = "runtimes/kestrel", default-features = false} peregrine-runtime = {path = "runtimes/peregrine", default-features = false} spiritnet-runtime = {path = "runtimes/spiritnet", default-features = false} -clone-runtime = {path = "runtimes/clone", default-features = false} # Benchmarking (with default disabled) cumulus-pallet-session-benchmarking = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} # Cumulus (with default disabled) + cumulus-pallet-aura-ext = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} cumulus-pallet-dmp-queue = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} cumulus-pallet-parachain-system = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} @@ -106,6 +111,19 @@ cumulus-primitives-timestamp = {git = "https://github.com/paritytech/cumulus", d cumulus-primitives-utility = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} parachain-info = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +# XCM Emulator tests +asset-hub-kusama-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +asset-hub-polkadot-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +asset-hub-rococo-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +asset-hub-westend-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +bridge-hub-kusama-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +bridge-hub-polkadot-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +bridge-hub-rococo-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +collectives-polkadot-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +integration-tests-common = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +penpal-runtime = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +xcm-emulator = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} + # Substrate (with default disabled) frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} frame-benchmarking-cli = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} @@ -117,12 +135,15 @@ frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-fe pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-collator-selection = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0"} +pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-democracy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-grandpa = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-im-online = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-indices = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-message-queue = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +pallet-multisig = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-preimage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-proxy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} @@ -135,10 +156,11 @@ pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/parityte pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} pallet-vesting = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} -pallet-multisig = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-authority-discovery = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-consensus-babe = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} @@ -148,6 +170,7 @@ sp-session = {git = "https://github.com/paritytech/substrate", default-features sp-staking = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-state-machine = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} +sp-tracing = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-trie = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0"} @@ -157,10 +180,16 @@ try-runtime-cli = {git = "https://github.com/paritytech/substrate", default-feat # Polkadot (with default disabled) pallet-xcm = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} polkadot-parachain = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} +polkadot-runtime = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} +polkadot-runtime-constants = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} +polkadot-runtime-parachains = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} +polkadot-test-runtime = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} rococo-runtime = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} +rococo-runtime-constants = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} xcm = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} xcm-builder = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} xcm-executor = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} +xcm-simulator = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0"} # Client-only (with default enabled) cumulus-client-cli = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v1.0.0"} @@ -183,12 +212,12 @@ sc-cli = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1 sc-client-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-consensus-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} -sc-offchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } sc-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-executor = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-network = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-network-sync = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sc-offchain = {version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-rpc-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-service = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sc-sysinfo = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} @@ -198,6 +227,7 @@ sc-transaction-pool = {git = "https://github.com/paritytech/substrate", branch = sc-transaction-pool-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sp-consensus = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} +sp-consensus-beefy = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sp-consensus-grandpa = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sp-keyring = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} sp-keystore = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0"} diff --git a/integration-tests/emulated/Cargo.toml b/integration-tests/emulated/Cargo.toml new file mode 100644 index 0000000000..bdbb9c1dc1 --- /dev/null +++ b/integration-tests/emulated/Cargo.toml @@ -0,0 +1,59 @@ +[package] +authors.workspace = true +description = "Emulated integration tests for XCM config" +documentation.workspace = true +edition.workspace = true +homepage.workspace = true +license-file.workspace = true +name = "xcm-integration-tests" +readme.workspace = true +repository.workspace = true +version.workspace = true + +[dev-dependencies] +asset-hub-kusama-runtime = {workspace = true, features = ["std"]} +asset-hub-polkadot-runtime = {workspace = true, features = ["std"]} +asset-hub-westend-runtime = {workspace = true, features = ["std"]} +attestation = {workspace = true, features = ["std"]} +bridge-hub-kusama-runtime = {workspace = true, features = ["std"]} +bridge-hub-polkadot-runtime = {workspace = true, features = ["std"]} +bridge-hub-rococo-runtime = {workspace = true, features = ["std"]} +collectives-polkadot-runtime = {workspace = true, features = ["std"]} +ctype = {workspace = true, features = ["std"]} +cumulus-pallet-dmp-queue = {workspace = true, features = ["std"]} +cumulus-pallet-xcmp-queue = {workspace = true, features = ["std"]} +cumulus-primitives-core = {workspace = true, features = ["std"]} +did = {workspace = true, features = ["std"]} +frame-support = {workspace = true, features = ["std"]} +frame-system = {workspace = true, features = ["std"]} +integration-tests-common.workspace = true +kilt-asset-dids = {workspace = true, features = ["std"]} +pallet-did-lookup = {workspace = true, features = ["std"]} +pallet-message-queue = {workspace = true, features = ["std"]} +pallet-web3-names = {workspace = true, features = ["std"]} +pallet-xcm = {workspace = true, features = ["std"]} +parity-scale-codec = {workspace = true, features = ["std", "derive"]} +penpal-runtime = {workspace = true, features = ["std"]} +peregrine-runtime = {workspace = true, features = ["std"]} +polkadot-parachain = {workspace = true, features = ["std"]} +polkadot-primitives = {workspace = true, features = ["std"]} +polkadot-runtime-constants = {workspace = true, features = ["std"]} +polkadot-runtime-parachains = {workspace = true, features = ["std"]} +polkadot-runtime = {workspace = true, features = ["std"]} +polkadot-service.workspace = true +polkadot-test-runtime = {workspace = true, features = ["std"]} +public-credentials = {workspace = true, features = ["std", "mock"]} +rococo-runtime = {workspace = true, features = ["std"]} +runtime-common = {workspace = true, features = ["std"]} +sc-consensus-grandpa.workspace = true +sp-authority-discovery = {workspace = true, features = ["std"]} +sp-consensus-babe = {workspace = true, features = ["std"]} +sp-consensus-beefy = {workspace = true, features = ["std"]} +sp-core = {workspace = true, features = ["std"]} +sp-io = {workspace = true, features = ["std"]} +sp-runtime = {workspace = true, features = ["std"]} +sp-tracing = {workspace = true, features = ["std"]} +spiritnet-runtime = {workspace = true, features = ["std"]} +xcm-emulator.workspace = true +xcm-executor = {workspace = true, features = ["std"]} +xcm = {workspace = true, features = ["std"]} \ No newline at end of file diff --git a/pallets/public-credentials/src/atests.rs b/integration-tests/emulated/src/lib.rs similarity index 67% rename from pallets/public-credentials/src/atests.rs rename to integration-tests/emulated/src/lib.rs index 9f56dd8e67..99afcb8e18 100644 --- a/pallets/public-credentials/src/atests.rs +++ b/integration-tests/emulated/src/lib.rs @@ -16,31 +16,9 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use frame_support::{ - assert_noop, assert_ok, - traits::{fungible::InspectHold, Get}, -}; -use sp_runtime::traits::Zero; - -use ctype::mock::get_ctype_hash; -use kilt_support::{mock::mock_origin::DoubleOrigin, Deposit}; - -use crate::{ - mock::*, Config, CredentialIdOf, CredentialSubjects, Credentials, Error, HoldReason, InputClaimsContentOf, -}; - -// add - - - -// revoke - - - -// remove - - - -// reclaim_deposit - - +#[cfg(test)] +mod mock; +#[cfg(test)] +mod tests; +#[cfg(test)] +mod utils; diff --git a/integration-tests/emulated/src/mock/mod.rs b/integration-tests/emulated/src/mock/mod.rs new file mode 100644 index 0000000000..645422b1be --- /dev/null +++ b/integration-tests/emulated/src/mock/mod.rs @@ -0,0 +1,19 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +pub mod network; +pub mod para_chains; +pub mod relay_chains; diff --git a/integration-tests/emulated/src/mock/network.rs b/integration-tests/emulated/src/mock/network.rs new file mode 100644 index 0000000000..c419765c50 --- /dev/null +++ b/integration-tests/emulated/src/mock/network.rs @@ -0,0 +1,48 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +use integration_tests_common::Get; +use polkadot_primitives::Balance; +use sp_core::sr25519; +use xcm_emulator::{ + decl_test_networks, AccountId, Ancestor, BridgeMessageHandler, MultiLocation, Parachain, Parent, RelayChain, + TestExt, X1, +}; +use xcm_executor::traits::ConvertLocation; + +use crate::mock::{ + para_chains::{AssetHubPolkadot, AssetHubRococo, Peregrine, Spiritnet}, + relay_chains::{Polkadot, Rococo}, +}; + +decl_test_networks! { + pub struct MockNetworkPolkadot { + relay_chain = Polkadot, + parachains = vec![ + AssetHubPolkadot, + Spiritnet, + ], + bridge = () + }, + pub struct MockNetworkRococo { + relay_chain = Rococo, + parachains = vec![ + AssetHubRococo, + Peregrine, + ], + bridge = () + } +} diff --git a/integration-tests/emulated/src/mock/para_chains.rs b/integration-tests/emulated/src/mock/para_chains.rs new file mode 100644 index 0000000000..11304f09c7 --- /dev/null +++ b/integration-tests/emulated/src/mock/para_chains.rs @@ -0,0 +1,217 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +use integration_tests_common::constants::{accounts, asset_hub_polkadot, polkadot::ED}; +use runtime_common::AuthorityId; +use sp_core::sr25519; +use sp_runtime::{BuildStorage, Storage}; +use xcm_emulator::{decl_test_parachains, BridgeMessageHandler, Parachain, TestExt}; + +use crate::utils::{get_account_id_from_seed, get_from_seed}; + +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; +pub mod spiritnet { + use super::*; + + use spiritnet_runtime::{ + BalancesConfig, ParachainInfoConfig, PolkadotXcmConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, + SystemConfig, WASM_BINARY, + }; + + pub const PARA_ID: u32 = 2_000; + + pub fn genesis() -> Storage { + RuntimeGenesisConfig { + system: SystemConfig { + code: WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + ..Default::default() + }, + parachain_info: ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + polkadot_xcm: PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + session: SessionConfig { + keys: vec![( + get_account_id_from_seed::("Alice"), + get_from_seed::("Alice"), + )] + .iter() + .map(|(acc, key)| (acc.clone(), acc.clone(), SessionKeys { aura: key.clone() })) + .collect::>(), + }, + balances: BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + ..Default::default() + } + .build_storage() + .unwrap() + } +} + +pub mod peregrine { + use super::*; + + use peregrine_runtime::{ + BalancesConfig, ParachainInfoConfig, PolkadotXcmConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, + SystemConfig, WASM_BINARY, + }; + + pub const PARA_ID: u32 = 2_000; + + pub fn genesis() -> Storage { + RuntimeGenesisConfig { + system: SystemConfig { + code: WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + ..Default::default() + }, + parachain_info: ParachainInfoConfig { + parachain_id: PARA_ID.into(), + ..Default::default() + }, + polkadot_xcm: PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, + session: SessionConfig { + keys: vec![( + get_account_id_from_seed::("Alice"), + get_from_seed::("Alice"), + )] + .iter() + .map(|(acc, key)| (acc.clone(), acc.clone(), SessionKeys { aura: key.clone() })) + .collect::>(), + }, + balances: BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + ..Default::default() + } + .build_storage() + .unwrap() + } +} + +decl_test_parachains! { + pub struct Spiritnet { + genesis = spiritnet::genesis(), + on_init = (), + runtime = { + Runtime: spiritnet_runtime::Runtime, + RuntimeOrigin: spiritnet_runtime::RuntimeOrigin, + RuntimeCall: spiritnet_runtime::RuntimeCall, + RuntimeEvent: spiritnet_runtime::RuntimeEvent, + XcmpMessageHandler: spiritnet_runtime::XcmpQueue, + DmpMessageHandler: spiritnet_runtime::DmpQueue, + LocationToAccountId: spiritnet_runtime::xcm_config::LocationToAccountIdConverter, + System: spiritnet_runtime::System, + Balances: spiritnet_runtime::Balances, + ParachainSystem: spiritnet_runtime::ParachainSystem, + ParachainInfo: spiritnet_runtime::ParachainInfo, + }, + pallets_extra = { + Did: spiritnet_runtime::Did, + Ctype: spiritnet_runtime::Ctype, + Attestation: spiritnet_runtime::Attestation, + Web3Names: spiritnet_runtime::Web3Names, + DidLookup: spiritnet_runtime::DidLookup, + PublicCredentials: spiritnet_runtime::PublicCredentials, + } + }, + pub struct AssetHubPolkadot { + genesis = asset_hub_polkadot::genesis(), + on_init = (), + runtime = { + Runtime: asset_hub_polkadot_runtime::Runtime, + RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin, + RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall, + RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent, + XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue, + DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue, + LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId, + System: asset_hub_polkadot_runtime::System, + Balances: asset_hub_polkadot_runtime::Balances, + ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem, + ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm, + Assets: asset_hub_polkadot_runtime::Assets, + } + }, + pub struct AssetHubRococo { + genesis = asset_hub_polkadot::genesis(), + on_init = (), + runtime = { + Runtime: asset_hub_polkadot_runtime::Runtime, + RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin, + RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall, + RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent, + XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue, + DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue, + LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId, + System: asset_hub_polkadot_runtime::System, + Balances: asset_hub_polkadot_runtime::Balances, + ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem, + ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm, + Assets: asset_hub_polkadot_runtime::Assets, + } + }, + pub struct Peregrine { + genesis = peregrine::genesis(), + on_init = (), + runtime = { + Runtime: peregrine_runtime::Runtime, + RuntimeOrigin: peregrine_runtime::RuntimeOrigin, + RuntimeCall: peregrine_runtime::RuntimeCall, + RuntimeEvent: peregrine_runtime::RuntimeEvent, + XcmpMessageHandler: peregrine_runtime::XcmpQueue, + DmpMessageHandler: peregrine_runtime::DmpQueue, + LocationToAccountId: peregrine_runtime::xcm_config::LocationToAccountIdConverter, + System: peregrine_runtime::System, + Balances: peregrine_runtime::Balances, + ParachainSystem: peregrine_runtime::ParachainSystem, + ParachainInfo: peregrine_runtime::ParachainInfo, + }, + pallets_extra = { + Did: peregrine_runtime::Did, + Ctype: peregrine_runtime::Ctype, + Attestation: peregrine_runtime::Attestation, + Web3Names: peregrine_runtime::Web3Names, + DidLookup: peregrine_runtime::DidLookup, + PublicCredentials: peregrine_runtime::PublicCredentials, + } + } +} diff --git a/integration-tests/emulated/src/mock/relay_chains.rs b/integration-tests/emulated/src/mock/relay_chains.rs new file mode 100644 index 0000000000..19e477c4ac --- /dev/null +++ b/integration-tests/emulated/src/mock/relay_chains.rs @@ -0,0 +1,59 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +use integration_tests_common::{polkadot, rococo}; +use xcm_emulator::{decl_test_relay_chains, RelayChain, TestExt, XcmHash}; + +decl_test_relay_chains! { + #[api_version(5)] + pub struct Polkadot { + genesis = polkadot::genesis(), + on_init = (), + runtime = { + Runtime: polkadot_runtime::Runtime, + RuntimeOrigin: polkadot_runtime::RuntimeOrigin, + RuntimeCall: polkadot_runtime::RuntimeCall, + RuntimeEvent: polkadot_runtime::RuntimeEvent, + MessageQueue: polkadot_runtime::MessageQueue, + XcmConfig: polkadot_runtime::xcm_config::XcmConfig, + SovereignAccountOf: polkadot_runtime::xcm_config::SovereignAccountOf, + System: polkadot_runtime::System, + Balances: polkadot_runtime::Balances, + }, + pallets_extra = { + XcmPallet: polkadot_runtime::XcmPallet, + } + }, + #[api_version(5)] + pub struct Rococo { + genesis = rococo::genesis(), + on_init = (), + runtime = { + Runtime: rococo_runtime::Runtime, + RuntimeOrigin: rococo_runtime::RuntimeOrigin, + RuntimeCall: rococo_runtime::RuntimeCall, + RuntimeEvent: rococo_runtime::RuntimeEvent, + MessageQueue: rococo_runtime::MessageQueue, + XcmConfig: rococo_runtime::xcm_config::XcmConfig, + SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, + System: rococo_runtime::System, + Balances: rococo_runtime::Balances, + }, + pallets_extra = { + XcmPallet: rococo_runtime::XcmPallet, + } + } +} diff --git a/integration-tests/emulated/src/tests/mod.rs b/integration-tests/emulated/src/tests/mod.rs new file mode 100644 index 0000000000..8e6a644c43 --- /dev/null +++ b/integration-tests/emulated/src/tests/mod.rs @@ -0,0 +1,18 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +mod peregrine; +mod spiritnet; diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/association.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/association.rs new file mode 100644 index 0000000000..99ca93c6e5 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/association.rs @@ -0,0 +1,163 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::Rococo, + }, + tests::peregrine::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_did_from_account, get_asset_hub_sovereign_account, + get_sibling_destination_peregrine, + }, +}; + +fn get_xcm_message_add_association(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::DidLookup( + pallet_did_lookup::Call::associate_sender {}, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_create_association_from_asset_hub_successful() { + MockNetworkRococo::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let init_balance = KILT * 10; + + let xcm_add_association_msg = get_xcm_message_add_association(OriginKind::SovereignAccount, KILT); + let destination = get_sibling_destination_peregrine(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination), + Box::new(xcm_add_association_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(account, result)) => { + account: account == &asset_hub_sovereign_account, + result: result.is_ok(), + }, + PeregrineRuntimeEvent::DidLookup(pallet_did_lookup::Event::AssociationEstablished(owner, did)) => { + owner: owner.as_ref() == >::as_ref(&asset_hub_sovereign_account), + did: did == &asset_hub_sovereign_account, + }, + ] + ); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); +} + +#[test] +fn test_create_association_from_asset_hub_unsuccessful() { + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + + let destination = get_sibling_destination_peregrine(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_add_association_msg = get_xcm_message_add_association(origin_kind, KILT); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_add_association_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Peregrine::events().iter().any(|event| { + matches!( + event, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | PeregrineRuntimeEvent::DidLookup(pallet_did_lookup::Event::AssociationEstablished(_, _)) + ) + }); + + assert!(!is_event_present) + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/attestation.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/attestation.rs new file mode 100644 index 0000000000..920f967d93 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/attestation.rs @@ -0,0 +1,188 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use sp_core::H256; +use xcm::VersionedXcm; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::Rococo, + }, + tests::peregrine::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_ctype, create_mock_did_from_account, + get_asset_hub_sovereign_account, get_sibling_destination_peregrine, + }, +}; + +fn get_xcm_message_attestation_creation( + origin_kind: OriginKind, + withdraw_balance: Balance, + ctype_hash: H256, + claim_hash: H256, +) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::Attestation( + attestation::Call::add { + claim_hash, + ctype_hash, + authorization: None, + }, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_attestation_creation_from_asset_hub_successful() { + MockNetworkRococo::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + + let ctype_hash_value = H256([0; 32]); + let claim_hash_value = H256([1; 32]); + + let init_balance = KILT * 10; + let withdraw_balance = init_balance / 2; + + let xcm_issue_attestation_msg = get_xcm_message_attestation_creation( + OriginKind::SovereignAccount, + withdraw_balance, + ctype_hash_value, + claim_hash_value, + ); + + let destination = get_sibling_destination_peregrine(); + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + Peregrine::execute_with(|| { + create_mock_ctype(ctype_hash_value, asset_hub_sovereign_account.clone()); + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_issue_attestation_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + PeregrineRuntimeEvent::Attestation(attestation::Event::AttestationCreated { attester, claim_hash, authorization: _ , ctype_hash }) => { + attester: attester == &asset_hub_sovereign_account, + claim_hash: claim_hash == &claim_hash_value, + ctype_hash: ctype_hash == &ctype_hash_value, + }, + ] + ); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); +} + +#[test] +fn test_attestation_creation_from_asset_hub_unsuccessful() { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + let sudo_origin = ::RuntimeOrigin::root(); + let destination = get_sibling_destination_peregrine(); + + let ctype_hash_value = H256([0; 32]); + let claim_hash_value = H256([1; 32]); + + let init_balance = KILT * 100; + let withdraw_balance = init_balance / 2; + + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + Peregrine::execute_with(|| { + create_mock_ctype(ctype_hash_value, asset_hub_sovereign_account.clone()); + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_issue_attestation_msg = + get_xcm_message_attestation_creation(origin_kind, withdraw_balance, ctype_hash_value, claim_hash_value); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_issue_attestation_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Peregrine::events().iter().any(|event| { + matches!( + event, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | PeregrineRuntimeEvent::Attestation(attestation::Event::AttestationCreated { .. }) + ) + }); + + assert!(!is_event_present); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/ctype.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/ctype.rs new file mode 100644 index 0000000000..e40bc26a66 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/ctype.rs @@ -0,0 +1,165 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::Rococo, + }, + tests::peregrine::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_did_from_account, get_asset_hub_sovereign_account, + get_sibling_destination_peregrine, + }, +}; + +fn get_xcm_message_ctype_creation(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::Ctype(ctype::Call::add { + ctype: b"{\"foo\": \"bar\"}".to_vec(), + })), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_ctype_creation_from_asset_hub_successful() { + MockNetworkRococo::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + + let init_balance = KILT * 10; + + let xcm_add_ctype_msg = get_xcm_message_ctype_creation(OriginKind::SovereignAccount, KILT); + let destination = get_sibling_destination_peregrine(); + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination), + Box::new(xcm_add_ctype_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(account, result)) => { + account: account == &asset_hub_sovereign_account, + result: result.is_ok(), + }, + PeregrineRuntimeEvent::Ctype(ctype::Event::CTypeCreated(account, _)) => { + account: account == &asset_hub_sovereign_account, + }, + ] + ); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); +} + +#[test] +fn test_ctype_creation_from_asset_hub_unsuccessful() { + let sudo_origin = ::RuntimeOrigin::root(); + + let init_balance = KILT * 10; + + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + let destination = get_sibling_destination_peregrine(); + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_add_ctype_msg = get_xcm_message_ctype_creation(origin_kind, KILT); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_add_ctype_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Peregrine::events().iter().any(|event| { + matches!( + event, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | PeregrineRuntimeEvent::Ctype(ctype::Event::CTypeCreated(_, _)) + ) + }); + + assert!(!is_event_present); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/did.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/did.rs new file mode 100644 index 0000000000..c9c00f0c7f --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/did.rs @@ -0,0 +1,167 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use did::did_details::DidVerificationKey; +use frame_support::traits::fungible::hold::Inspect; +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::Rococo, + }, + tests::peregrine::did_pallets::utils::{ + construct_basic_transact_xcm_message, get_asset_hub_sovereign_account, get_sibling_destination_peregrine, + }, +}; + +fn get_xcm_message_create_did(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::create_from_account { + authentication_key: DidVerificationKey::Account(asset_hub_sovereign_account), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_did_creation_from_asset_hub_successful() { + MockNetworkRococo::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + + let init_balance = KILT * 10; + let withdraw_balance = init_balance / 2; + + let xcm_create_did_msg = get_xcm_message_create_did(OriginKind::SovereignAccount, withdraw_balance); + let destination = get_sibling_destination_peregrine(); + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + Peregrine::execute_with(|| { + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination.clone()), + Box::new(xcm_create_did_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + PeregrineRuntimeEvent::Did(did::Event::DidCreated(account, did_identifier)) => { + account: account == &asset_hub_sovereign_account, + did_identifier: did_identifier == &asset_hub_sovereign_account, + }, + ] + ); + + let balance_on_hold = <::Balances as Inspect>::balance_on_hold( + &peregrine_runtime::RuntimeHoldReason::from(did::HoldReason::Deposit), + &asset_hub_sovereign_account, + ); + + assert_eq!( + balance_on_hold, + ::BaseDeposit::get() + ); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); +} + +#[test] +fn test_did_creation_from_asset_hub_unsuccessful() { + let sudo_origin = ::RuntimeOrigin::root(); + + let init_balance = KILT * 100; + let withdraw_balance = init_balance / 2; + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + let destination = get_sibling_destination_peregrine(); + + let origin_kind_list = vec![OriginKind::Xcm, OriginKind::Superuser, OriginKind::Native]; + + for origin in origin_kind_list { + MockNetworkRococo::reset(); + + Peregrine::execute_with(|| { + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_create_did_msg = get_xcm_message_create_did(origin, withdraw_balance); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_create_did_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + let is_create_event_present = Peregrine::events().iter().any(|event| { + matches!( + event, + PeregrineRuntimeEvent::Did(did::Event::::DidCreated(_, _)) + ) + }); + + assert!(!is_create_event_present); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/mod.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/mod.rs new file mode 100644 index 0000000000..45f84550b6 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/mod.rs @@ -0,0 +1,26 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +mod association; +mod attestation; +mod ctype; +mod did; +mod public_credentials; +mod unallowed_did_call; +mod utils; +mod w3n; diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/public_credentials.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/public_credentials.rs new file mode 100644 index 0000000000..62e25bd4a6 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/public_credentials.rs @@ -0,0 +1,184 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use sp_core::H256; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::Rococo, + }, + tests::peregrine::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_ctype, create_mock_did_from_account, + get_asset_hub_sovereign_account, get_sibling_destination_peregrine, + }, +}; + +fn get_xcm_message_add_public_credential( + origin_kind: OriginKind, + withdraw_balance: Balance, + ctype_hash: H256, +) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let subject_id = b"did:asset:eip155:1.slip44:60".to_vec(); + + let credential = public_credentials::mock::generate_base_public_credential_creation_op::( + subject_id.try_into().unwrap(), + ctype_hash, + Default::default(), + ); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::PublicCredentials( + public_credentials::Call::add { + credential: Box::new(credential), + }, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_create_public_credential_from_asset_hub_successful() { + MockNetworkRococo::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + let ctype_hash_value = H256([0; 32]); + + let init_balance = KILT * 10; + + let xcm_issue_public_credential_msg = + get_xcm_message_add_public_credential(OriginKind::SovereignAccount, KILT, ctype_hash_value); + + let destination = get_sibling_destination_peregrine(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + create_mock_ctype(ctype_hash_value, asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination), + Box::new(xcm_issue_public_credential_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(account, result)) => { + account: account == &asset_hub_sovereign_account, + result: result.is_ok(), + }, + PeregrineRuntimeEvent::PublicCredentials(public_credentials::Event::CredentialStored{ .. }) => { + + }, + ] + ); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); +} + +#[test] +fn test_create_public_credential_from_asset_hub_unsuccessful() { + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + let ctype_hash_value = H256([0; 32]); + + let destination = get_sibling_destination_peregrine(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + create_mock_ctype(ctype_hash_value, asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_issue_public_credential_msg = + get_xcm_message_add_public_credential(origin_kind, KILT, ctype_hash_value); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_issue_public_credential_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Peregrine::events().iter().any(|event| { + matches!( + event, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | PeregrineRuntimeEvent::DidLookup(pallet_did_lookup::Event::AssociationEstablished(_, _)) + ) + }); + + assert!(!is_event_present) + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/unallowed_did_call.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/unallowed_did_call.rs new file mode 100644 index 0000000000..01947510f6 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/unallowed_did_call.rs @@ -0,0 +1,192 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::Rococo, + }, + tests::peregrine::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_did_from_account, get_asset_hub_sovereign_account, + get_sibling_destination_peregrine, + }, +}; + +fn get_xcm_message_system_remark(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::System( + frame_system::Call::remark { remark: vec![] }, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +fn get_xcm_message_recursion(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account.clone(), + call: Box::new(::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::System( + frame_system::Call::remark { remark: vec![] }, + )), + })), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_not_allowed_did_call() { + let origin_kind_list = vec![ + OriginKind::Native, + OriginKind::Superuser, + OriginKind::Xcm, + OriginKind::SovereignAccount, + ]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + + let destination = get_sibling_destination_peregrine(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_invalid_did_msg = get_xcm_message_system_remark(origin_kind, KILT); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_invalid_did_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + // All calls should have [NoPermission] error + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { + error: xcm::v3::Error::NoPermission, + .. + }) => {}, + ] + ); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} + +#[test] +fn test_recursion_did_call() { + let origin_kind_list = vec![ + OriginKind::Native, + OriginKind::Superuser, + OriginKind::Xcm, + OriginKind::SovereignAccount, + ]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + + let destination = get_sibling_destination_peregrine(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_invalid_did_msg = get_xcm_message_recursion(origin_kind, KILT); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_invalid_did_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + // All calls should have [NoPermission] error + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { + error: xcm::v3::Error::NoPermission, + .. + }) => {}, + ] + ); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/utils.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/utils.rs new file mode 100644 index 0000000000..ef7fc7a3ff --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/utils.rs @@ -0,0 +1,82 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use ctype::ctype_entry::CtypeEntry; +use ctype::pallet::Ctypes; +use did::{did_details::DidVerificationKey, pallet::Did}; +use runtime_common::Balance; +use sp_core::H256; +use sp_runtime::AccountId32; +use xcm::{DoubleEncoded, VersionedMultiLocation, VersionedXcm}; +use xcm_emulator::{ + Instruction::{BuyExecution, Transact, WithdrawAsset}, + Junction, + Junctions::{self, Here}, + OriginKind, ParentThen, Weight, WeightLimit, Xcm, +}; + +use crate::mock::para_chains::{peregrine, AssetHubRococo, Peregrine}; + +pub fn create_mock_ctype(ctype_hash: H256, creator: AccountId32) { + let ctype_entry = CtypeEntry { creator, created_at: 0 }; + + Ctypes::::insert(ctype_hash, ctype_entry); +} + +pub fn get_asset_hub_sovereign_account() -> AccountId32 { + Peregrine::sovereign_account_id_of(Peregrine::sibling_location_of(AssetHubRococo::para_id())) +} + +pub fn get_sibling_destination_peregrine() -> VersionedMultiLocation { + ParentThen(Junctions::X1(Junction::Parachain(peregrine::PARA_ID))).into() +} + +pub fn create_mock_did_from_account(account: AccountId32) { + let did_key = DidVerificationKey::Account(account); + let mut details = did::did_details::DidDetails::::new( + did_key.clone(), + 0, + AccountId32::new([0u8; 32]), + ) + .expect("Failed to generate new DidDetails"); + + details.update_attestation_key(did_key, 0).unwrap(); + + Did::::insert(get_asset_hub_sovereign_account(), details); +} + +pub fn construct_basic_transact_xcm_message( + origin_kind: OriginKind, + withdraw_balance: Balance, + call: DoubleEncoded<()>, +) -> VersionedXcm<()> { + let require_weight_at_most = Weight::from_parts(10_000_600_000_000, 200_000_000_000); + + VersionedXcm::from(Xcm(vec![ + WithdrawAsset((Here, withdraw_balance).into()), + BuyExecution { + fees: (Here, withdraw_balance).into(), + weight_limit: WeightLimit::Unlimited, + }, + Transact { + origin_kind, + require_weight_at_most, + call, + }, + ])) +} diff --git a/integration-tests/emulated/src/tests/peregrine/did_pallets/w3n.rs b/integration-tests/emulated/src/tests/peregrine/did_pallets/w3n.rs new file mode 100644 index 0000000000..341d948e17 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/did_pallets/w3n.rs @@ -0,0 +1,168 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use sp_runtime::BoundedVec; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::Rococo, + }, + tests::peregrine::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_did_from_account, get_asset_hub_sovereign_account, + get_sibling_destination_peregrine, + }, +}; + +fn get_xcm_message_claim_w3n(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::Web3Names( + pallet_web3_names::Call::claim { + name: BoundedVec::try_from(b"adelo".to_vec()).unwrap(), + }, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_claim_w3n_from_asset_hub_successful() { + MockNetworkRococo::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let init_balance = KILT * 10; + + let xcm_claim_w3n_msg = get_xcm_message_claim_w3n(OriginKind::SovereignAccount, KILT); + let destination = get_sibling_destination_peregrine(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination), + Box::new(xcm_claim_w3n_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(account, result)) => { + account: account == &asset_hub_sovereign_account, + result: result.is_ok(), + }, + PeregrineRuntimeEvent::Web3Names(pallet_web3_names::Event::Web3NameClaimed{owner, name: _}) => { + owner: owner == &asset_hub_sovereign_account, + }, + ] + ); + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); +} + +#[test] +fn test_claim_w3n_from_asset_hub_unsuccessful() { + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + + let destination = get_sibling_destination_peregrine(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + Peregrine::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_claim_w3n_msg = get_xcm_message_claim_w3n(origin_kind, KILT); + + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_claim_w3n_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Peregrine::events().iter().any(|event| { + matches!( + event, + PeregrineRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | PeregrineRuntimeEvent::Web3Names(pallet_web3_names::Event::Web3NameClaimed { + owner: _, + name: _ + }) + ) + }); + + assert!(!is_event_present) + }); + + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/peregrine/mod.rs b/integration-tests/emulated/src/tests/peregrine/mod.rs new file mode 100644 index 0000000000..456048c83f --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/mod.rs @@ -0,0 +1,23 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +mod did_pallets; +mod reserve_transfers; +mod sudo; +mod teleportation; +mod unpaid_execution; diff --git a/integration-tests/emulated/src/tests/peregrine/reserve_transfers.rs b/integration-tests/emulated/src/tests/peregrine/reserve_transfers.rs new file mode 100644 index 0000000000..176f5182ae --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/reserve_transfers.rs @@ -0,0 +1,142 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, dispatch::RawOrigin, traits::fungible::Inspect}; +use integration_tests_common::{asset_hub_polkadot, polkadot::ED, ALICE}; +use peregrine_runtime::PolkadotXcm as PeregrineXcm; +use runtime_common::AccountId; +use sp_core::sr25519; +use sp_runtime::traits::Zero; +use xcm::v3::WeightLimit; +use xcm_emulator::{ + assert_expected_events, cumulus_pallet_xcmp_queue::Event as XcmpQueueEvent, Here, Junction, Junctions, Parachain, + Parent, ParentThen, TestExt, X1, +}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, Peregrine}, + relay_chains::Rococo, + }, + utils::get_account_id_from_seed, +}; + +/// Test that a reserved transfer to the relaychain is failing. We don't want to +/// allow transfers to the relaychain since the funds might be lost. +#[test] +fn test_reserve_asset_transfer_from_regular_peregrine_account_to_relay() { + MockNetworkRococo::reset(); + + let alice_account = get_account_id_from_seed::(ALICE); + + Peregrine::execute_with(|| { + assert_ok!(PeregrineXcm::limited_reserve_transfer_assets( + RawOrigin::Signed(alice_account.clone()).into(), + Box::new(Parent.into()), + Box::new( + X1(Junction::AccountId32 { + network: None, + id: alice_account.into() + }) + .into() + ), + Box::new((Here, 1_000_000).into()), + 0, + WeightLimit::Unlimited, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Peregrine, + vec![RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Attempted { + outcome: xcm::latest::Outcome::Error(xcm::latest::Error::Barrier) + }) => {},] + ); + }); + // No message should reach the relaychain. + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }) +} + +#[test] +fn test_reserve_asset_transfer_from_regular_peregrine_account_to_asset_hub() { + MockNetworkRococo::reset(); + + let alice_account_id = get_account_id_from_seed::(ALICE); + let asset_hub_sovereign_account = + Peregrine::sovereign_account_id_of(Peregrine::sibling_location_of(AssetHubRococo::para_id())); + + let balance_to_transfer = 1000 * ED; + + Peregrine::execute_with(|| { + // the sovereign_account of AssetHub should have no coins. + let balance_before_transfer: u128 = + <::Balances as Inspect>::balance(&asset_hub_sovereign_account); + + assert!(balance_before_transfer.is_zero()); + + // submit xcm message + assert_ok!(PeregrineXcm::limited_reserve_transfer_assets( + RawOrigin::Signed(alice_account_id.clone()).into(), + Box::new(ParentThen(Junctions::X1(Junction::Parachain(asset_hub_polkadot::PARA_ID))).into()), + Box::new( + X1(Junction::AccountId32 { + network: None, + id: asset_hub_sovereign_account.clone().into() + }) + .into() + ), + Box::new((Here, balance_to_transfer).into()), + 0, + WeightLimit::Unlimited, + )); + + type RuntimeEvent = ::RuntimeEvent; + + // we expect to have the [Complete] event. + assert_expected_events!( + Peregrine, + vec![RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Attempted { + outcome: xcm::latest::Outcome::Complete(_) + }) => {}, + ] + ); + + // we also expect that the sovereignAccount of AssetHub has some coins now + let balance_after_transfer: u128 = + <::Balances as Inspect>::balance(&asset_hub_sovereign_account); + + assert_eq!(balance_after_transfer, balance_to_transfer); + }); + // No event on the relaychain (message is meant for AssetHub. + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + // Fails on AssetHub since peregrine is not a trusted registrar + AssetHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubRococo, + vec![RuntimeEvent::XcmpQueue(XcmpQueueEvent::Fail { .. }) => {},] + ); + }); +} diff --git a/integration-tests/emulated/src/tests/peregrine/sudo.rs b/integration-tests/emulated/src/tests/peregrine/sudo.rs new file mode 100644 index 0000000000..3f7762af5a --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/sudo.rs @@ -0,0 +1,212 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{v3::WeightLimit, DoubleEncoded, VersionedMultiLocation, VersionedXcm}; +use xcm_emulator::{ + assert_expected_events, Here, + Instruction::{BuyExecution, Transact, UnpaidExecution, WithdrawAsset}, + Junction, Junctions, OriginKind, Parachain, ParentThen, RelayChain, TestExt, Weight, Xcm, +}; + +use crate::mock::{ + network::MockNetworkRococo, + para_chains::{peregrine, AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::{Rococo, RococoPallet}, +}; + +fn get_sovereign_account_id_of_asset_hub() -> AccountId { + Peregrine::sovereign_account_id_of(Peregrine::sibling_location_of(AssetHubRococo::para_id())) +} + +fn get_parachain_destination_from_parachain() -> VersionedMultiLocation { + ParentThen(Junctions::X1(Junction::Parachain(peregrine::PARA_ID))).into() +} + +fn get_parachain_destination_from_relay_chain() -> VersionedMultiLocation { + Rococo::child_location_of(peregrine::PARA_ID.into()).into_versioned() +} + +fn get_unpaid_xcm_message(origin_kind: OriginKind) -> VersionedXcm<()> { + let code = vec![]; + let call: DoubleEncoded<()> = ::RuntimeCall::System(frame_system::Call::set_code { code }) + .encode() + .into(); + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1600000000000, 200000); + + VersionedXcm::from(Xcm(vec![ + UnpaidExecution { + weight_limit, + check_origin: None, + }, + Transact { + origin_kind, + require_weight_at_most, + call, + }, + ])) +} + +fn get_paid_xcm_message(init_balance: Balance, origin_kind: OriginKind) -> VersionedXcm<()> { + let code = vec![]; + + let call: DoubleEncoded<()> = ::RuntimeCall::System(frame_system::Call::set_code { code }) + .encode() + .into(); + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1600000000000, 200000); + let withdraw_asset = init_balance / 2; + + VersionedXcm::from(Xcm(vec![ + WithdrawAsset((Here, withdraw_asset).into()), + BuyExecution { + fees: (Here, withdraw_asset).into(), + weight_limit, + }, + Transact { + origin_kind, + require_weight_at_most, + call, + }, + ])) +} + +#[test] +fn test_sudo_call_from_relay_chain_to_peregrine() { + let sudo_origin = ::RuntimeOrigin::root(); + let parachain_destination = get_parachain_destination_from_relay_chain(); + + let origin_kind_list = vec![ + OriginKind::Superuser, + OriginKind::Native, + OriginKind::SovereignAccount, + OriginKind::Xcm, + ]; + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + let xcm = get_unpaid_xcm_message(origin_kind); + + //Send XCM message from relay chain + Rococo::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin.clone(), + Box::new(parachain_destination.clone()), + Box::new(xcm) + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { + outcome: xcm::v3::Outcome::Incomplete(_, xcm::v3::Error::NoPermission), + .. + }) => {}, + ] + ); + }); + + // No event on the AssetHub message is meant for peregrine + AssetHubRococo::execute_with(|| { + assert_eq!(AssetHubRococo::events().len(), 0); + }); + } +} + +#[test] +fn test_sudo_call_from_asset_hub_to_peregrine() { + let asset_hub_sovereign_account = get_sovereign_account_id_of_asset_hub(); + + let sudo_origin = ::RuntimeOrigin::root(); + + let parachain_destination = get_parachain_destination_from_parachain(); + let init_balance = KILT * 10; + + let origin_kind_list = vec![ + OriginKind::Superuser, + OriginKind::Native, + OriginKind::SovereignAccount, + OriginKind::Xcm, + ]; + + for origin_kind in origin_kind_list { + MockNetworkRococo::reset(); + + let xcm = get_paid_xcm_message(init_balance, origin_kind); + + // give the sovereign account of AssetHub some coins. + Peregrine::execute_with(|| { + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + //Send XCM message from AssetHub + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(parachain_destination.clone()), + Box::new(xcm) + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // We expect to get the [NoPermission] error + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { + error: xcm::v3::Error::NoPermission, + .. + }) => {}, + ] + ); + }); + + // No event on the relaychain. Message is for AssetHub + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/peregrine/teleportation.rs b/integration-tests/emulated/src/tests/peregrine/teleportation.rs new file mode 100644 index 0000000000..f92b3a1ef6 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/teleportation.rs @@ -0,0 +1,70 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::assert_noop; +use frame_support::dispatch::RawOrigin; +use integration_tests_common::{asset_hub_polkadot, polkadot::ED, ALICE, BOB}; +use peregrine_runtime::PolkadotXcm as PeregrineXcm; +use sp_core::sr25519; +use xcm::v3::WeightLimit; +use xcm_emulator::{Here, Junction, Junctions, ParentThen, TestExt, X1}; + +use crate::{ + mock::{ + network::MockNetworkRococo, + para_chains::{AssetHubRococo, Peregrine}, + relay_chains::Rococo, + }, + utils::get_account_id_from_seed, +}; + +#[test] +fn test_teleport_asset_from_regular_peregrine_account_to_asset_hub() { + MockNetworkRococo::reset(); + + let alice_account_id = get_account_id_from_seed::(ALICE); + let bob_account_id = get_account_id_from_seed::(BOB); + + Peregrine::execute_with(|| { + assert_noop!( + PeregrineXcm::limited_teleport_assets( + RawOrigin::Signed(alice_account_id.clone()).into(), + Box::new(ParentThen(Junctions::X1(Junction::Parachain(asset_hub_polkadot::PARA_ID))).into()), + Box::new( + X1(Junction::AccountId32 { + network: None, + id: bob_account_id.into() + }) + .into() + ), + Box::new((Here, 1000 * ED).into()), + 0, + WeightLimit::Unlimited, + ), + pallet_xcm::Error::::Filtered + ); + }); + // No event on the relaychain Message is for AssetHub + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); + // AssetHub should not receive any message, since the message is filtered out. + AssetHubRococo::execute_with(|| { + assert_eq!(AssetHubRococo::events().len(), 0); + }); +} diff --git a/integration-tests/emulated/src/tests/peregrine/unpaid_execution.rs b/integration-tests/emulated/src/tests/peregrine/unpaid_execution.rs new file mode 100644 index 0000000000..d5f590d785 --- /dev/null +++ b/integration-tests/emulated/src/tests/peregrine/unpaid_execution.rs @@ -0,0 +1,175 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use did::did_details::DidVerificationKey; +use frame_support::{ + assert_ok, + traits::fungible::{Inspect, Mutate}, +}; +use parity_scale_codec::Encode; +use runtime_common::{constants::EXISTENTIAL_DEPOSIT, AccountId}; +use xcm::{v3::WeightLimit, DoubleEncoded, VersionedMultiLocation, VersionedXcm}; +use xcm_emulator::{ + assert_expected_events, + Instruction::{Transact, UnpaidExecution}, + Junction, Junctions, Outcome, Parachain, ParentThen, RelayChain, TestExt, Weight, Xcm, +}; + +use crate::mock::{ + network::MockNetworkRococo, + para_chains::{peregrine, AssetHubRococo, AssetHubRococoPallet, Peregrine}, + relay_chains::{Rococo, RococoPallet}, +}; + +#[test] +fn test_unpaid_execution_from_asset_hub_to_peregrine() { + MockNetworkRococo::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let parachain_destination: VersionedMultiLocation = + ParentThen(Junctions::X1(Junction::Parachain(peregrine::PARA_ID))).into(); + + let weight_limit = WeightLimit::Unlimited; + let check_origin = None; + + let xcm = VersionedXcm::from(Xcm(vec![UnpaidExecution { + weight_limit, + check_origin, + }])); + + //Send XCM message from Parachain + AssetHubRococo::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(parachain_destination), + Box::new(xcm) + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { + error: xcm::v3::Error::Barrier, + .. + }) => {}, + ] + ); + }); + + // No event on Rococo. message is meant for Peregrine + Rococo::execute_with(|| { + assert_eq!(Rococo::events().len(), 0); + }); +} + +#[test] +fn test_unpaid_execution_from_rococo_to_peregrine() { + MockNetworkRococo::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let parachain_destination: VersionedMultiLocation = Junctions::X1(Junction::Parachain(peregrine::PARA_ID)).into(); + let init_balance = ::BaseDeposit::get() + + ::Fee::get() + + EXISTENTIAL_DEPOSIT; + + let weight_limit = WeightLimit::Unlimited; + let check_origin = None; + + let polkadot_sovereign_account = Peregrine::sovereign_account_id_of(Peregrine::parent_location()); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::create_from_account { + authentication_key: DidVerificationKey::Account(polkadot_sovereign_account.clone()), + }) + .encode() + .into(); + + let xcm = VersionedXcm::from(Xcm(vec![ + UnpaidExecution { + weight_limit, + check_origin, + }, + Transact { + origin_kind: xcm_emulator::OriginKind::SovereignAccount, + require_weight_at_most: Weight::from_parts(10_000_600_000_000, 200_000_000_000), + call, + }, + ])); + + Peregrine::execute_with(|| { + // DID creation takes a deposit of 2 KILT coins + Fees. We have to give them to the sovereign account. Otherwise, the extrinsic will fail. + >::set_balance(&polkadot_sovereign_account, init_balance); + }); + + //Send XCM message from relaychain + Rococo::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + Box::new(parachain_destination), + Box::new(xcm) + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Rococo, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Peregrine::execute_with(|| { + type PeregrineRuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + Peregrine, + vec![ + PeregrineRuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { + outcome: Outcome::Complete(_), + .. + }) => {}, + PeregrineRuntimeEvent::Did(did::Event::DidCreated(account, did_identifier)) => { + account: account == &polkadot_sovereign_account, + did_identifier: did_identifier == &polkadot_sovereign_account, + }, + ] + ); + + // Since the user have not paid any tx fees, we expect that the free balance is the ED + let balance_after_transfer: u128 = + <::Balances as Inspect>::balance(&polkadot_sovereign_account); + + assert_eq!(balance_after_transfer, EXISTENTIAL_DEPOSIT); + }); + + // No event on AssetHubRococo. message is meant for Peregrine + AssetHubRococo::execute_with(|| { + assert_eq!(AssetHubRococo::events().len(), 0); + }); +} diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/association.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/association.rs new file mode 100644 index 0000000000..d3abdb778c --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/association.rs @@ -0,0 +1,163 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::Polkadot, + }, + tests::spiritnet::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_did_from_account, get_asset_hub_sovereign_account, + get_sibling_destination_spiritnet, + }, +}; + +fn get_xcm_message_add_association(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::DidLookup( + pallet_did_lookup::Call::associate_sender {}, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_create_association_from_asset_hub_successful() { + MockNetworkPolkadot::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let init_balance = KILT * 10; + + let xcm_add_association_msg = get_xcm_message_add_association(OriginKind::SovereignAccount, KILT); + let destination = get_sibling_destination_spiritnet(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination), + Box::new(xcm_add_association_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(account, result)) => { + account: account == &asset_hub_sovereign_account, + result: result.is_ok(), + }, + SpiritnetRuntimeEvent::DidLookup(pallet_did_lookup::Event::AssociationEstablished(owner, did)) => { + owner: owner.as_ref() == >::as_ref(&asset_hub_sovereign_account), + did: did == &asset_hub_sovereign_account, + }, + ] + ); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); +} + +#[test] +fn test_create_association_from_asset_hub_unsuccessful() { + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + + let destination = get_sibling_destination_spiritnet(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_add_association_msg = get_xcm_message_add_association(origin_kind, KILT); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_add_association_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Spiritnet::events().iter().any(|event| { + matches!( + event, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | SpiritnetRuntimeEvent::DidLookup(pallet_did_lookup::Event::AssociationEstablished(_, _)) + ) + }); + + assert!(!is_event_present) + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/attestation.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/attestation.rs new file mode 100644 index 0000000000..a9e739ac32 --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/attestation.rs @@ -0,0 +1,188 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use sp_core::H256; +use xcm::VersionedXcm; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::Polkadot, + }, + tests::spiritnet::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_ctype, create_mock_did_from_account, + get_asset_hub_sovereign_account, get_sibling_destination_spiritnet, + }, +}; + +fn get_xcm_message_attestation_creation( + origin_kind: OriginKind, + withdraw_balance: Balance, + ctype_hash: H256, + claim_hash: H256, +) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::Attestation( + attestation::Call::add { + claim_hash, + ctype_hash, + authorization: None, + }, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_attestation_creation_from_asset_hub_successful() { + MockNetworkPolkadot::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + + let ctype_hash_value = H256([0; 32]); + let claim_hash_value = H256([1; 32]); + + let init_balance = KILT * 10; + let withdraw_balance = init_balance / 2; + + let xcm_issue_attestation_msg = get_xcm_message_attestation_creation( + OriginKind::SovereignAccount, + withdraw_balance, + ctype_hash_value, + claim_hash_value, + ); + + let destination = get_sibling_destination_spiritnet(); + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + Spiritnet::execute_with(|| { + create_mock_ctype(ctype_hash_value, asset_hub_sovereign_account.clone()); + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_issue_attestation_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + SpiritnetRuntimeEvent::Attestation(attestation::Event::AttestationCreated { attester, claim_hash, authorization: _ , ctype_hash }) => { + attester: attester == &asset_hub_sovereign_account, + claim_hash: claim_hash == &claim_hash_value, + ctype_hash: ctype_hash == &ctype_hash_value, + }, + ] + ); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); +} + +#[test] +fn test_attestation_creation_from_asset_hub_unsuccessful() { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + let sudo_origin = ::RuntimeOrigin::root(); + let destination = get_sibling_destination_spiritnet(); + + let ctype_hash_value = H256([0; 32]); + let claim_hash_value = H256([1; 32]); + + let init_balance = KILT * 100; + let withdraw_balance = init_balance / 2; + + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + + Spiritnet::execute_with(|| { + create_mock_ctype(ctype_hash_value, asset_hub_sovereign_account.clone()); + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_issue_attestation_msg = + get_xcm_message_attestation_creation(origin_kind, withdraw_balance, ctype_hash_value, claim_hash_value); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_issue_attestation_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Spiritnet::events().iter().any(|event| { + matches!( + event, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | SpiritnetRuntimeEvent::Attestation(attestation::Event::AttestationCreated { .. }) + ) + }); + + assert!(!is_event_present); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/ctype.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/ctype.rs new file mode 100644 index 0000000000..0e386dfa31 --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/ctype.rs @@ -0,0 +1,165 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::Polkadot, + }, + tests::spiritnet::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_did_from_account, get_asset_hub_sovereign_account, + get_sibling_destination_spiritnet, + }, +}; + +fn get_xcm_message_ctype_creation(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::Ctype(ctype::Call::add { + ctype: b"{\"foo\": \"bar\"}".to_vec(), + })), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_ctype_creation_from_asset_hub_successful() { + MockNetworkPolkadot::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + + let init_balance = KILT * 10; + + let xcm_create_ctype_msg = get_xcm_message_ctype_creation(OriginKind::SovereignAccount, KILT); + let destination = get_sibling_destination_spiritnet(); + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination), + Box::new(xcm_create_ctype_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(account, result)) => { + account: account == &asset_hub_sovereign_account, + result: result.is_ok(), + }, + SpiritnetRuntimeEvent::Ctype(ctype::Event::CTypeCreated(account, _)) => { + account: account == &asset_hub_sovereign_account, + }, + ] + ); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); +} + +#[test] +fn test_ctype_creation_from_asset_hub_unsuccessful() { + let sudo_origin = ::RuntimeOrigin::root(); + + let init_balance = KILT * 10; + + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + let destination = get_sibling_destination_spiritnet(); + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_create_ctype_msg = get_xcm_message_ctype_creation(origin_kind, KILT); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_create_ctype_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Spiritnet::events().iter().any(|event| { + matches!( + event, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | SpiritnetRuntimeEvent::Ctype(ctype::Event::CTypeCreated(_, _)) + ) + }); + + assert!(!is_event_present); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/did.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/did.rs new file mode 100644 index 0000000000..a38c6eeb71 --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/did.rs @@ -0,0 +1,167 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use did::did_details::DidVerificationKey; +use frame_support::traits::fungible::hold::Inspect; +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::Polkadot, + }, + tests::spiritnet::did_pallets::utils::{ + construct_basic_transact_xcm_message, get_asset_hub_sovereign_account, get_sibling_destination_spiritnet, + }, +}; + +fn get_xcm_message_create_did(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::create_from_account { + authentication_key: DidVerificationKey::Account(asset_hub_sovereign_account), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_did_creation_from_asset_hub_successful() { + MockNetworkPolkadot::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + + let init_balance = KILT * 10; + let withdraw_balance = init_balance / 2; + + let xcm_create_did_msg = get_xcm_message_create_did(OriginKind::SovereignAccount, withdraw_balance); + let destination = get_sibling_destination_spiritnet(); + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + Spiritnet::execute_with(|| { + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination.clone()), + Box::new(xcm_create_did_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + SpiritnetRuntimeEvent::Did(did::Event::DidCreated(account, did_identifier)) => { + account: account == &asset_hub_sovereign_account, + did_identifier: did_identifier == &asset_hub_sovereign_account, + }, + ] + ); + + let balance_on_hold = <::Balances as Inspect>::balance_on_hold( + &spiritnet_runtime::RuntimeHoldReason::from(did::HoldReason::Deposit), + &asset_hub_sovereign_account, + ); + + assert_eq!( + balance_on_hold, + ::BaseDeposit::get() + ); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); +} + +#[test] +fn test_did_creation_from_asset_hub_unsuccessful() { + let sudo_origin = ::RuntimeOrigin::root(); + + let init_balance = KILT * 100; + let withdraw_balance = init_balance / 2; + + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + let destination = get_sibling_destination_spiritnet(); + + let origin_kind_list = vec![OriginKind::Xcm, OriginKind::Superuser, OriginKind::Native]; + + for origin in origin_kind_list { + MockNetworkPolkadot::reset(); + + Spiritnet::execute_with(|| { + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_create_did_msg = get_xcm_message_create_did(origin, withdraw_balance); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_create_did_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + let is_create_event_present = Spiritnet::events().iter().any(|event| { + matches!( + event, + SpiritnetRuntimeEvent::Did(did::Event::::DidCreated(_, _)) + ) + }); + + assert!(!is_create_event_present); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/mod.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/mod.rs new file mode 100644 index 0000000000..45f84550b6 --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/mod.rs @@ -0,0 +1,26 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +mod association; +mod attestation; +mod ctype; +mod did; +mod public_credentials; +mod unallowed_did_call; +mod utils; +mod w3n; diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/public_credentials.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/public_credentials.rs new file mode 100644 index 0000000000..4f96905111 --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/public_credentials.rs @@ -0,0 +1,184 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use sp_core::H256; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::Polkadot, + }, + tests::spiritnet::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_ctype, create_mock_did_from_account, + get_asset_hub_sovereign_account, get_sibling_destination_spiritnet, + }, +}; + +fn get_xcm_message_add_public_credential( + origin_kind: OriginKind, + withdraw_balance: Balance, + ctype_hash: H256, +) -> VersionedXcm<()> { + let asset_hub_sovereign_account: sp_runtime::AccountId32 = get_asset_hub_sovereign_account(); + + let subject_id = b"did:asset:eip155:1.slip44:60".to_vec(); + + let credential = public_credentials::mock::generate_base_public_credential_creation_op::( + subject_id.try_into().unwrap(), + ctype_hash, + Default::default(), + ); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::PublicCredentials( + public_credentials::Call::add { + credential: Box::new(credential), + }, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_create_public_credential_from_asset_hub_successful() { + MockNetworkPolkadot::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + let ctype_hash_value = H256([0; 32]); + + let init_balance = KILT * 10; + + let xcm_issue_public_credential_msg = + get_xcm_message_add_public_credential(OriginKind::SovereignAccount, KILT, ctype_hash_value); + + let destination = get_sibling_destination_spiritnet(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + create_mock_ctype(ctype_hash_value, asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination), + Box::new(xcm_issue_public_credential_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(account, result)) => { + account: account == &asset_hub_sovereign_account, + result: result.is_ok(), + }, + SpiritnetRuntimeEvent::PublicCredentials(public_credentials::Event::CredentialStored{ .. }) => { + + }, + ] + ); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); +} + +#[test] +fn test_create_public_credential_from_asset_hub_unsuccessful() { + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + let ctype_hash_value = H256([0; 32]); + + let destination = get_sibling_destination_spiritnet(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + + Polkadot::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + create_mock_ctype(ctype_hash_value, asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_issue_public_credential_msg = + get_xcm_message_add_public_credential(origin_kind, KILT, ctype_hash_value); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_issue_public_credential_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Spiritnet::events().iter().any(|event| { + matches!( + event, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | SpiritnetRuntimeEvent::DidLookup(pallet_did_lookup::Event::AssociationEstablished(_, _)) + ) + }); + + assert!(!is_event_present) + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/unallowed_did_call.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/unallowed_did_call.rs new file mode 100644 index 0000000000..18df0efa6b --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/unallowed_did_call.rs @@ -0,0 +1,192 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::Polkadot, + }, + tests::spiritnet::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_did_from_account, get_asset_hub_sovereign_account, + get_sibling_destination_spiritnet, + }, +}; + +fn get_xcm_message_system_remark(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::System( + frame_system::Call::remark { remark: vec![] }, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +fn get_xcm_message_recursion(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account.clone(), + call: Box::new(::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::System( + frame_system::Call::remark { remark: vec![] }, + )), + })), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_not_allowed_did_call() { + let origin_kind_list = vec![ + OriginKind::Native, + OriginKind::Superuser, + OriginKind::Xcm, + OriginKind::SovereignAccount, + ]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + + let destination = get_sibling_destination_spiritnet(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_invalid_did_msg = get_xcm_message_system_remark(origin_kind, KILT); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_invalid_did_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + // All calls should have [NoPermission] error + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { + error: xcm::v3::Error::NoPermission, + .. + }) => {}, + ] + ); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} + +#[test] +fn test_recursion_did_call() { + let origin_kind_list = vec![ + OriginKind::Native, + OriginKind::Superuser, + OriginKind::Xcm, + OriginKind::SovereignAccount, + ]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + + let destination = get_sibling_destination_spiritnet(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_invalid_did_msg = get_xcm_message_recursion(origin_kind, KILT); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_invalid_did_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + // All calls should have [NoPermission] error + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { + error: xcm::v3::Error::NoPermission, + .. + }) => {}, + ] + ); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/utils.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/utils.rs new file mode 100644 index 0000000000..a99be9d17c --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/utils.rs @@ -0,0 +1,82 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use ctype::ctype_entry::CtypeEntry; +use ctype::pallet::Ctypes; +use did::{did_details::DidVerificationKey, pallet::Did}; +use runtime_common::{AccountId, Balance}; +use sp_core::H256; +use sp_runtime::AccountId32; +use xcm::{DoubleEncoded, VersionedMultiLocation, VersionedXcm}; +use xcm_emulator::{ + Instruction::{BuyExecution, Transact, WithdrawAsset}, + Junction, + Junctions::{self, Here}, + OriginKind, ParentThen, Weight, WeightLimit, Xcm, +}; + +use crate::mock::para_chains::{spiritnet, AssetHubPolkadot, Spiritnet}; + +pub fn create_mock_ctype(ctype_hash: H256, creator: AccountId32) { + let ctype_entry = CtypeEntry { creator, created_at: 0 }; + + Ctypes::::insert(ctype_hash, ctype_entry); +} + +pub fn get_asset_hub_sovereign_account() -> AccountId { + Spiritnet::sovereign_account_id_of(Spiritnet::sibling_location_of(AssetHubPolkadot::para_id())) +} + +pub fn get_sibling_destination_spiritnet() -> VersionedMultiLocation { + ParentThen(Junctions::X1(Junction::Parachain(spiritnet::PARA_ID))).into() +} + +pub fn create_mock_did_from_account(account: AccountId32) { + let did_key = DidVerificationKey::Account(account); + let mut details = did::did_details::DidDetails::::new( + did_key.clone(), + 0, + AccountId32::new([0u8; 32]), + ) + .expect("Failed to generate new DidDetails"); + + details.update_attestation_key(did_key, 0).unwrap(); + + Did::::insert(get_asset_hub_sovereign_account(), details); +} + +pub fn construct_basic_transact_xcm_message( + origin_kind: OriginKind, + withdraw_balance: Balance, + call: DoubleEncoded<()>, +) -> VersionedXcm<()> { + let require_weight_at_most = Weight::from_parts(10_000_600_000_000, 200_000_000_000); + + VersionedXcm::from(Xcm(vec![ + WithdrawAsset((Here, withdraw_balance).into()), + BuyExecution { + fees: (Here, withdraw_balance).into(), + weight_limit: WeightLimit::Unlimited, + }, + Transact { + origin_kind, + require_weight_at_most, + call, + }, + ])) +} diff --git a/integration-tests/emulated/src/tests/spiritnet/did_pallets/w3n.rs b/integration-tests/emulated/src/tests/spiritnet/did_pallets/w3n.rs new file mode 100644 index 0000000000..dc82e031d9 --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/did_pallets/w3n.rs @@ -0,0 +1,168 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use sp_runtime::BoundedVec; +use xcm::{DoubleEncoded, VersionedXcm}; +use xcm_emulator::{assert_expected_events, OriginKind, Parachain, TestExt}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::Polkadot, + }, + tests::spiritnet::did_pallets::utils::{ + construct_basic_transact_xcm_message, create_mock_did_from_account, get_asset_hub_sovereign_account, + get_sibling_destination_spiritnet, + }, +}; + +fn get_xcm_message_claim_w3n(origin_kind: OriginKind, withdraw_balance: Balance) -> VersionedXcm<()> { + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::dispatch_as { + did_identifier: asset_hub_sovereign_account, + call: Box::new(::RuntimeCall::Web3Names( + pallet_web3_names::Call::claim { + name: BoundedVec::try_from(b"adelo".to_vec()).unwrap(), + }, + )), + }) + .encode() + .into(); + + construct_basic_transact_xcm_message(origin_kind, withdraw_balance, call) +} + +#[test] +fn test_claim_w3n_from_asset_hub_successful() { + MockNetworkPolkadot::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + let init_balance = KILT * 10; + + let xcm_claim_w3n_msg = get_xcm_message_claim_w3n(OriginKind::SovereignAccount, KILT); + let destination = get_sibling_destination_spiritnet(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(destination), + Box::new(xcm_claim_w3n_msg) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(account, result)) => { + account: account == &asset_hub_sovereign_account, + result: result.is_ok(), + }, + SpiritnetRuntimeEvent::Web3Names(pallet_web3_names::Event::Web3NameClaimed{owner, name: _}) => { + owner: owner == &asset_hub_sovereign_account, + }, + ] + ); + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); +} + +#[test] +fn test_claim_w3n_from_asset_hub_unsuccessful() { + let origin_kind_list = vec![OriginKind::Native, OriginKind::Superuser, OriginKind::Xcm]; + + let sudo_origin = ::RuntimeOrigin::root(); + let init_balance = KILT * 100; + + let destination = get_sibling_destination_spiritnet(); + let asset_hub_sovereign_account = get_asset_hub_sovereign_account(); + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + + Spiritnet::execute_with(|| { + create_mock_did_from_account(asset_hub_sovereign_account.clone()); + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + let xcm_claim_w3n_msg = get_xcm_message_claim_w3n(origin_kind, KILT); + + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(destination.clone()), + Box::new(xcm_claim_w3n_msg.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + let is_event_present = Spiritnet::events().iter().any(|event| { + matches!( + event, + SpiritnetRuntimeEvent::Did(did::Event::DidCallDispatched(_, _)) + | SpiritnetRuntimeEvent::Web3Names(pallet_web3_names::Event::Web3NameClaimed { + owner: _, + name: _ + }) + ) + }); + + assert!(!is_event_present) + }); + + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/spiritnet/mod.rs b/integration-tests/emulated/src/tests/spiritnet/mod.rs new file mode 100644 index 0000000000..456048c83f --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/mod.rs @@ -0,0 +1,23 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +mod did_pallets; +mod reserve_transfers; +mod sudo; +mod teleportation; +mod unpaid_execution; diff --git a/integration-tests/emulated/src/tests/spiritnet/reserve_transfers.rs b/integration-tests/emulated/src/tests/spiritnet/reserve_transfers.rs new file mode 100644 index 0000000000..80cc358555 --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/reserve_transfers.rs @@ -0,0 +1,149 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{assert_ok, dispatch::RawOrigin, traits::fungible::Inspect}; +use integration_tests_common::{asset_hub_polkadot, polkadot::ED, ALICE}; +use runtime_common::AccountId; +use sp_core::sr25519; +use sp_runtime::traits::Zero; +use spiritnet_runtime::PolkadotXcm as SpiritnetXcm; +use xcm::v3::WeightLimit; +use xcm_emulator::{ + assert_expected_events, cumulus_pallet_xcmp_queue::Event as XcmpQueueEvent, Here, Junction, Junctions, Parachain, + Parent, ParentThen, TestExt, X1, +}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, Spiritnet}, + relay_chains::Polkadot, + }, + utils::get_account_id_from_seed, +}; + +/// Test that a reserved transfer to the relaychain is failing. We don't want to +/// allow transfers to the relaychain since the funds might be lost. +#[test] +fn test_reserve_asset_transfer_from_regular_spiritnet_account_to_relay() { + MockNetworkPolkadot::reset(); + + let alice_account = get_account_id_from_seed::(ALICE); + + // Submit XCM msg + Spiritnet::execute_with(|| { + assert_ok!(SpiritnetXcm::limited_reserve_transfer_assets( + RawOrigin::Signed(alice_account.clone()).into(), + Box::new(Parent.into()), + Box::new( + X1(Junction::AccountId32 { + network: None, + id: alice_account.into() + }) + .into() + ), + Box::new((Here, 1_000_000).into()), + 0, + WeightLimit::Unlimited, + )); + + type RuntimeEvent = ::RuntimeEvent; + + // The msg should be blocked by the barrier + assert_expected_events!( + Spiritnet, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Attempted { + outcome: xcm::latest::Outcome::Error(xcm::latest::Error::Barrier) + }) => {}, + ] + ); + }); + + // No message should reach the relaychain. + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }) +} + +#[test] +fn test_reserve_asset_transfer_from_regular_spiritnet_account_to_asset_hub() { + MockNetworkPolkadot::reset(); + + let alice_account_id = get_account_id_from_seed::(ALICE); + let asset_hub_sovereign_account = + Spiritnet::sovereign_account_id_of(Spiritnet::sibling_location_of(AssetHubPolkadot::para_id())); + + let balance_to_transfer = 1000 * ED; + + Spiritnet::execute_with(|| { + // the sovereign_account of AssetHub should have no coins. + let balance_before_transfer: u128 = + <::Balances as Inspect>::balance(&asset_hub_sovereign_account); + + assert!(balance_before_transfer.is_zero()); + + // submit xcm message + assert_ok!(SpiritnetXcm::limited_reserve_transfer_assets( + RawOrigin::Signed(alice_account_id.clone()).into(), + Box::new(ParentThen(Junctions::X1(Junction::Parachain(asset_hub_polkadot::PARA_ID))).into()), + Box::new( + X1(Junction::AccountId32 { + network: None, + id: asset_hub_sovereign_account.clone().into() + }) + .into() + ), + Box::new((Here, balance_to_transfer).into()), + 0, + WeightLimit::Unlimited, + )); + + type RuntimeEvent = ::RuntimeEvent; + + // we expect to have the [Complete] event. + assert_expected_events!( + Spiritnet, + vec![RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Attempted { + outcome: xcm::latest::Outcome::Complete(_) + }) => {}, + ] + ); + + // we also expect that the sovereignAccount of AssetHub has some coins now + let balance_after_transfer: u128 = + <::Balances as Inspect>::balance(&asset_hub_sovereign_account); + + assert_eq!(balance_after_transfer, balance_to_transfer); + }); + + // No event on the relaychain. Message is for AssetHub. + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + + // Fails on AssetHub since spiritnet is not a trusted registrar + AssetHubPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubPolkadot, + vec![RuntimeEvent::XcmpQueue(XcmpQueueEvent::Fail { .. }) => {},] + ); + }); +} diff --git a/integration-tests/emulated/src/tests/spiritnet/sudo.rs b/integration-tests/emulated/src/tests/spiritnet/sudo.rs new file mode 100644 index 0000000000..6fef6a9eca --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/sudo.rs @@ -0,0 +1,211 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use asset_hub_polkadot_runtime::System as AssetHubSystem; +use frame_support::{assert_ok, traits::fungible::Mutate}; +use parity_scale_codec::Encode; +use runtime_common::{constants::KILT, AccountId, Balance}; +use xcm::{v3::WeightLimit, DoubleEncoded, VersionedMultiLocation, VersionedXcm}; +use xcm_emulator::{ + assert_expected_events, Here, + Instruction::{BuyExecution, Transact, UnpaidExecution, WithdrawAsset}, + Junction, Junctions, OriginKind, Parachain, ParentThen, RelayChain, TestExt, Weight, Xcm, +}; + +use crate::mock::{ + network::MockNetworkPolkadot, + para_chains::{spiritnet, AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::{Polkadot, PolkadotPallet}, +}; + +fn get_sovereign_account_id_of_asset_hub() -> AccountId { + Spiritnet::sovereign_account_id_of(Spiritnet::sibling_location_of(AssetHubPolkadot::para_id())) +} + +fn get_parachain_destination_from_parachain() -> VersionedMultiLocation { + ParentThen(Junctions::X1(Junction::Parachain(spiritnet::PARA_ID))).into() +} + +fn get_parachain_destination_from_relay_chain() -> VersionedMultiLocation { + Polkadot::child_location_of(spiritnet::PARA_ID.into()).into_versioned() +} + +fn get_unpaid_xcm_message(origin_kind: OriginKind) -> VersionedXcm<()> { + let code = vec![]; + let call: DoubleEncoded<()> = ::RuntimeCall::System(frame_system::Call::set_code { code }) + .encode() + .into(); + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1600000000000, 200000); + + VersionedXcm::from(Xcm(vec![ + UnpaidExecution { + weight_limit, + check_origin: None, + }, + Transact { + origin_kind, + require_weight_at_most, + call, + }, + ])) +} + +fn get_paid_xcm_message(init_balance: Balance, origin_kind: OriginKind) -> VersionedXcm<()> { + let code = vec![]; + + let call: DoubleEncoded<()> = ::RuntimeCall::System(frame_system::Call::set_code { code }) + .encode() + .into(); + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1600000000000, 200000); + let withdraw_asset = init_balance / 2; + + VersionedXcm::from(Xcm(vec![ + WithdrawAsset((Here, withdraw_asset).into()), + BuyExecution { + fees: (Here, withdraw_asset).into(), + weight_limit, + }, + Transact { + origin_kind, + require_weight_at_most, + call, + }, + ])) +} + +/// Sudo calls from other chains should not be whitelisted and therefore fail. +#[test] +fn test_sudo_call_from_relay_chain_to_spiritnet() { + let sudo_origin = ::RuntimeOrigin::root(); + let parachain_destination = get_parachain_destination_from_relay_chain(); + + let origin_kind_list = vec![ + OriginKind::Superuser, + OriginKind::Native, + OriginKind::SovereignAccount, + OriginKind::Xcm, + ]; + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + + let xcm = get_unpaid_xcm_message(origin_kind); + + Polkadot::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin.clone(), + Box::new(parachain_destination.clone()), + Box::new(xcm.clone()), + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { + outcome: xcm::v3::Outcome::Incomplete(_, xcm::v3::Error::NoPermission), + .. + }) => {}, + ] + ); + }); + + // No events on other parachains. Message was for the relaychain + AssetHubPolkadot::execute_with(|| { + assert_eq!(AssetHubSystem::events().len(), 0); + }); + } +} + +/// Sudo calls from other chains should not be whitelisted and therefore fail. +#[test] +fn test_sudo_call_from_asset_hub_to_spiritnet() { + let asset_hub_sovereign_account = get_sovereign_account_id_of_asset_hub(); + + let sudo_origin = ::RuntimeOrigin::root(); + let parachain_destination = get_parachain_destination_from_parachain(); + let init_balance = KILT * 10; + + let origin_kind_list = vec![ + OriginKind::Superuser, + OriginKind::Native, + OriginKind::SovereignAccount, + OriginKind::Xcm, + ]; + + for origin_kind in origin_kind_list { + MockNetworkPolkadot::reset(); + let xcm = get_paid_xcm_message(init_balance, origin_kind); + + // Give some coins to pay the fees + Spiritnet::execute_with(|| { + >::set_balance(&asset_hub_sovereign_account, init_balance); + }); + + // Send msg to Spiritnet + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin.clone(), + Box::new(parachain_destination.clone()), + Box::new(xcm.clone()) + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { + error: xcm::v3::Error::NoPermission, + .. + }) => {}, + ] + ); + }); + + // No events on the relaychain. Message was for Spiritnet + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + } +} diff --git a/integration-tests/emulated/src/tests/spiritnet/teleportation.rs b/integration-tests/emulated/src/tests/spiritnet/teleportation.rs new file mode 100644 index 0000000000..f1776c1ed2 --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/teleportation.rs @@ -0,0 +1,71 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::assert_noop; +use frame_support::dispatch::RawOrigin; +use integration_tests_common::{asset_hub_polkadot, polkadot::ED, ALICE, BOB}; +use sp_core::sr25519; +use spiritnet_runtime::PolkadotXcm as SpiritnetXcm; +use xcm::v3::WeightLimit; +use xcm_emulator::{Here, Junction, Junctions, ParentThen, TestExt, X1}; + +use crate::{ + mock::{ + network::MockNetworkPolkadot, + para_chains::{AssetHubPolkadot, Spiritnet}, + relay_chains::Polkadot, + }, + utils::get_account_id_from_seed, +}; + +#[test] +fn test_teleport_asset_from_regular_spiritnet_account_to_asset_hub() { + MockNetworkPolkadot::reset(); + + let alice_account_id = get_account_id_from_seed::(ALICE); + let bob_account_id = get_account_id_from_seed::(BOB); + + // Send XCM msg + Spiritnet::execute_with(|| { + assert_noop!( + SpiritnetXcm::limited_teleport_assets( + RawOrigin::Signed(alice_account_id.clone()).into(), + Box::new(ParentThen(Junctions::X1(Junction::Parachain(asset_hub_polkadot::PARA_ID))).into()), + Box::new( + X1(Junction::AccountId32 { + network: None, + id: bob_account_id.into() + }) + .into() + ), + Box::new((Here, 1000 * ED).into()), + 0, + WeightLimit::Unlimited, + ), + pallet_xcm::Error::::Filtered + ); + }); + // No event on the relaychain Message is for AssetHub + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); + // AssetHub should not receive any message, since the message is filtered out. + AssetHubPolkadot::execute_with(|| { + assert_eq!(AssetHubPolkadot::events().len(), 0); + }); +} diff --git a/integration-tests/emulated/src/tests/spiritnet/unpaid_execution.rs b/integration-tests/emulated/src/tests/spiritnet/unpaid_execution.rs new file mode 100644 index 0000000000..cefa82b8ed --- /dev/null +++ b/integration-tests/emulated/src/tests/spiritnet/unpaid_execution.rs @@ -0,0 +1,176 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use did::did_details::DidVerificationKey; +use frame_support::{ + assert_ok, + traits::fungible::{Inspect, Mutate}, +}; +use parity_scale_codec::Encode; +use runtime_common::{constants::EXISTENTIAL_DEPOSIT, AccountId}; +use xcm::{v3::WeightLimit, DoubleEncoded, VersionedMultiLocation, VersionedXcm}; +use xcm_emulator::{ + assert_expected_events, + Instruction::{Transact, UnpaidExecution}, + Junction, Junctions, Outcome, Parachain, ParentThen, RelayChain, TestExt, Weight, Xcm, +}; + +use crate::mock::{ + network::MockNetworkPolkadot, + para_chains::{spiritnet, AssetHubPolkadot, AssetHubPolkadotPallet, Spiritnet}, + relay_chains::{Polkadot, PolkadotPallet}, +}; + +#[test] +fn test_unpaid_execution_to_spiritnet() { + MockNetworkPolkadot::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let parachain_destination: VersionedMultiLocation = + ParentThen(Junctions::X1(Junction::Parachain(spiritnet::PARA_ID))).into(); + + let weight_limit = WeightLimit::Unlimited; + let check_origin = None; + + let xcm = VersionedXcm::from(Xcm(vec![UnpaidExecution { + weight_limit, + check_origin, + }])); + + //Send XCM message from AssetHub + AssetHubPolkadot::execute_with(|| { + assert_ok!(::PolkadotXcm::send( + sudo_origin, + Box::new(parachain_destination), + Box::new(xcm) + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Execution should be blocked by barrier + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { + error: xcm::v3::Error::Barrier, + .. + }) => {}, + ] + ); + }); + + // No event on the Polkadot message is meant for Spiritnet + Polkadot::execute_with(|| { + assert_eq!(Polkadot::events().len(), 0); + }); +} + +#[test] +fn test_unpaid_execution_from_polkadot_to_spiritnet() { + MockNetworkPolkadot::reset(); + + let sudo_origin = ::RuntimeOrigin::root(); + let parachain_destination: VersionedMultiLocation = Junctions::X1(Junction::Parachain(spiritnet::PARA_ID)).into(); + let init_balance = ::BaseDeposit::get() + + ::Fee::get() + + EXISTENTIAL_DEPOSIT; + + let weight_limit = WeightLimit::Unlimited; + let check_origin = None; + + let polkadot_sovereign_account = Spiritnet::sovereign_account_id_of(Spiritnet::parent_location()); + + let call: DoubleEncoded<()> = ::RuntimeCall::Did(did::Call::create_from_account { + authentication_key: DidVerificationKey::Account(polkadot_sovereign_account.clone()), + }) + .encode() + .into(); + + let xcm = VersionedXcm::from(Xcm(vec![ + UnpaidExecution { + weight_limit, + check_origin, + }, + Transact { + origin_kind: xcm_emulator::OriginKind::SovereignAccount, + require_weight_at_most: Weight::from_parts(10_000_600_000_000, 200_000_000_000), + call, + }, + ])); + + Spiritnet::execute_with(|| { + // DID creation takes a deposit of 2 KILT coins + Fees. We have to give them to the sovereign account. Otherwise, the extrinsic will fail. + >::set_balance(&polkadot_sovereign_account, init_balance); + }); + + // Submit XCM msg from relaychain + Polkadot::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + Box::new(parachain_destination), + Box::new(xcm) + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + Spiritnet::execute_with(|| { + type SpiritnetRuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + Spiritnet, + vec![ + SpiritnetRuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { + outcome: Outcome::Complete(_), + .. + }) => {}, + SpiritnetRuntimeEvent::Did(did::Event::DidCreated(account, did_identifier)) => { + account: account == &polkadot_sovereign_account, + did_identifier: did_identifier == &polkadot_sovereign_account, + }, + ] + ); + + // Since the user have not paid any tx fees, we expect that the free balance is the ED + let balance_after_transfer: u128 = + <::Balances as Inspect>::balance(&polkadot_sovereign_account); + + assert_eq!(balance_after_transfer, EXISTENTIAL_DEPOSIT); + }); + + // No event on AssetHubPolkadot. message is meant for Spiritnet + AssetHubPolkadot::execute_with(|| { + assert_eq!(AssetHubPolkadot::events().len(), 0); + }); +} diff --git a/integration-tests/emulated/src/utils.rs b/integration-tests/emulated/src/utils.rs new file mode 100644 index 0000000000..d2860dcef1 --- /dev/null +++ b/integration-tests/emulated/src/utils.rs @@ -0,0 +1,41 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2024 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +use polkadot_primitives::AccountId; +use sp_core::{Pair, Public}; +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + MultiSignature, +}; + +type AccountPublic = ::Signer; + +/// Helper function to generate a crypto pair from seed +pub(crate) fn get_from_seed(seed: &str) -> ::Public +where + TPublic: Public, +{ + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() +} + +pub(crate) fn get_account_id_from_seed(seed: &str) -> AccountId +where + AccountPublic: From<::Public>, +{ + AccountPublic::from(get_from_seed::(seed)).into_account() +} diff --git a/out.txt b/out.txt new file mode 100644 index 0000000000..7e94e2975f --- /dev/null +++ b/out.txt @@ -0,0 +1,9 @@ +pallet-conviction-voting v4.0.0-dev (https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2f) +├── kusama-runtime v1.0.0 (https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a) +│ └── integration-tests-common v1.0.0 (https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6b) +│ [dev-dependencies] +│ └── xcm-integration-tests v1.13.0-dev (/home/antonio/Developer/kilt-node/integration-tests/emulated) +└── polkadot-runtime v1.0.0 (https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a) + └── integration-tests-common v1.0.0 (https://github.com/paritytech/cumulus?branch=polkadot-v1.0.0#0d17cf6b) (*) + [dev-dependencies] + └── xcm-integration-tests v1.13.0-dev (/home/antonio/Developer/kilt-node/integration-tests/emulated) diff --git a/runtimes/clone/Cargo.toml b/runtimes/clone/Cargo.toml index 2ce4af47e5..19967a6147 100644 --- a/runtimes/clone/Cargo.toml +++ b/runtimes/clone/Cargo.toml @@ -113,7 +113,7 @@ std = [ "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", - "cumulus-pallet-session-benchmarking/std", + "cumulus-pallet-session-benchmarking?/std", "frame-benchmarking?/std", "frame-executive/std", "frame-support/std", diff --git a/runtimes/clone/src/xcm_config.rs b/runtimes/clone/src/xcm_config.rs index 2dc54d52db..65daebe8f9 100644 --- a/runtimes/clone/src/xcm_config.rs +++ b/runtimes/clone/src/xcm_config.rs @@ -37,7 +37,7 @@ use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use runtime_common::xcm_config::{ DenyReserveTransferToRelayChain, DenyThenTry, HereLocation, LocalAssetTransactor, LocationToAccountId, - MaxAssetsIntoHolding, MaxInstructions, ParentLegislative, UnitWeightCost, + MaxAssetsIntoHolding, MaxInstructions, ParentLocation, UnitWeightCost, }; parameter_types! { @@ -81,7 +81,7 @@ pub type XcmBarrier = DenyThenTry< // We allow everything from the relay chain if it was sent by the relay chain legislative (i.e., democracy // vote). Since the relaychain doesn't own KILTs and missing fees shouldn't prevent calls from the // relaychain legislative, we allow unpaid execution. - AllowTopLevelPaidExecutionFrom, + AllowTopLevelPaidExecutionFrom, ), UniversalLocation, ConstU32<8>, diff --git a/runtimes/common/src/xcm_config.rs b/runtimes/common/src/xcm_config.rs index 7a86aef332..2d036fb349 100644 --- a/runtimes/common/src/xcm_config.rs +++ b/runtimes/common/src/xcm_config.rs @@ -26,16 +26,19 @@ use xcm_executor::traits::{Properties, ShouldExecute}; use crate::AccountId; parameter_types! { - // One XCM operation is 1_000_000_000 weight, almost certainly a conservative estimate. - pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); + // One XCM operation is 200_000_000 weight, cross-chain transfer ~= 2x of transfer. + pub UnitWeightCost: Weight = Weight::from_parts(200_000_000, 0); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } match_types! { - // The legislative of our parent (i.e. Polkadot majority vote for Spiritnet). - pub type ParentLegislative: impl Contains = { - MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Legislative, .. }) } + pub type ParentLocation: impl Contains = { + MultiLocation { parents: 1, interior: Here} + }; + pub type ParentOrSiblings: impl Contains = { + MultiLocation { parents: 1, interior: Here } | + MultiLocation { parents: 1, interior: X1(_) } }; } diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index 288f22db56..e0857dd3bb 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -43,8 +43,8 @@ pallet-deposit-storage.workspace = true pallet-did-lookup.workspace = true pallet-dip-provider.workspace = true pallet-inflation.workspace = true -pallet-web3-names.workspace = true pallet-migration.workspace = true +pallet-web3-names.workspace = true parachain-staking.workspace = true public-credentials.workspace = true runtime-common.workspace = true @@ -169,7 +169,7 @@ std = [ "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", - "cumulus-pallet-session-benchmarking/std", + "cumulus-pallet-session-benchmarking?/std", "delegation/std", "did/std", "frame-benchmarking?/std", diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index d1584d3ea6..3ecd140e2d 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -47,7 +47,6 @@ use sp_runtime::{ }; use sp_std::{cmp::Ordering, prelude::*}; use sp_version::RuntimeVersion; -use xcm_executor::XcmExecutor; use delegation::DelegationAc; use kilt_support::traits::ItemFilter; @@ -66,8 +65,6 @@ use runtime_common::{ FeeSplit, Hash, Header, Nonce, Signature, SlowAdjustingFeeUpdate, }; -use crate::xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin}; - #[cfg(feature = "std")] use sp_version::NativeVersion; #[cfg(feature = "runtime-benchmarks")] @@ -81,7 +78,7 @@ mod tests; mod dip; mod weights; -mod xcm_config; +pub mod xcm_config; impl_opaque_keys! { pub struct SessionKeys { @@ -259,24 +256,6 @@ impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} -impl cumulus_pallet_xcmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; - type ChannelInfo = ParachainSystem; - type VersionWrapper = PolkadotXcm; - type ExecuteOverweightOrigin = EnsureRoot; - type ControllerOrigin = EnsureRoot; - type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; - type PriceForSiblingDelivery = (); -} - -impl cumulus_pallet_dmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; - type ExecuteOverweightOrigin = EnsureRoot; -} - parameter_types! { pub const MaxAuthorities: u32 = constants::staking::MAX_CANDIDATES; } diff --git a/runtimes/peregrine/src/xcm_config.rs b/runtimes/peregrine/src/xcm_config.rs index aa3617361e..88bd5db1c7 100644 --- a/runtimes/peregrine/src/xcm_config.rs +++ b/runtimes/peregrine/src/xcm_config.rs @@ -16,49 +16,59 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use super::{ +use crate::{ AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, WeightToFee, XcmpQueue, }; use frame_support::{ parameter_types, - traits::{Contains, Nothing}, + traits::{Contains, Everything, Nothing}, }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use sp_core::ConstU32; +use sp_std::prelude::ToOwned; use xcm::v3::prelude::*; use xcm_builder::{ - AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, RelayChainAsNative, SiblingParachainAsNative, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents, WithComputedOrigin, + AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, + EnsureXcmOrigin, FixedWeightBounds, NativeAsset, RelayChainAsNative, SiblingParachainAsNative, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, + UsingComponents, WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use runtime_common::xcm_config::{ DenyReserveTransferToRelayChain, DenyThenTry, HereLocation, LocalAssetTransactor, LocationToAccountId, - MaxAssetsIntoHolding, MaxInstructions, ParentLegislative, UnitWeightCost, + MaxAssetsIntoHolding, MaxInstructions, ParentLocation, ParentOrSiblings, UnitWeightCost, }; parameter_types! { pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); - // TODO: This needs to be updated once we deploy Peregrine on Rococo + // TODO: This needs to be updated once we deploy Peregrine on Rococo/Paseo pub const RelayNetworkId: Option = None; + // TODO: This needs to be updated once we deploy Peregrine on Rococo/Paseo. pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); } +/// This type specifies how a `MultiLocation` can be converted into an +/// `AccountId` within the Peregrine network, which is crucial for determining +/// ownership of accounts for asset transactions and for dispatching XCM +/// `Transact` operations. +pub type LocationToAccountIdConverter = LocationToAccountId; + /// This is the type we use to convert an (incoming) XCM origin into a local /// `Origin` instance, ready for dispatching a transaction with Xcm's /// `Transact`. There is an `OriginKind` which can bias the kind of local /// `Origin` it will become. pub type XcmOriginToTransactDispatchOrigin = ( // Sovereign account converter; this attempts to derive an `AccountId` from the origin location - // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for + // using `LocationToAccountIdConverter` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. // In contrast to Spiritnet, it's fine to include this on peregrine for testing. - SovereignSignedViaLocation, RuntimeOrigin>, + SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location which converts to a `Relay` origin when // recognized. RelayChainAsNative, @@ -74,17 +84,28 @@ pub type XcmOriginToTransactDispatchOrigin = ( /// Explicitly deny ReserveTransfer to the relay chain. Allow calls from the /// relay chain governance. -pub type XcmBarrier = DenyThenTry< - DenyReserveTransferToRelayChain, - WithComputedOrigin< +pub type XcmBarrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, ( - // We allow everything from the relay chain if it was sent by the relay chain legislative (i.e., democracy - // vote). Since the relaychain doesn't own KILTs and missing fees shouldn't prevent calls from the - // relaychain legislative, we allow unpaid execution. - AllowTopLevelPaidExecutionFrom, + // For local extrinsics. Takes credit from already paid extrinsic fee. This is outside the computed origin + // since local accounts don't have a computed origin (the message isn't send by any router etc.) + TakeWeightCredit, + // If we request a response we should also allow it to execute. + AllowKnownQueryResponses, + WithComputedOrigin< + ( + // Allow unpaid execution from the relay chain + AllowUnpaidExecutionFrom, + // Allow paid execution. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for XCM version are OK from the relaychain and other parachains. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ), - UniversalLocation, - ConstU32<8>, >, >; @@ -98,8 +119,44 @@ pub type XcmBarrier = DenyThenTry< /// parameters. pub struct SafeCallFilter; impl Contains for SafeCallFilter { - fn contains(_call: &RuntimeCall) -> bool { - false + fn contains(c: &RuntimeCall) -> bool { + fn is_call_allowed(call: &RuntimeCall) -> bool { + matches!( + call, + RuntimeCall::Ctype { .. } + | RuntimeCall::DidLookup { .. } + | RuntimeCall::Web3Names { .. } + | RuntimeCall::PublicCredentials { .. } + | RuntimeCall::Attestation { .. } + // we exclude here [dispatch_as] and [submit_did_call] + | RuntimeCall::Did ( + did::Call::add_key_agreement_key { .. } + | did::Call::add_service_endpoint { .. } + | did::Call::create { .. } + | did::Call::delete { .. } + | did::Call::remove_attestation_key { .. } + | did::Call::remove_delegation_key { .. } + | did::Call::remove_key_agreement_key { .. } + | did::Call::remove_service_endpoint { .. } + | did::Call::set_attestation_key { .. } + | did::Call::set_authentication_key { .. } + | did::Call::set_delegation_key { .. } + | did::Call::update_deposit { .. } + | did::Call::change_deposit_owner { .. } + | did::Call::reclaim_deposit { .. } + | did::Call::create_from_account { .. } + ) + ) + } + + match c { + RuntimeCall::Did(c) => match c { + did::Call::dispatch_as { call, .. } => is_call_allowed(call), + did::Call::submit_did_call { did_call, .. } => is_call_allowed(&did_call.call), + _ => is_call_allowed(&c.to_owned().into()), + }, + _ => is_call_allowed(c), + } } } @@ -112,7 +169,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTransactor = LocalAssetTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; // Reserving is disabled. - type IsReserve = (); + type IsReserve = NativeAsset; // Teleporting is disabled. type IsTeleporter = (); type UniversalLocation = UniversalLocation; @@ -163,17 +220,15 @@ parameter_types! { } impl pallet_xcm::Config for Runtime { - type MaxRemoteLockConsumers = ConstU32<10>; - type RemoteLockConsumerIdentifier = [u8; 8]; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); type RuntimeEvent = RuntimeEvent; - type SendXcmOrigin = EnsureXcmOrigin; + type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; - // Disable dispatchable execution on the XCM pallet. - // NOTE: For local testing this needs to be `Everything`. type XcmExecuteFilter = Nothing; type XcmTeleportFilter = Nothing; - type XcmReserveTransferFilter = Nothing; + type XcmReserveTransferFilter = Everything; type AdminOrigin = EnsureRoot; type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; @@ -187,7 +242,7 @@ impl pallet_xcm::Config for Runtime { type Currency = Balances; type CurrencyMatcher = (); type TrustedLockers = (); - type SovereignAccountOf = LocationToAccountId; + type SovereignAccountOf = LocationToAccountIdConverter; type MaxLockers = ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] @@ -198,3 +253,22 @@ impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; } + +impl cumulus_pallet_xcmp_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; + type ChannelInfo = ParachainSystem; + type VersionWrapper = PolkadotXcm; + type ExecuteOverweightOrigin = EnsureRoot; + type ControllerOrigin = EnsureRoot; + type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; + type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; + // TODO: Most chains use `NoPriceForMessageDelivery`, merged in https://github.com/paritytech/polkadot-sdk/pull/1234. + type PriceForSiblingDelivery = (); +} + +impl cumulus_pallet_dmp_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; + type ExecuteOverweightOrigin = EnsureRoot; +} diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml index 66b7e71c30..05df9a56ef 100644 --- a/runtimes/spiritnet/Cargo.toml +++ b/runtimes/spiritnet/Cargo.toml @@ -130,6 +130,8 @@ runtime-benchmarks = [ "pallet-indices/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-membership/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-migration/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", @@ -140,10 +142,8 @@ runtime-benchmarks = [ "pallet-vesting/runtime-benchmarks", "pallet-web3-names/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", - "pallet-multisig/runtime-benchmarks", "parachain-staking/runtime-benchmarks", "public-credentials/runtime-benchmarks", - "pallet-migration/runtime-benchmarks", "runtime-common/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -166,9 +166,9 @@ std = [ "frame-benchmarking?/std", "frame-executive/std", "frame-support/std", - "frame-system/std", "frame-system-benchmarking?/std", "frame-system-rpc-runtime-api/std", + "frame-system/std", "frame-try-runtime?/std", "kilt-runtime-api-did/std", "kilt-runtime-api-public-credentials/std", @@ -184,12 +184,12 @@ std = [ "pallet-indices/std", "pallet-inflation/std", "pallet-membership/std", + "pallet-multisig/std", + "pallet-migration/std", "pallet-preimage/std", "pallet-proxy/std", "pallet-scheduler/std", "pallet-session/std", - "pallet-multisig/std", - "pallet-migration/std", "pallet-timestamp/std", "pallet-tips/std", "pallet-transaction-payment-rpc-runtime-api/std", @@ -235,7 +235,6 @@ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "frame-try-runtime", - "pallet-multisig/try-runtime", "kilt-support/try-runtime", "pallet-aura/try-runtime", "pallet-authorship/try-runtime", @@ -246,6 +245,7 @@ try-runtime = [ "pallet-indices/try-runtime", "pallet-inflation/try-runtime", "pallet-membership/try-runtime", + "pallet-multisig/try-runtime", "pallet-migration/try-runtime", "pallet-preimage/try-runtime", "pallet-proxy/try-runtime", @@ -266,5 +266,5 @@ try-runtime = [ ] with-tracing = [ "frame-executive/with-tracing", - "sp-io/with-tracing" + "sp-io/with-tracing", ] diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index eb7fe27263..f1323887f4 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -47,7 +47,6 @@ use sp_runtime::{ }; use sp_std::{cmp::Ordering, prelude::*}; use sp_version::RuntimeVersion; -use xcm_executor::XcmExecutor; use delegation::DelegationAc; use kilt_support::traits::ItemFilter; @@ -65,8 +64,6 @@ use runtime_common::{ FeeSplit, Hash, Header, Nonce, Signature, SlowAdjustingFeeUpdate, }; -use crate::xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin}; - #[cfg(feature = "std")] use sp_version::NativeVersion; #[cfg(feature = "runtime-benchmarks")] @@ -79,7 +76,7 @@ pub use sp_runtime::BuildStorage; mod tests; mod weights; -mod xcm_config; +pub mod xcm_config; impl_opaque_keys! { pub struct SessionKeys { @@ -250,24 +247,6 @@ impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} -impl cumulus_pallet_xcmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; - type ChannelInfo = ParachainSystem; - type VersionWrapper = PolkadotXcm; - type ExecuteOverweightOrigin = EnsureRoot; - type ControllerOrigin = EnsureRoot; - type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; - type PriceForSiblingDelivery = (); -} - -impl cumulus_pallet_dmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; - type ExecuteOverweightOrigin = EnsureRoot; -} - parameter_types! { pub const MaxAuthorities: u32 = constants::staking::MAX_CANDIDATES; } diff --git a/runtimes/spiritnet/src/xcm_config.rs b/runtimes/spiritnet/src/xcm_config.rs index 01fd76152a..ae725e5096 100644 --- a/runtimes/spiritnet/src/xcm_config.rs +++ b/runtimes/spiritnet/src/xcm_config.rs @@ -16,46 +16,55 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use super::{ +use crate::{ AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, WeightToFee, XcmpQueue, }; use frame_support::{ parameter_types, - traits::{Contains, Nothing}, + traits::{Contains, Everything, Nothing}, }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use sp_core::ConstU32; +use sp_std::prelude::ToOwned; use xcm::v3::prelude::*; use xcm_builder::{ - AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, RelayChainAsNative, SiblingParachainAsNative, - SignedAccountId32AsNative, SignedToAccountId32, UsingComponents, WithComputedOrigin, + AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, + EnsureXcmOrigin, FixedWeightBounds, NativeAsset, RelayChainAsNative, SiblingParachainAsNative, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, + UsingComponents, WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use runtime_common::xcm_config::{ DenyReserveTransferToRelayChain, DenyThenTry, HereLocation, LocalAssetTransactor, LocationToAccountId, - MaxAssetsIntoHolding, MaxInstructions, ParentLegislative, UnitWeightCost, + MaxAssetsIntoHolding, MaxInstructions, ParentLocation, ParentOrSiblings, UnitWeightCost, }; parameter_types! { pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); - pub const RelayNetworkId: Option = Some(NetworkId::Polkadot); - pub UniversalLocation: InteriorMultiLocation = - Parachain(ParachainInfo::parachain_id().into()).into(); + pub const RelayNetworkId: NetworkId = NetworkId::Polkadot; + pub UniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(RelayNetworkId::get()), Parachain(ParachainInfo::parachain_id().into())); } +/// This type specifies how a `MultiLocation` can be converted into an +/// `AccountId` within the Spiritnet network, which is crucial for determining +/// ownership of accounts for asset transactions and for dispatching XCM +/// `Transact` operations. +pub type LocationToAccountIdConverter = LocationToAccountId; + /// This is the type we use to convert an (incoming) XCM origin into a local /// `Origin` instance, ready for dispatching a transaction with Xcm's /// `Transact`. There is an `OriginKind` which can bias the kind of local /// `Origin` it will become. pub type XcmOriginToTransactDispatchOrigin = ( - // We don't include `SovereignSignedViaLocation` since we don't want to allow - // other chains to manage accounts on our network. - + // Sovereign account converter; this attempts to derive an `AccountId` from the origin location + // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for + // foreign chains who want to have a local sovereign account on this chain which they control. + SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location which converts to a `Relay` origin when // recognized. RelayChainAsNative, @@ -71,17 +80,28 @@ pub type XcmOriginToTransactDispatchOrigin = ( /// Explicitly deny ReserveTransfer to the relay chain. Allow calls from the /// relay chain governance. -pub type XcmBarrier = DenyThenTry< - DenyReserveTransferToRelayChain, - WithComputedOrigin< +pub type XcmBarrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, ( - // We allow everything from the relay chain if it was sent by the relay chain legislative (i.e., democracy - // vote). Since the relaychain doesn't own KILTs and missing fees shouldn't prevent calls from the - // relaychain legislative, we allow unpaid execution. - AllowTopLevelPaidExecutionFrom, + // For local extrinsics. Takes credit from already paid extrinsic fee. This is outside the computed origin + // since local accounts don't have a computed origin (the message isn't send by any router etc.) + TakeWeightCredit, + // If we request a response we should also allow it to execute. + AllowKnownQueryResponses, + WithComputedOrigin< + ( + // Allow unpaid execution from the relay chain + AllowUnpaidExecutionFrom, + // Allow paid execution. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for XCM version are OK from the relaychain and other parachains. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ), - UniversalLocation, - ConstU32<8>, >, >; @@ -95,8 +115,44 @@ pub type XcmBarrier = DenyThenTry< /// parameters. pub struct SafeCallFilter; impl Contains for SafeCallFilter { - fn contains(_call: &RuntimeCall) -> bool { - false + fn contains(c: &RuntimeCall) -> bool { + fn is_call_allowed(call: &RuntimeCall) -> bool { + matches!( + call, + RuntimeCall::Ctype { .. } + | RuntimeCall::DidLookup { .. } + | RuntimeCall::Web3Names { .. } + | RuntimeCall::PublicCredentials { .. } + | RuntimeCall::Attestation { .. } + // we exclude here [dispatch_as] and [submit_did_call] + | RuntimeCall::Did ( + did::Call::add_key_agreement_key { .. } + | did::Call::add_service_endpoint { .. } + | did::Call::create { .. } + | did::Call::delete { .. } + | did::Call::remove_attestation_key { .. } + | did::Call::remove_delegation_key { .. } + | did::Call::remove_key_agreement_key { .. } + | did::Call::remove_service_endpoint { .. } + | did::Call::set_attestation_key { .. } + | did::Call::set_authentication_key { .. } + | did::Call::set_delegation_key { .. } + | did::Call::update_deposit { .. } + | did::Call::change_deposit_owner { .. } + | did::Call::reclaim_deposit { .. } + | did::Call::create_from_account { .. } + ) + ) + } + + match c { + RuntimeCall::Did(c) => match c { + did::Call::dispatch_as { call, .. } => is_call_allowed(call), + did::Call::submit_did_call { did_call, .. } => is_call_allowed(&did_call.call), + _ => is_call_allowed(&c.to_owned().into()), + }, + _ => is_call_allowed(c), + } } } @@ -109,7 +165,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTransactor = LocalAssetTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; // Reserving is disabled. - type IsReserve = (); + type IsReserve = NativeAsset; // Teleporting is disabled. type IsTeleporter = (); type UniversalLocation = UniversalLocation; @@ -160,17 +216,15 @@ parameter_types! { } impl pallet_xcm::Config for Runtime { - type MaxRemoteLockConsumers = ConstU32<10>; - type RemoteLockConsumerIdentifier = [u8; 8]; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); type RuntimeEvent = RuntimeEvent; - type SendXcmOrigin = EnsureXcmOrigin; + type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; - // Disable dispatchable execution on the XCM pallet. - // NOTE: For local testing this needs to be `Everything`. type XcmExecuteFilter = Nothing; type XcmTeleportFilter = Nothing; - type XcmReserveTransferFilter = Nothing; + type XcmReserveTransferFilter = Everything; type AdminOrigin = EnsureRoot; type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; @@ -184,7 +238,7 @@ impl pallet_xcm::Config for Runtime { type Currency = Balances; type CurrencyMatcher = (); type TrustedLockers = (); - type SovereignAccountOf = LocationToAccountId; + type SovereignAccountOf = LocationToAccountIdConverter; type MaxLockers = ConstU32<8>; type WeightInfo = crate::weights::pallet_xcm::WeightInfo; #[cfg(feature = "runtime-benchmarks")] @@ -195,3 +249,22 @@ impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; } + +impl cumulus_pallet_xcmp_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; + type ChannelInfo = ParachainSystem; + type VersionWrapper = PolkadotXcm; + type ExecuteOverweightOrigin = EnsureRoot; + type ControllerOrigin = EnsureRoot; + type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; + type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; + // TODO: Most chains use `NoPriceForMessageDelivery`, merged in https://github.com/paritytech/polkadot-sdk/pull/1234. + type PriceForSiblingDelivery = (); +} + +impl cumulus_pallet_dmp_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; + type ExecuteOverweightOrigin = EnsureRoot; +} diff --git a/zombienet/.env-example b/zombienet/.env-example deleted file mode 100644 index 94a7a4dd08..0000000000 --- a/zombienet/.env-example +++ /dev/null @@ -1,4 +0,0 @@ -# The docker image of the parachain. Make sure, the constructed container from the image has a bash binary. -KILT_NODE_IMAGE= -# The docker image of the relaychain. -RELAY_NODE_IMAGE= diff --git a/zombienet/README.md b/zombienet/README.md deleted file mode 100644 index 118059022e..0000000000 --- a/zombienet/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Setup - -Download Zombienet version [1.3.34](https://github.com/paritytech/zombienet/releases/download/v1.3.34/zombienet-linux-x64) and make the binary executable. Zombienet is currently under heavy development. Other versions might not work with the current defined network configuration. -Make sure you have a correct configured kubectl and all env variable, which are described in the tests/.env-example file, are set. -To set up another provider, have a look at the [official documentation](https://paritytech.github.io/zombienet/). - -The provided network configuration spawns 3 parachain nodes and 2 validator nodes. - -To run the network: -``` -zombienet spawn network-config.toml -``` - -There are two ways, to execute a test. If you do not have a spawned network, you can simply execute: - -``` -zombienet tests FILENAME.zndsl -``` - -This will create the network and perform the tests. After all tests are finished, the network is destroyed. - -If you already have a spawned network, you have to look up the ´runningNetworkSpec´ which is typically in /tmp/zombie-{HASH}/zombie.json located for the k8s provider. - -An example call would be: - - -``` -zombienet test {FILENAME}.zndsl /tmp/zombie-{HASH}/zombie.json -``` - -## Known Issues - -### Kubernetes provider - -1. If you face this error: - -``` -Error: Error: Command failed with exit code 1: kubectl --kubeconfig /home/{USER}/.kube/config --namespace zombie-087286c76d4301bac2d39f96a4a97698 cp temp-collator:/cfg/genesis-state /tmp/zombie-087286c76d4301bac2d39f96a4a97698_-1512996-vZpBh73wdvtR/2000/genesis-state -error: unable to upgrade connection: container not found ("temp-collator") -Defaulted container "temp-collator" out of: temp-collator, transfer-files-container (init) -``` - -Make sure, you have export all env variable. The env variables defines the used docker images. An example is provided in tests/.env-example. - -2. If prometheus is not working and you use minikube, delete your minikube instance and start the process again. - -### Docker - -Zombienet requires to have bash. Docker images without bash can not be tested or spawned. diff --git a/zombienet/block-authoring-tests.zndsl b/zombienet/block-authoring-tests.zndsl deleted file mode 100644 index 49654c6251..0000000000 --- a/zombienet/block-authoring-tests.zndsl +++ /dev/null @@ -1,39 +0,0 @@ -Description: Tests the basics of the network -Network: ./network-config.toml -Creds: config - - -# check if parachains is producing blocks - -kilt-node-bob: log line contains regex "\[Parachain\] .* finalized #\d+" within 120 seconds -kilt-node-alice: log line contains regex "\[Parachain\] .* finalized #\d+" within 120 seconds -kilt-node-dave: log line contains regex "\[Parachain\] .* finalized #\d+" within 120 seconds -kilt-node-charlie: log line contains regex "\[Parachain\] .* finalized #\d+" within 120 seconds - -#check if relay chain is producing blocks - -kilt-node-bob: log line contains regex "\[Relaychain\] .* finalized #\d+" within 120 seconds -kilt-node-alice: log line contains regex "\[Relaychain\] .* finalized #\d+" within 120 seconds -kilt-node-dave: log line contains regex "\[Relaychain\] .* finalized #\d+" within 120 seconds -kilt-node-charlie: log line contains regex "\[Relaychain\] .* finalized #\d+" within 120 seconds - -# check if peer connections are established in the parachain - -kilt-node-bob: reports peers count is at least 2 -kilt-node-alice: reports peers count is at least 2 -kilt-node-charlie: reports peers count is at least 2 -kilt-node-dave: reports peers count is at least 2 - -# check if peer connections are established in the relaychain - -alice: reports peers count is at least 1 -bob: reports peers count is at least 1 - - -# check if an error occurred - -alice: count of log lines containing "error" is 0 within 10 seconds -kilt-node-bob: count of log lines containing "error" is 0 within 10 seconds -kilt-node-charlie: count of log lines containing "error" is 0 within 10 seconds -kilt-node-alice: count of log lines containing "error" is 0 within 10 seconds -kilt-node-dave: count of log lines containing "error" is 0 within 10 seconds diff --git a/zombienet/network-config.toml b/zombienet/network-config.toml deleted file mode 100644 index a1b3f2b4b8..0000000000 --- a/zombienet/network-config.toml +++ /dev/null @@ -1,89 +0,0 @@ -[relaychain] -default_args = ["-lparachain=debug"] -default_command = "polkadot" -default_image = "{{RELAY_NODE_IMAGE}}" - -chain = "rococo-local" - -[[relaychain.nodes]] -name = "alice" -validator = true - -[[relaychain.nodes]] -name = "bob" -validator = true - -[[parachains]] -id = 2000 - -[[parachains.collators]] -command_with_args = """node-executable \ - --chain=dev \ - --dave \ - --runtime=peregrine \ - --rpc-port=9933 \ - --rpc-cors=all \ - --rpc-external \ - --ws-external \ - --force-authoring \ - --execution=wasm \ - --pruning archive \ - -- \ - --chain=/cfg/rococo-local.json \ - --execution=wasm""" -image = "{{KILT_NODE_IMAGE}}" -name = "kilt-node-dave" - -[[parachains.collators]] -command_with_args = """node-executable \ - --chain=dev \ - --alice \ - --runtime=peregrine \ - --rpc-port=9933 \ - --rpc-cors=all \ - --rpc-external \ - --ws-external \ - --force-authoring \ - --execution=wasm \ - --pruning archive \ - -- \ - --chain=/cfg/rococo-local.json \ - --execution=wasm""" -image = "{{KILT_NODE_IMAGE}}" -name = "kilt-node-alice" - -[[parachains.collators]] -command_with_args = """node-executable \ - --chain=dev \ - --bob \ - --runtime=peregrine \ - --rpc-port=9933 \ - --rpc-cors=all \ - --rpc-external \ - --ws-external \ - --force-authoring \ - --execution=wasm \ - --pruning archive \ - -- \ - --chain=/cfg/rococo-local.json \ - --execution=wasm""" -image = "{{KILT_NODE_IMAGE}}" -name = "kilt-node-bob" - -[[parachains.collators]] -command_with_args = """node-executable \ - --chain=dev \ - --charlie \ - --runtime=peregrine \ - --rpc-port=9933 \ - --rpc-cors=all \ - --rpc-external \ - --ws-external \ - --force-authoring \ - --execution=wasm \ - --pruning archive \ - -- \ - --chain=/cfg/rococo-local.json \ - --execution=wasm""" -image = "{{KILT_NODE_IMAGE}}" -name = "kilt-node-charlie" diff --git a/zombienet/smoke-tests.zndsl b/zombienet/smoke-tests.zndsl deleted file mode 100644 index a7af0eee77..0000000000 --- a/zombienet/smoke-tests.zndsl +++ /dev/null @@ -1,13 +0,0 @@ -Description: smoke tests -Network: ./network-config.toml -Creds: config - -#parachain -kilt-node-bob: is up within 10 seconds -kilt-node-charlie: is up within 10 seconds -kilt-node-alice: is up within 10 seconds -kilt-node-dave: is up within 10 seconds - -# validators -alice: is up -bob: is up